How do I send informatin from the database to a contact?

B

bsyalniz

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.
 
B

BruceM

Check Help for information about SendObject. You can add the appropriate
information to the subject line and/or the message body, as needed.
Presumably you are clicking on a button or text box or something on a form.
Is the contact e-mail address in the record from which you are clicking? If
so, add that to the To argument, then add to the other arguments as needed
for subject, message, and so forth, with commas as placeholders if you are
not using the argument. This may be clearer when you look at the Help file.
If you have further question, please provide specific information about such
things as how Access is to determine the e-mail address, and where it gets
the data to be included in the subject and/or message.
 
A

Arvin Meyer MVP

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
 

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