Email from a form to an address in a table

Brando

Enthusiastic Novice
Local time
Today, 07:48
Joined
Apr 4, 2006
Messages
100
I can't seem to find the right answer....

The following code puts the text box contents in the "To:" section of the email. But on the form, the text box only includes the person's last name and I want it to go to a table and pull either FullName or Email and put it into the "To:". (it's not a huge list of people and there are no duplicate last names so far) Any advice is appreciated.
___________________________________________
Private Sub txtLastName_DblClick(Cancel As Integer)

Dim Email As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'Gathers info from the form. This sets the string variable to the field(s).
Email = Me!txtLastName
'Creates an instance of Outlook.
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

With objEmail
.To = Email
.Subject = "Weely Specials"
.Display 'Creates and displays the email."

End With

Exit_txtLastName_DblClick:

Exit Sub

End Sub
___________________________________________
 
This might work for you:

Try using a "dlookup" to pull the email address from your source table
matching Me!txtLastName on your form.
 

Users who are viewing this thread

Back
Top Bottom