E-mail Button in Access Form

  • Thread starter Thread starter TanyaM
  • Start date Start date
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
 
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
 
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
 
Back
Top