I want to automate an email to include the senders email addres with some text in the body of the email. Can somebody tell me how to it, thanks.
Code:
Private Sub send_mail_Click()
Dim olApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance
End If
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "da.drew@hotmail.co.uk"
'.Cc = "ccaddress@yourmailaddress.com"
.Subject = "Gundog Manager Registration"
.HTMLBody = "<htmltags>This email confirms that a new user has registered a copy of Gundog Manager</htmltags>"
.Send
End With
MsgBox "Operation completed successfully"
End Sub