Hello Everyone:
I wrote the code below and it works great, however I need to add my signature to the email which contains some HTML as well. How can I add it? Also, let me know if my code could be improved. Here is my code:
I wrote the code below and it works great, however I need to add my signature to the email which contains some HTML as well. How can I add it? Also, let me know if my code could be improved. Here is my code:
VBA Code:
Sub SendEmailAttachment()
Dim Email As String
Dim subj As String
Dim message As String
Dim filename As String
Dim outlookapp As Object
Dim outlookmailitem As Object
Dim myAttachments As Object
Dim path As String
Dim lastrow As Integer
Dim attachment As String
Dim attachment2 As String
Dim x As Integer
x = 2
Do While Sheet1.Cells(x, 1) <> ""
Set outlookapp = CreateObject("Outlook.Application")
Set outlookmailitem = outlookapp.CreateItem(0)
Set myAttachments = outlookmailitem.Attachments
path = "C:\Statements\"
Email = Sheet1.Cells(x, 1)
subj = Sheet1.Cells(x, 2)
filename = Sheet1.Cells(x, 3)
attachment = path + filename
attachment2 = path + "CEO Letter to Employees.Pdf"
outlookmailitem.To = Email
outlookmailitem.cc = ""
outlookmailitem.bcc = ""
outlookmailitem.Subject = subj
outlookmailitem.body = "Please find your statement attached" & vbCrLf & "Best Regards"
myAttachments.Add (attachment)
myAttachments.Add (attachment2)
outlookmailitem.Display
outlookmailitem.send
lastrow = lastrow + 1
Email = ""
x = x + 1
Loop
Set outlookapp = Nothing
Set outlookmailitem = Nothing
End Sub