I have created a statement based on help from thread702-396121 (Thanks) to send an e-mail in Outlook using fields from my database. I have one problem, I would like to have the e-mail created but not sent. I would like to view the e-mail, in case the message needs to be edited slightly before send, and then manually click on the send button in Outlook. I am fairly new to VBA so any help would be greatly appreciated!
Here is my code, it is run off a button on a form that has three fields; [CCAddress], [Subject] and [Body], all of which are concatenating data from a source table.
***Begin Code***
Private Sub cmdSendEmail_Click()
Dim strEmail, strBody, strSubject, strFrom As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
strFrom = "GMB-EITSS-Work-Engagement"
strEmail = CCAddress
strSubject = SUBJECT
strBody = MainText
With objEmail
.SentOnBehalfOfName = strFrom
.To = strEmail
.SUBJECT = strSubject
.Body = strBody
.Send
End With
Set objEmail = Nothing
Exit Sub
End Sub
***END CODE***
Here is my code, it is run off a button on a form that has three fields; [CCAddress], [Subject] and [Body], all of which are concatenating data from a source table.
***Begin Code***
Private Sub cmdSendEmail_Click()
Dim strEmail, strBody, strSubject, strFrom As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
strFrom = "GMB-EITSS-Work-Engagement"
strEmail = CCAddress
strSubject = SUBJECT
strBody = MainText
With objEmail
.SentOnBehalfOfName = strFrom
.To = strEmail
.SUBJECT = strSubject
.Body = strBody
.Send
End With
Set objEmail = Nothing
Exit Sub
End Sub
***END CODE***