I have a table in access that I'm using to send Outlook emails. The emails are specific messages, and are contained in an Access module. There's a loop that sends each message. When I click on the button used to activate the code in the module, I get the outlook warning message that says that "A program is trying to send an email message on your behalf..." with the allow, deny or help buttons. That's not so bad, but this warning comes up for each message. Painful. Now, the code that sends the messages looks like this:
Code: Select all
MyDate = Date
Set dbs = CurrentDb
Set rsNames = dbs.OpenRecordset("qryReminderEmail")
rsNames.MoveFirst
Count = 0
Do Until rsNames.EOF
If rsNames("verbalSent") = False Then
Set Outlook_App = CreateObject("Outlook.Application")
Set Outlook_Mail = Outlook_App.createitem(0)
With Outlook_Mail
.To = rsNames("ManagerEmail")
.subject = "Important: "
.htmlbody = "<font face = ""Calibri""> <p>From: Human Resources</p> <p> </p></font>"
.send
End With
rsNames.Edit
rsNames("ManagerLetterSent").Value = True
rsNames("MLSentDate").Value = Date
rsNames.Update
Count = Count + 1
End If
rsNames.MoveNext
On Error GoTo 0
Set Outlook_Mail = Nothing
Set Outlook_App = Nothing
Loop