VBA - Need help automating emails with Outlook

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brossyg
    New Member
    • Nov 2008
    • 8

    VBA - Need help automating emails with Outlook

    I have some VBA code that creates an email in Access and sends it from Outlook. It is based on a query with a list of email addresses. It sends the first email to Outlook and then I have to manually click the SEND button in Outlook ... and then the second email is sent to Outlook ... and so on...

    The list of email addresses is getting quite long and I want to automate clicking the SEND button in Outlook from the VBA script...but don't know how!

    Here is the VB code currently that works perfectly as long as I manually click the SEND button in Outlook for each email:

    Code:
    Dim counter As Integer
    Dim origemailstosend As Integer
     
    counter = 1
    origemailstosend = Me![totalemails]
     
    While counter <= origemailstosend
          DoCmd.SendObject _ 
               , _
               , _ 
               , _
               [eMailclean], _ 
               , _ 
               "subscriptions@ourcompany.org", _
               "Thank you for your purchase!", _ 
               "Thank you for your purchase of the Money Matters handout and bible study series." & Chr(13) & Chr(13) & "Your Username is: " & [Acct_Number] & Chr(13) & "Your Password is: " & [ZipCode] & Chr(13) & Chr(13) & "Please go to www.ourcompany.org and click on the Stewardship Download Center to download your Money Matters files." & Chr(13) & Chr(13) & "Sincerely," & Chr(13) & Chr(13) & "Customer Service" & Chr(13) & "our company", _
              True 
     
         Me![totalemails] = Me![totalemails] - 1
         Requery
         counter = counter + 1
    Wend
     
    DoCmd.Close
    What I need to know is how to programatically click the SEND button in Outlook in the VBA code, or another way to release the email so the WEND can continue to loop without manually clicking the SEND button.

    Thanks for any help.
Working...