Sending an Access report to specific email addresses?

P

Pauli G

Hello,
I'm creating an MS Access form for employees to use when reporting
errors with our GIS (geographic information systems) data. One
option I'd like to add to the form is the ability to automatically
email an error report to the GIS personnel so that they instantly know
when there's a data error/issue. I've been able to figure out how to
make a button that creates an Outlook message with an attachment of
the error report, but I'd like for this email message to automatically
have two email addresses populated in the "To:" field of Outlook. I'm
just not sure how to do this.

Here is the script that I am using to create the email message:


Private Sub EMail_Report_Click()
On Error GoTo Err_EMail_Report_Click

Dim stDocName As String

stDocName = "error reporting"
DoCmd.SendObject acReport, stDocName


Exit_EMail_Report_Click:
Exit Sub


Err_EMail_Report_Click:
MsgBox Err.Description
Resume Exit_EMail_Report_Click

End Sub
 
W

Wayne-I-M

If sending to the same e mail addresses all the time

Private Sub ButtonName_Click()
DoCmd.SendObject acReport, "Name of report here", "RichTextFormat(*.rtf)",
"(e-mail address removed)", "(e-mail address removed)", "", "Hey - our machine is
broken", "Please will you come and fix our machine as soon as possible.
Thanks", False, ""
End Sub

Or

DoCmd.SendObject acReport, "Labels Jackets_Orders",
"RichTextFormat(*.rtf)", "(e-mail address removed);[email protected]", "", "",
"Hey - our machine is broken", "Please will you come and fix our machine as
soon as possible. Thanks", False, ""


If sending the mail to addresses shown in 2 controls on the form (where the
CC may or may not be empty) - I use the If Not IsNull to stop the errors
caused by the empty address in the code in outllook

Private Sub ButtonName_Click()
If Not IsNull(Me.CCMailAdress) Then
DoCmd.SendObject acReport, "Report Name Here", "RichTextFormat(*.rtf)",
FormName!EMailaddress, Forms!CCMailAdress, "", "Hey - our machine is broken",
"Please will you come and fix our machine as soon as possible. Thanks",
False, ""
Else
DoCmd.SendObject acReport, "Report Name Here", "RichTextFormat(*.rtf)",
FormName!EMailaddress, , "", "Hey - our machine is broken", "Please will you
come and fix our machine as soon as possible. Thanks", False, ""
End If
End Sub

Note the "" before the "Hey - our..... this is the space where the CC would
be in the "Else" case


Hope this helps
 

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

Top