FYI - this is what I use:
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 = "Your Order Number " & Forms!ordersfrm.CustID.Column(4) & " "
& Forms!ordersfrm.CustID.Column(3)
.Body = vbCrLf & _
"Thank you for your recent order. " & _
vbCrLf & vbCrLf & "Please print the attachment (total of 3 pages).. Sign
two of the pages and fax back toll free to (877)000-0000 using the cover
sheet provided. " & vbCrLf & vbCrLf & _
"Further, if you can arrange to return by email . . . ." & vbCrLf&
vbCrLf & _
"Your order will not continue to be processed until your signed invoice
is received via fax." & vbCrLf & vbCrLf & _
"Kind regards, " & vbCrLf & vbCrLf & _
"Sales Guy" & vbCrLf & _
"Process Department" & vbCrLf & _
"My Company" & vbCrLf & _
"(877)000-0000 Office" & vbCrLf & _
"(877)000-0000 Fax" & vbCrLf & _
"
www.mycompany.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
Bonniehttp://
www.dataplus-svc.com
I'm pretty certain the following will work:
Private Sub Command50_Click()
Dim stURL As String
stURL = "mailto:" & & "?Subject=" & [Subject] & "?Body=" &
[Body]
Application.FollowHyperlink stURL
End Sub[/QUOTE]
[QUOTE]
...however, I'd like to add attachments. How could I do this? (and is
my code correct up there?)[/QUOTE]
[QUOTE]
Thanks in advance!
magmike[/QUOTE]
[/QUOTE]
Wow! I used this code (modified of course) and am getting all sorts of
errors! Here is what I have modified it to:
Private Sub SendMessage_Click(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
Mrecip = Forms!ProspectForm.EmailAddress
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 = [NOTES]
.Body = vbCrLf & _
[LetterBody]
' 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
I'm getting an error about "NewMonth" and "NewYear" on the opening of
the form, and then when I click on the button I get an error as well.
They all end saying something about an Ambiguous name
"SendMessage_Cick"