Trying to send a email through a command button. I get the email correctly, however I would like the form data in the subject line. Can you please help?
Here is the code I have so far...this works to pull up an email, but I need the form data. The table the form is built from is tbl_Master Data Table, and the form is frm_Master Data Table. The MAWB and HAWB is the fields from the form I need in the subject line.
Here is the code I have so far...this works to pull up an email, but I need the form data. The table the form is built from is tbl_Master Data Table, and the form is frm_Master Data Table. The MAWB and HAWB is the fields from the form I need in the subject line.
Private Sub Command120_Click()
DoCmd.SetWarnings True
Dim Email As String
Dim MAWB As String
Dim HAWB As String
Dim notes As String
'**create variables for Outlook
'Dim objOutlook As Outlook.Application'
'Dim objEmail As Outlook.MailItem'
'**gathers information from your form. this sets the string variable to your fields
'Email = Me!Email
'MAWB = Me!MAWB
'HAWB = Me!HAWB
'origin = Me!origin
'destination = Me!destination
'notes = Me!notes
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.To = strEmail
.Subject = MAWB & HAWB
.Body = notes
.Display
End With
End Sub
DoCmd.SetWarnings True
Dim Email As String
Dim MAWB As String
Dim HAWB As String
Dim notes As String
'**create variables for Outlook
'Dim objOutlook As Outlook.Application'
'Dim objEmail As Outlook.MailItem'
'**gathers information from your form. this sets the string variable to your fields
'Email = Me!Email
'MAWB = Me!MAWB
'HAWB = Me!HAWB
'origin = Me!origin
'destination = Me!destination
'notes = Me!notes
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.To = strEmail
.Subject = MAWB & HAWB
.Body = notes
.Display
End With
End Sub