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
[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!
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!