Help with inserting image into email body using .HTMLBody

soulslinger

New Member
Joined
Jun 3, 2018
Messages
1
I have been held up by a simple glitch in my email loop code. I can't seem to get the correct code to insert a image into the body using .HTMLBody. I am using a loop to grab email addresses (both .To and .CC), salutations, attachments and the image that I would like inserted into the body of the email instead of attached. The table below the code is the exact same I have in my WorkBook.

The images are somthing like "D:\Pictures\DR1.bmp", "D:\Pictures\DR2.bmp", "D:\Pictures\DR3.bmp", etc.

I have marked the line where I would like to use the Cell(i, 4).Value method, continuing my use of the loop elsewhere. I have been having trouble with the picture appearing in my messages as well, it might just be due to the code mistake. If I attach one image at a time and send an email one by one then it works.

Code is below. ******** is where I need the HTML help

Code:
Sub SendMultitudesofEmails()
 
On Error Resume Next
 
Dim o As Outlook.Application
Set o = New Outlook.Application
Dim omail As Outlook.MailItem
Dim SigString As String
Dim Signature As String
Dim FileExtStr As String
 
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
 
SigString = Environ("appdata") & _
"\Microsoft\Signatures\New.htm"
If Dir(SigString) <> "" Then
Signature = Boiler(SigString)
Else
Signature = ""
End If
 
On Error Resume Next
 
Dim I As Long
For I = 2 to Range("A100").End(xlUp).Row
Set omail = o.CreateItem(olMailItem)
 
With omail
 .To = Cells(I, 2).Value
 .CC = Cells(I, 3).Value
 .Subject = "Daily Report " & Format(Now, "mm/dd/yyyy")
 .HTMLBody = "Dear " & Cells(I, 1).Value & "," & _
" br" & _
" br" & _
"Please see chart below" &_
" br" & _
"Text Text Text TEST TEST" & _
" br" & _
" br" & _

******* html Cells(i, 4).Value /html & _********


" br" & _
" br" & _
 Signature
.Attachments.Add Cell(I, 5).Value
 
.Display
End With
 
Next
End Sub

Function Boiler(ByVal sFile As String) As String
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
Boiler - ts.ReadAll
Ts.Close
End Function


Name.To Email.CC EmailImage to Insert into Email BodyAttachment
Mr. Abrahamsam.abraham@email.comthe.boss@email.comD:\Pictures\DR1.bmpD:\Daily Reports\DR#1\DR1 - 06.13.2018.xlsx
Mr. Pauljohn.paul@email.comthe.boss@email.comD:\Pictures\DR2.bmpD:\Daily Reports\DR#1\DR1 - 06.13.2018.xlsx

<tbody>
</tbody>









Thank you in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top