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


[TABLE="class: grid, width: 800, align: left"]
<tbody>[TR]
[TD]Name[/TD]
[TD].To Email[/TD]
[TD].CC Email[/TD]
[TD]Image to Insert into Email Body[/TD]
[TD]Attachment[/TD]
[/TR]
[TR]
[TD]Mr. Abraham[/TD]
[TD]sam.abraham@email.com[/TD]
[TD]the.boss@email.com[/TD]
[TD]D:\Pictures\DR1.bmp[/TD]
[TD]D:\Daily Reports\DR#1\DR1 - 06.13.2018.xlsx[/TD]
[/TR]
[TR]
[TD]Mr. Paul[/TD]
[TD]john.paul@email.com[/TD]
[TD]the.boss@email.com[/TD]
[TD]D:\Pictures\DR2.bmp[/TD]
[TD]D:\Daily Reports\DR#1\DR1 - 06.13.2018.xlsx[/TD]
[/TR]
</tbody>[/TABLE]









Thank you in advance!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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