Results 1 to 2 of 2
  1. #1
    Manasa is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    1

    Send Report by mail for the mail Ids present in the table from a button click

    Hi,
    Right now I have this code in the onclick event of my "Email " button(Command button)-
    DoCmd.SendObject acSendReport, "Project Executive Summary", acFormatPDF, "", "", "", "Project Executive Summary Report", "Here is the attached Report", True

    I need to pull the TO list from the table .For say there is a field called "To List" for each Record in my table.

    I need to send a mail to Project App team of "Project executive Summary Report" for each Phase.


    There are around five phases for projects.Each phase will contain around 5 to 10 records.
    I have five reports for each different phases.But I need to pull the "To List" mail details of those 5 to 10 records which comes under a single phase.

    The mail should go to "To List" details for each phase as each phase contains 5 to 10 records.It should append all the mail IDs in the "To list" of the code.
    How can we do this?Please help me .Thank you

  2. #2
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    I use the following code to do something similar. See what you can use from it.

    Code:
    Dim varApprovalRequest, varReportName, varSendTo, varSendFrom, varHTMLBody As String
    Dim varUsername, varSubjectText, varSendCC As String
    Dim objOutlook, objEmail As Object
    
    
    varApprovalRequest = DLookup("data", "table", "child = 'ApprovalRequestMessage'")
    varReportName = DLookup("data", "qry_drcconfig", "child = 'ApprovalRequetForm'")
    varSendTo = Me.ComboApprover.Column(2)
    varSendFrom = DLookup("email", "tbl_contact", "ID = " & [TempVars]![varDRCContactID])
    varSubjectText = "Design Review Project Approval Request: " & [TaskSR]
    varEmailTemplate = DLookup("data", "qry_drcconfig", "child = 'ApprovalRequestTemplate'")
    varSendCC = DLookup("data", "qry_drcconfig", "child = 'ApprovalCopyToList'")
    
    DoCmd.OutputTo acOutputReport, varReportName, acFormatHTML, varApprovalRequest
    
    Set objOutlook = CreateObject("Outlook.application")
    
    Set objEmail = objOutlook.CreateItemFromTemplate(varEmailTemplate)
    With objEmail
    .To = varSendTo
    .cc = varSendCC
    .Subject = varSubjectText
    '.Body = "The body doesn't matter, just the attachment"
    .HTMLBody = varHTMLBody
    .Attachments.Add varApprovalRequest
    .Display
    .SentOnBehalfOfName = varSendFrom
    '.Send - this didn't work on my setup but .Display did
    '.ReadReceiptRequested
    End With
    There are a couple of things with this code. The first is that it uses an HTML file generated from a report as the body. The second is that I have a qry that I get the information from called qry_drcconfig. You will want to modify your code to work with your data.

    Good luck.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Send e-mail with info from Report
    By mari_hitz in forum Import/Export Data
    Replies: 22
    Last Post: 12-17-2011, 06:24 PM
  2. send a form via mail
    By Fabdav in forum Forms
    Replies: 1
    Last Post: 10-12-2011, 07:35 AM
  3. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  4. Click a Button to Run Word Mail Merge...
    By nchesebro in forum Programming
    Replies: 6
    Last Post: 03-09-2011, 01:41 PM
  5. Send mail to the chosen ones
    By carstenhdk in forum Import/Export Data
    Replies: 0
    Last Post: 05-18-2010, 11:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums