Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto email how to click "send"

Status
Not open for further replies.

legolas75

Technical User
Mar 19, 2007
17
US
I have a program that will send a report to email addresses contained in a table. The problem is that Outlook opens and I have to click on the "send" button everytime before the program loops and the next email is created. How do I programmatically click on the "send" button. Also, if there is a way to delete all of these emails from my "sent items" folder that would be useful too. The code is posted below. Thanks. Mike

Private Sub cmd_test_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim vIPA_NUM As String
Dim strReport As String
Dim strReportPath As String

strReportPath = "c:\"
strReport = "1 rpt_Summary"

Set db = CurrentDb
Set rs = db.OpenRecordset("tblEmail")
rs.MoveFirst
Do

DoCmd.SetWarnings False

vIPA_NUM = rs.Fields("IPA_NUM")

DoCmd.RunSQL "SELECT DATA1.* INTO [1 rpt_Summary] FROM DATA1 WHERE (((DATA1.IPA_NUM)= '" & vIPA_NUM & "'))", -1
DoCmd.SendObject acSendReport, "1 rpt_Summary", "MicrosoftExcelBiff8(*.xls)", rs.Fields("Email_Address"), "", "", "1 rpt_Summary", "Please find attached your report", True

rs.MoveNext

Loop Until rs.EOF

DoCmd.SetWarnings True

rs.Close
db.Close
End Sub
 
There are about 8,000,000 threads in this forum dedicated to this subject. You will probably need to move away from sendObject method, but I suggest you google 'outlook redemption' or look into using CDO.

HOpe this helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
And what about this ?
DoCmd.SendObject acSendReport, "1 rpt_Summary", "MicrosoftExcelBiff8(*.xls)", rs.Fields("Email_Address"), "", "", "1 rpt_Summary", "Please find attached your report", [!]False[/!]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That gets me to where the security patch comes up and asks me whether I want to allow the email to be sent.
 
Have a look here:
[google]outlook "object model guard"[/google]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top