Hi,
1. My attempt to include my default Outlook signature with email generated from Excel is not working. How do I modify this existing code, that does everything else I need, to add the signature?
2. How do I also modify this existing code, that does everything else I need, to set Direct Replies To, to exclude sender. Or to include only those in To, CC, BCC fields - without actually relisting their e-addresses by hardcoding them, but instead for VBA to include them by whomever happened to be in the sent email in those fields?
1. My attempt to include my default Outlook signature with email generated from Excel is not working. How do I modify this existing code, that does everything else I need, to add the signature?
2. How do I also modify this existing code, that does everything else I need, to set Direct Replies To, to exclude sender. Or to include only those in To, CC, BCC fields - without actually relisting their e-addresses by hardcoding them, but instead for VBA to include them by whomever happened to be in the sent email in those fields?
VBA Code:
Sub email() 'attaches active workbook to a generated email
Dim EmailApp As Outlook.Application
Dim Source As String
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
'
Signature = EmailItem.HTMLBody
'
EmailItem.To = "John@abc.com”
EmailItem.CC = "Jane@abc.com"
EmailItem.BCC = ""
EmailItem.Subject = ActiveWorkbook.Name
EmailItem.HTMLBody = "Hello,<br><br>" & "There are NumOfRows, ZZZZZ of them.<br><br>" & _
"Please...<br><br>" & _
"ABC.<br><br>" & "Thanks." & Signature
'replacing strings
Dim X As Integer
X = Range("a2").End(xlDown).Row - 1
EmailItem.HTMLBody = Replace(EmailItem.HTMLBody, "NumOfRows", X)
'
Dim Y As Integer
'Y = WorksheetFunction.CountIf(Range("a2").End(xlDown).Value, >10)
Y = Application.WorksheetFunction.CountIf(Range("A:A"), ">10")
EmailItem.HTMLBody = Replace(EmailItem.HTMLBody, "ZZZZZ", Y)
'
Source = ActiveWorkbook.FullName
EmailItem.Attachments.Add Source
EmailItem.Display
'EmailItem.Send
End Sub