E-mail Button in Access Form

T

TanyaM

In my customer database, in the contact form I have a send contact e-mail
button. when clicked I want to launch an outlook e-mail with the current
record's e-mail populatedin the to field. I can't seem to get it to look at
the current record in the form (it seems to populate from all over the place,
but never the right one). Here's what I have so far:

Private Sub SendEmail_Click()
Dim myOlApp As Outlook.Application
Dim myItem As Outlook.MailItem

Dim strLtrContent As String
Dim rsContacts As New ADODB.Recordset

rsContacts.ActiveConnection = CurrentProject.Connection
'Contacts = contact's Table - is there a way to get it to look at the
contact's form?
rsContacts.Open "Contacts"


Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
myItem.Recipients.Add rsContacts("EmailName")
myItem.Display

End Sub

Any help is so appreciated as I'm new at programming in Access.

Thanks,
Tanya
 
W

Wayne-I-M

Hi

Am a litle lost with what you're trying to do.

But if you have a text box with an e mail address called txtEmailAddress

put this onclick of a button

Private Sub ButtonName_Click()
If Not IsNull(Me.txtEmailAddress) Then
Application.FollowHyperlink "MailTo:" & [txtEmailAddress]
Else
MsgBox "There is no E Mail address on file for this person",
vbInformation, "E Mail options"
End If
End Sub
 
P

Peter Hibbs

Tanya,

Why do you need to use Outlook, why not just use the SendObject
function.

DoCmd.SendObject , , "EMail", "EMailAddress", , , "MailSubject",
"MailMessage", True

(All on one line).

Peter Hibbs
 

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