Sending email from Access using recipient name from text box??

G

Guest

I figured out how to have Access send an email, but now, I want to enter some
info into the email from text boxes on the form that has the button that
sends the email. Here's what I want to do:
1. get recipient name from a text box
2. add info from another text box into part of the subject and/or body
(kind of like a concatenate function in Excel)

Here is the code I am using to send the email so far:

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("????????")
objOutlookRecip.Type = olTo
.Subject = "??????????????????????????"
.Body = "?????????????????" & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing

Thanks ahead of time!!!
Doug
 
G

Guest

It would look like:

....
..Subject = Me.SubjectControlNameFromForm
..Body = Me.BodyControlNameFromForm & vbCrLf & vbCrLf
....
 

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