Here's a start I'm doing this:
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim Mrecip As String
Dim Mrecname As String
Mrecip = Forms!ordersfrm.EmailAdd
MrecipName = Forms!ordersfrm.CustID.Column(3)
DoCmd.SetWarnings off
' Create the outlook session.
Set objOutlook = CreateObject("Outlook.Application")
'Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To receipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(Mrecip)
' Set the Subject and Body of the message.
.Subject = "Whatever" & Forms!ordersfrm.CustID.Column(4) & " " & Forms!
ordersfrm.CustID.Column(3)
.Body = vbCrLf & _
"Thank you for your recent order. " & _
vbCrLf & vbCrLf & "Please print the attachment. Sign two of the pages and
fax back toll free to (888)888-8888 using the cover sheet provided. Fax
machine remains on." & vbCrLf & vbCrLf & _
"Further, if you can arrange to return by email three or four pictures it
would be greatly appreciated." & vbCrLf & vbCrLf & _
"Your order will not continue to be processed until your signed invoice
is received via fax." & vbCrLf & vbCrLf & _
"Kind regards, " & vbCrLf & vbCrLf & _
"John Smith" & vbCrLf & _
"Process Department" & vbCrLf & _
"My Company" & vbCrLf & _
"(888)888-8888 Office" & vbCrLf & _
"(888)888-8888 Fax" & vbCrLf & _
"
www.mememe.com" & vbCrLf & vbCrLf & vbCrLf
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Sub
And here's the onclick event to send it from the form:
Private Sub E_Mail_Click()
On Error GoTo Err_E_Mail_Click
Dim morder As String
Dim minvoice As String
minvoice = "C:\Invoice.pdf"
If IsNull(Forms!ordersfrm.EmailAdd) Then
MsgBox "There is no email address for this customer!"
Else
DoCmd.OpenReport "Invoice", acViewNormal
SendMessage True, minvoice
End If
Exit_E_Mail_Click:
Exit Sub
Err_E_Mail_Click:
If IsNull(Forms!ordersfrm.EmailAdd) Then
MsgBox "There is no email address for this customer!"
End If
'MsgBox Err.Description
Resume Exit_E_Mail_Click
End Sub
You can remove the code for the attachment and change the .Body text with
your report.
Bonnie
http://www.dataplus-svc.com