Send email multiple users using report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Wnicole
    New Member
    • Oct 2013
    • 3

    Send email multiple users using report

    I was hoping someone can look at this code and tell me what is missing
    It works all the way to outlook but once there it is not linking with the emails from the query on the report. It's sending the email to the first person in the table.

    Can u tell me why it's not pulling up correct email?
  • Wnicole
    New Member
    • Oct 2013
    • 3

    #2
    Here is the code

    Code:
    Option Compare Database
    
    
    Private Sub Command5_Click()
    
    
    Dim strCriteria As String
    Dim strDate As String
    Dim strEmail As String
    
    strCriteria = "[Date]=" & strDate
    
    DoCmd.OpenReport "R_WeeklyDispatch_Today", acViewPreview, , , acHidden
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("T_Inspectors", dbOpenDynaset) 'We need an email address
    rs.MoveFirst
    
    Do While Not rs.EOF 'Loop through every record in T_Inspectors and retreive emails
    
    DoCmd.OpenReport "R_WeeklyDispatch_Today", acViewPreview, , "[Employee]='" & rs![Last Name] & "'"
    
    DoCmd.SendObject acSendReport, "R_WeeklyDispatch_Today", acFormatPDF, strEmail, , , "Current Jobs", "Please contact Tracy with any concerns 415-525-0000", True
    
    rs.MoveNext
    DoCmd.Close acReport, "R_WeeklyDispatch_Today"
    Loop
    
    rs.Close
    
    Set rs = Nothing
    Last edited by Rabbit; Oct 20 '13, 04:48 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Please use code tags when posting code or formatted data.

      You never set your strEmail variable anywhere.

      Comment

      • Wnicole
        New Member
        • Oct 2013
        • 3

        #4
        I was given the code and do not know how to set the ste email.
        Can you assist me?

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          You set it by using the equal operator.
          Code:
          strEmail = your change email variable
          What that variable is will depend on where you're storing it. You haven't told us that so that's as specific as I can get.

          Comment

          Working...