outlook 2007 warning message when emailing from Access


H

hlock

I finally found a vb script that will email out my reports to individual
recipients. Works great! Now I'm encountering the dreaded warning message
about "A program is trying to automatically send email on your behalf". I've
looked at several solutions, but with my extremely limited knowledge of
scripting, I can't figure out how to incorporate the solutions in my Access
process. Here is the current code that I am using:

Function SendReportByEmail(strReportName As String, strEmail As String) As
Boolean
' Comments: Sends an email using SendObject method
' Parameters: strEmail - employee's email address
' strReportName - report name
' Returns: True of False

On Error GoTo PROC_ERR

Dim strRecipient As String
Dim strSubject As String
Dim strMessageBody As String

'set the mail varaibles
strRecipient = strEmail
strSubject = Reports(strReportName).Caption
strMessageBody = "Attached is a list of claims that have not been entered
into the Deductible Initiation Table. Please supply the deductible
information to ClaimHelp via a task. If the listed claim or claims do not
apply, please ignore this request."

'send the report as a snapshot
DoCmd.SendObject acSendReport, strReportName, acFormatTXT, strRecipient, , ,
strSubject, strMessageBody, False

SendReportByEmail = True

PROC_EXIT:
Exit Function

PROC_ERR:
SendReportByEmail = False
If Err.Number = 2501 Then
Call MsgBox( _
"The email was not sent for " & strEmail & ".", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"User Cancelled Operation")
Else
MsgBox Err.Description
End If
Resume PROC_EXIT

End Function

I've looked at Redemption, Wayne Phillips script and Outlookcode.com. I
just can't figure out how to change my current script to get rid of the
warnings. If anyone has suggestions, please let me know. I may ask more
questions - so I appreciate patience.
 
Ad

Advertisements

Ad

Advertisements

S

Sue Mosher [MVP-Outlook]

In Outlook, look in Tools | Trust Center | Programmatic Access. Is the
antivirus status listed as "Valid," and are the three warning option controls
enabled? If so, then you don't need Redemption to avoid security prompts.
Instead, you can just use Outlook automation (e.g the Application.CreateItem
method from the Outlook object model) to create an send a new message.

I don't know enough about SendObject to know if it's creating messages with
the report as an attachment or as the message body. I assume it's an
attachment, in which case, your Access automation code would need to save the
report as a file so it can be attached to the message using the
MailItem.Attachments.Add method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Need help with looping through records to email report 7
Help with VB 5
Dlookup Frustration 2
Email Subject Line 12
Invalid use of null 1
change e-mail subject 2
Attachments 1
Attachments 4

Top