Greetings,
I am attempting to use the following code (in Access 2000) to email an attachment. However, when the code runs I receive the following message: "A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and your should choose "No"."
I have set the Macro Security Level in Outlook to "Low", but this does not make a difference. Any idea as to how to get around this? In Excel, you could use "Application.Sendkeys". Is there anything similar to this in Access? (By the way, I am using Outlook 2000, SP3).
Code:
Sub Email_Attachment()
...
With objOutlookMsg
' Dialog displays here ...
Set objOutlookRecipient = .Recipients.Add(strEmailAddress)
objOutlookRecipient.Type = olTo
If strEmailCCAddress = "" Then
Else
Set objOutlookRecipient = .Recipients.Add(strEmailCCAddress)
objOutlookRecipient.Type = olCC
End If
If strEmailBccAddress = "" Then
Else
''' Dialog displays here also ...
Set objOutlookRecipient = .Recipients.Add(strEmailBccAddress)
objOutlookRecipient.Type = olBCC
End If
.Subject = strSubject
.Body = strMessage
'* Add attachments
If Not IsMissing(strAttachmentFullPath) Then
If Trim(strAttachmentFullPath) = "" Then
Else
Set objOutlookAttach = .Attachments.Add(strAttachmentFullPath)
If Err <> 0 Then Beep: _
MsgBox "Error in " & strProcName & " (3): " _
& Err.Number & " - " & Err.Description: _
Err.Clear: _
GoTo Exit_Section
End If
End If
If blnDisplayMessage Then
.Display
Else
'* Send message by putting it in the Outbox
''' Dialog displays here as well ...
.Send
End If
End With
...
End Sub
Thanks in advance!
I am attempting to use the following code (in Access 2000) to email an attachment. However, when the code runs I receive the following message: "A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and your should choose "No"."
I have set the Macro Security Level in Outlook to "Low", but this does not make a difference. Any idea as to how to get around this? In Excel, you could use "Application.Sendkeys". Is there anything similar to this in Access? (By the way, I am using Outlook 2000, SP3).
Code:
Sub Email_Attachment()
...
With objOutlookMsg
' Dialog displays here ...
Set objOutlookRecipient = .Recipients.Add(strEmailAddress)
objOutlookRecipient.Type = olTo
If strEmailCCAddress = "" Then
Else
Set objOutlookRecipient = .Recipients.Add(strEmailCCAddress)
objOutlookRecipient.Type = olCC
End If
If strEmailBccAddress = "" Then
Else
''' Dialog displays here also ...
Set objOutlookRecipient = .Recipients.Add(strEmailBccAddress)
objOutlookRecipient.Type = olBCC
End If
.Subject = strSubject
.Body = strMessage
'* Add attachments
If Not IsMissing(strAttachmentFullPath) Then
If Trim(strAttachmentFullPath) = "" Then
Else
Set objOutlookAttach = .Attachments.Add(strAttachmentFullPath)
If Err <> 0 Then Beep: _
MsgBox "Error in " & strProcName & " (3): " _
& Err.Number & " - " & Err.Description: _
Err.Clear: _
GoTo Exit_Section
End If
End If
If blnDisplayMessage Then
.Display
Else
'* Send message by putting it in the Outbox
''' Dialog displays here as well ...
.Send
End If
End With
...
End Sub
Thanks in advance!