Hello,
I am sending emails with my code below. So, I created a string as Email body and I am writing everything there.
I have two quick questions regarding that:
First, how can I add a picture from my computer or excel (I can paste the picture to a hidden sheet) to the email body below ?
Second, How can I make bold my some strings such as Address or StartDate in the email?
Thank you very very much in advance
Orhan
Sub outlookMacro()
Dim StartRow As Integer, EndRow As Integer
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body, firstName, site, StartDate, Address As String
Dim Mail_Object, Mail_Single As Variant
Email_Send_From = "email"
Email_Send_To = "email"
Email_Cc = "email"
Email_Bcc = "email"
StartRow = InputBox("enter the first record to printt.")
EndRow = InputBox("enter the last record to print.")
If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, "Advanced Excel Training"
End If
For i = StartRow To EndRow
StartDate = Sheets("Sheet2").Cells(i, 3)
firstName = Sheets("Sheet2").Cells(i, 9)
Address = Sheets("Sheet2").Cells(i, 18)
site = Sheets("Sheet2").Cells(i, 6)
Email_Subject = "Welcome in " & site
Email_Body = There should be a picture _
& vbCrLf & "Dear " & Firstname & vbCrLf & "You will start on" & StartDate (Bold) & Welcome to our company" vbCrLf & "Your working location will be " & Address (Bold)
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.CC = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.Display
.Send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description
Next i
End Sub
Bookmarks