Sending E-Mails via code

D

Darren

We use a database to log all fault calls and need a better way to send to
the callers confirmation of the closure/solution.

At present the code below is used on the AfterUpdate event in a check box
chkResolved. The code relies of a report being generated and attached as
well as the mail body. Is there anyway a normal e-mail can be issued in
plain text without the need to attach reports?

***********************************
Dim SendDoc As String, UserMail As String, CallSheet As String, Subject As
String, Body As String, Solution As String

If Me.ID = 571 Then
' Check that the call was made by internal staff
SendDoc = "rpt_Call-Confirmation"
' Select the correct report layout for internal staff
Solution = DLookup("[Solution]", "qry_Mailing-Solution", "")
' Pull out the solution details for the case in hand using pre-defined query
UserMail = Me.txtUserEMail
Subject = "Call Closure: " & txtMFLRef
Body = "Your Reference: " & txtMFLRef & Chr(10) & "Our Reference: " &
Me.txtFaultNumber & Chr(10) & Chr(10) & "Your recent call to the IT Helpdesk
has now been resolved. The resolution details are as follows:" & Chr(10) &
Chr(10) & Solution

DoCmd.SendObject acReport, SendDoc, "HTML(*.html)", UserMail, "", "",
Subject, Body, False, ""

End If
***********************************
 
P

Peter De Baets

SEND AN E-MAIL MESSAGE FROM ACCESS

It's simple! I just learned how to do it, and I thought I'd share it with
you. You need an e-mail program that uses MAPI, like Outlook Express:

DoCmd.SendObject ,,,"(e-mail address removed)",,,"Subject","Message",False

The above example will put an e-mail message to "(e-mail address removed)" into your
outbox. To have the e-mail send window pop up, change the last parameter to
"True". To send to more addresses, separate the addresses with a semicolon.
Here's another example that shows where to put CC and Bcc addresses:

DoCmd.SendObject , , , "(e-mail address removed);[email protected]","(e-mail address removed)"
,"(e-mail address removed)" , "Subject", "Message", False

E-MAIL THE OUTPUT OF A REPORT FROM ACCESS

Here's an example of how to send the output of a report named "Sales By
Order" via e-mail. If your report prompts you for parameters, you will be
prompted for them when you run this command:

DoCmd.SendObject acSendReport, "Sales By Order", acFormatRTF,
"(e-mail address removed)", , , "Subject", "Message", False

The "acFormatRTF" parameter will send the report output in a format that can
be read by MS Word. You can also use:

"acFormatHTML" - Your sent report output will be opened with a web browser.
"acFormatTXT" - Your sent report output will be opened with notepad, or
wordpad.

E-MAIL AN ATTACHMENT

To include an attachment with your e-mail, you need to use automation
because SendObject won't do this. Here's how to use automation to send an
e-mail attachment:
http://support.microsoft.com/support/kb/articles/q209/9/48.asp

Hope this helps,


--
Peter De Baets
Peter's Software - MS Access Tools for Developers
http://www.peterssoftware.com

Darren said:
We use a database to log all fault calls and need a better way to send to
the callers confirmation of the closure/solution.

At present the code below is used on the AfterUpdate event in a check box
chkResolved. The code relies of a report being generated and attached as
well as the mail body. Is there anyway a normal e-mail can be issued in
plain text without the need to attach reports?

***********************************
Dim SendDoc As String, UserMail As String, CallSheet As String, Subject As
String, Body As String, Solution As String

If Me.ID = 571 Then
' Check that the call was made by internal staff
SendDoc = "rpt_Call-Confirmation"
' Select the correct report layout for internal staff
Solution = DLookup("[Solution]", "qry_Mailing-Solution", "")
' Pull out the solution details for the case in hand using pre-defined query
UserMail = Me.txtUserEMail
Subject = "Call Closure: " & txtMFLRef
Body = "Your Reference: " & txtMFLRef & Chr(10) & "Our Reference: " &
Me.txtFaultNumber & Chr(10) & Chr(10) & "Your recent call to the IT Helpdesk
has now been resolved. The resolution details are as follows:" & Chr(10) &
Chr(10) & Solution

DoCmd.SendObject acReport, SendDoc, "HTML(*.html)", UserMail, "", "",
Subject, Body, False, ""

End If
***********************************
 

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