Hello,
I'm a bit of a novice programmer and really need some help with this.
I've got the code below to work fine but when it creates the new mail message it doesn't add the signature. I've been searching but with no luck. Any ideas how I add the default outlook signature to the email message?
Thanks for any help in advance.
Private Sub Command40_Click()
On Error GoTo TrapEmailError:
Dim rsEmail As DAO.Recordset
Dim olApp As Object
Dim objOutlook As Object
Dim ObjMessage As Object
Dim strbody As String
Dim strsubject As String
Dim sfilepath As String
Dim shtml As String
Dim db As DAO.Database
Dim stremail As String
Const olto As Long = 1
Const olMailItem As Long = 0
Set objOutlook = CreateObject("Outlook.Application")
Set db = CurrentDb
Set rsEmail = CurrentDb.OpenRecordset("tblEmailClients")
While Not rsEmail.EOF
stremail = rsEmail.Fields("Email").Value
strsubject = rsEmail.Fields("subject").Value
strbody = rsEmail.Fields("detail").Value
Set ObjMessage = objOutlook.CreateItem(olMailItem)
With ObjMessage
.To = stremail
.Subject = strsubject
.HTMLBODY = strbody
.Attachments.Add (Me.AttachmentPath)
.Display
'.Send
End With
rsEmail.MoveNext
Wend
MsgBox "All emails have been sent, check your sent items in outlook.", , "Email Confirmation"
Set rsEmail = Nothing
Set ObjMessage = Nothing
TrapEmailError:
0
'MsgBox Err.Description
End Sub
I'm a bit of a novice programmer and really need some help with this.
I've got the code below to work fine but when it creates the new mail message it doesn't add the signature. I've been searching but with no luck. Any ideas how I add the default outlook signature to the email message?
Thanks for any help in advance.
Private Sub Command40_Click()
On Error GoTo TrapEmailError:
Dim rsEmail As DAO.Recordset
Dim olApp As Object
Dim objOutlook As Object
Dim ObjMessage As Object
Dim strbody As String
Dim strsubject As String
Dim sfilepath As String
Dim shtml As String
Dim db As DAO.Database
Dim stremail As String
Const olto As Long = 1
Const olMailItem As Long = 0
Set objOutlook = CreateObject("Outlook.Application")
Set db = CurrentDb
Set rsEmail = CurrentDb.OpenRecordset("tblEmailClients")
While Not rsEmail.EOF
stremail = rsEmail.Fields("Email").Value
strsubject = rsEmail.Fields("subject").Value
strbody = rsEmail.Fields("detail").Value
Set ObjMessage = objOutlook.CreateItem(olMailItem)
With ObjMessage
.To = stremail
.Subject = strsubject
.HTMLBODY = strbody
.Attachments.Add (Me.AttachmentPath)
.Display
'.Send
End With
rsEmail.MoveNext
Wend
MsgBox "All emails have been sent, check your sent items in outlook.", , "Email Confirmation"
Set rsEmail = Nothing
Set ObjMessage = Nothing
TrapEmailError:
0
'MsgBox Err.Description
End Sub