bsyalniz said:
Trying to setup a button to send information from the database to a
contact.
Ex. If a contact requests information that is contained in the database, I
want to be able to click on the contact in the database and it will send
an
e-mail to the contact with the information they requested.
Here's some of my code from my website:
http://www.datastrat.com/Code/OutlookEmail.txt
Notice the following line:
.body = "The body doesn't matter, just the attachment"
Instead change it to:
.body = Me.txtFirstName & " " & Me.txtLastName & vbCrLf & _
Me.txtAddress & vbCrLf & Me.txtCity & ", " & Me.txtState &
_
vbCrLf & vbCrLf & Me.txtPhone
substituting your control names, of course.
Private Sub Command0_Click()
'Arvin Meyer 03/12/1999
'Updated 7/21/2001
On Error GoTo Error_Handler
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = "(e-mail address removed)"
.Subject = "Look at this sample attachment"
.body = "The body doesn't matter, just the attachment"
.Attachments.Add "C:\Test.htm"
'.attachments.Add "c:\Path\to\the\next\file.txt"
.Send
'.ReadReceiptRequested
End With
Exit_Here:
Set objOutlook = Nothing
Exit Sub
Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here
End Sub