Results 1 to 2 of 2
  1. #1
    faodavid is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Aug 2014
    Posts
    17

    Beginner Help Selecting individual reords from a query to send an email shot to

    Hi
    Can any help. I have a venue database of 4,000, I have ran a parameter query to select the correct venue capacity range in the right locations. I only want to send an email shot to certain venues in the query and keep a record the venues that I have emailed.

    Thanks in advance
    Dave

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    You need a tELog table to track who/when when you sent the emails.
    At the SEND1EMAIL you would run a query to add the email address to the log file

    Code:
    Public Sub SendRstEmails()
    Dim rst As DAO.Recordset
    Dim strBody
    Dim vTo, vSubj
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set rst = currentdb.openrecordset("qsEmails")
    '================
        'send 1 email with everyones address, or
    '================
    vSubj = "Teste" & " " & rst![SAP] & " " & rst![Nome]
    While Not rst.EOF
      vTo = vTo & rst![Email] & ";"
      rst.MoveNext
    Wend
      
    Send1Email vTo, vSubj, strBody
    rst.Close
    Set rst = Nothing
    End Sub
    
     '================
       'sent many emails, 1 per person
    '================
    While Not rst.EOF
      vTo = rst![Email]
      vSubj = "Teste" & " " & rst![SAP] & " " & rst![Nome]
      
       Send1Email vTo, vSubj, strBody
      
       rst.MoveNext
    Wend
    rst.Close
    Set rst = Nothing
    End Sub
    
    '-------
    'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!!   checkmark OUTLOOK OBJECTS in the vbE menu, Tools, References
    '-------
    Public Function Send1Email (ByVal pvTo, ByVal pvSubj, ByVal pvBody, optional pvFile ) As Boolean
    Dim oApp As Outlook.Application
    Dim oMail As Outlook.MailItem
    On Error GoTo ErrMail
    Set oApp = CreateObject("Outlook.Application")
    Set oMail = oApp.CreateItem(olMailItem)
    With oMail
        .To = pvTo
        .Subject = pvSubj
        .Body = pvBody
        .Attachments.Add pvFile, olByValue, 1
        
       .Send
    End With
    EmailO = True
    Set oMail = Nothing
    Set oApp = Nothing
    Exit Function
    ErrMail:
    MsgBox Err.Description, vbCritical, Err
    Resume Next
    End Function

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

Similar Threads

  1. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  2. Replies: 6
    Last Post: 03-19-2014, 03:53 PM
  3. Replies: 3
    Last Post: 08-16-2013, 04:15 PM
  4. Use Query Results to send Email
    By Paul Ager in forum Programming
    Replies: 2
    Last Post: 05-05-2011, 09:57 AM
  5. Beginner trying to send email with attachment
    By ahm in forum Programming
    Replies: 2
    Last Post: 03-24-2009, 08: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