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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Alert Box 2

Status
Not open for further replies.

hsp7777

Programmer
Jan 11, 2005
67
0
0
US
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!
 
Do a google search for outlook object model guard

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. The "ClickYes" freeware program seemed to do the trick. Thanks again.
 
Just as a follow-up to the "ClickYes" freeware program, I have noticed that if my workstation is locked, then the program doesn't run until I unlock my machine. Is there anyway to get the "ClickYes" program to run even if the workstation is locked?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top