Sending Outlook emails from Access

BobSullivan
3StarLounger
Posts: 235
Joined: 08 Jun 2010, 20:03
Location: Morgantown, PA

Sending Outlook emails from Access

Post by BobSullivan »

Hello,

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
If I removed the Set Outlook_Mail = Nothing and the Set Outlook_App = Nothing, would this fix the problem? Or would it cause others?
Cordially,

Bob Sullivan
Elverson, PA

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sending Outlook emails from Access

Post by HansV »

This used to be a problem a while ago, but Microsoft usually doesn't show this message anymore if your antimalware protection is up to date...
Best wishes,
Hans

BobSullivan
3StarLounger
Posts: 235
Joined: 08 Jun 2010, 20:03
Location: Morgantown, PA

Re: Sending Outlook emails from Access

Post by BobSullivan »

Thanks for the quick reply. Yes, it doesn't happen when I do it from my email, but it does when the group I wrote it for tries to run it. Is there some sort of work around I can write for them?
Cordially,

Bob Sullivan
Elverson, PA

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sending Outlook emails from Access

Post by HansV »

Which version of Office are they using? And is their antivirus software up to date?
Best wishes,
Hans

BobSullivan
3StarLounger
Posts: 235
Joined: 08 Jun 2010, 20:03
Location: Morgantown, PA

Re: Sending Outlook emails from Access

Post by BobSullivan »

Office 2016, and I can't verify about the antivirus software.
Cordially,

Bob Sullivan
Elverson, PA

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Sending Outlook emails from Access

Post by HansV »

My first guess is that the problem will be gone if they fix their security software.
Best wishes,
Hans