erisciveja
New Member
- Joined
- Apr 3, 2023
- Messages
- 2
- Office Version
- 365
- 2016
- Platform
- Windows
Sub sendCustEmails()
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)
Dim Signature As String
intRow = 2
While (ThisWorkbook.Sheets("Client_Data").Range("A" & intRow).Text <> "")
Set objEmail = objOutlook.CreateItem(olMailItem)
strMailSubject = ThisWorkbook.Sheets("Mail_Details").Range("A2").Text
strMailBody = ThisWorkbook.Sheets("Mail_Details").Range("B2").Text
intRow = 2
strAudit = ThisWorkbook.Sheets("Client_Data").Range("A" & intRow).Text
strPrefix = ThisWorkbook.Sheets("Client_Data").Range("B" & intRow).Text
strName = ThisWorkbook.Sheets("Client_Data").Range("C" & intRow).Text
strEmail = ThisWorkbook.Sheets("Client_Data").Range("D" & intRow).Text
strAttachment = ThisWorkbook.Sheets("Client_Data").Range("E" & intRow).Text
strSignature = ThisWorkbook.Sheets("Client_Data").Range("F" & intRow).Text
strMailBody = Replace(strMailBody, "<Prefix>", strPrefix)
strMailBody = Replace(strMailBody, "<Name>", strName)
strMailBody = Replace(strMailBody, "<Audit>", strAudit)
strMailBody = Replace(strMailBody, "<Signature>", strSignature)
With objEmail
.To = CStr(strEmail)
.Subject = strMailSubject
.Body = strMailBody & Signature
.Attachments.Add strFolder & "\" & strAttachment
.Display
End With
intRow = intRow + 1
Wend
MsgBox "Done"
End Sub
This code currently displays an Outlook Email before I send it out. Everything seems fine, the attachment is also there. But the only issue is that I can't display the Signature. Can anybody review this code and help me out please?
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)
Dim Signature As String
intRow = 2
While (ThisWorkbook.Sheets("Client_Data").Range("A" & intRow).Text <> "")
Set objEmail = objOutlook.CreateItem(olMailItem)
strMailSubject = ThisWorkbook.Sheets("Mail_Details").Range("A2").Text
strMailBody = ThisWorkbook.Sheets("Mail_Details").Range("B2").Text
intRow = 2
strAudit = ThisWorkbook.Sheets("Client_Data").Range("A" & intRow).Text
strPrefix = ThisWorkbook.Sheets("Client_Data").Range("B" & intRow).Text
strName = ThisWorkbook.Sheets("Client_Data").Range("C" & intRow).Text
strEmail = ThisWorkbook.Sheets("Client_Data").Range("D" & intRow).Text
strAttachment = ThisWorkbook.Sheets("Client_Data").Range("E" & intRow).Text
strSignature = ThisWorkbook.Sheets("Client_Data").Range("F" & intRow).Text
strMailBody = Replace(strMailBody, "<Prefix>", strPrefix)
strMailBody = Replace(strMailBody, "<Name>", strName)
strMailBody = Replace(strMailBody, "<Audit>", strAudit)
strMailBody = Replace(strMailBody, "<Signature>", strSignature)
With objEmail
.To = CStr(strEmail)
.Subject = strMailSubject
.Body = strMailBody & Signature
.Attachments.Add strFolder & "\" & strAttachment
.Display
End With
intRow = intRow + 1
Wend
MsgBox "Done"
End Sub
This code currently displays an Outlook Email before I send it out. Everything seems fine, the attachment is also there. But the only issue is that I can't display the Signature. Can anybody review this code and help me out please?