By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

VBA - Need help automating emails with Outlook

P: 8
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:

Expand|Select|Wrap|Line Numbers
  1. Dim counter As Integer
  2. Dim origemailstosend As Integer
  3.  
  4. counter = 1
  5. origemailstosend = Me![totalemails]
  6.  
  7. While counter <= origemailstosend
  8.       DoCmd.SendObject _ 
  9.            , _
  10.            , _ 
  11.            , _
  12.            [eMailclean], _ 
  13.            , _ 
  14.            "subscriptions@ourcompany.org", _
  15.            "Thank you for your purchase!", _ 
  16.            "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", _
  17.           True 
  18.  
  19.      Me![totalemails] = Me![totalemails] - 1
  20.      Requery
  21.      counter = counter + 1
  22. Wend
  23.  
  24. DoCmd.Close
  25.  
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.
Jan 28 '09 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.