I run a MS Access 2003 application that sends email via MS Outlook. Each message is created with the sub procedure below. Each time I run the application, I get prompted with MS Outlook security warnings as follows:
“A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this?
If this is unexpected, it may be a virus and you should choose “No”.
[ ] Allow acess for [x minutes]
Yes No Help”
and then another:
“A program is trying to access e-mail addresses you have stored in Outlook. If this is unexpected, click Deny and verify your antivirus software is up-to-date.”
How do I turn off these warnings?
Thanks,
‘===============================================================
Sub SendEmail(ByVal strEmailAddr As String, DisplayMsg As Boolean, Optional AttachmentPath)
On Error Resume Next
Dim strMessage As String
Dim i As Integer
strMessage = “the message body goes here…..”
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
‘ Create the Outlook session.
Set objOutlook = CreateObject(“Outlook.Application”)
‘ Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
‘ Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(strEmailAddr)
objOutlookRecip.Type = olTo
‘ Add the CC recipient(s) to the message.
‘Set objOutlookRecip = .Recipients.Add(“someaddress@somedomain.com”)
‘objOutlookRecip.Type = olCC
‘ Add the BCC recipient(s) to the message.
‘Set objOutlookRecip = .Recipients.Add(“Joe Blow”)
‘objOutlookRecip.Type = olBCC
‘ Set the Subject, Body, and Importance of the message.
.Subject = “some subject goes here…”
.Body = strMessage & vbCrLf & vbCrLf
.Importance = olImportanceNormal
‘ Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
For i = 0 To UBound(varAttachments)
Set objOutlookAttach = .Attachments.Add(varAttachments(i))
Next i
End If
‘Resolve each Recipient’s name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
‘ Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
‘===============================================================