Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to add JPG file to oft template at specific location in on email body

$
0
0

I'm trying to distribute emails via using outlook oft template. On the oft template at specific location i want to attached jpg file which i have created from excel range.

Dim OutApp As Object
Dim OutMail As Object
Dim str_jpeg_file as String
str_jpeg_file  = "B:\temp\test.jpg"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate(ThisWorkbook.Path & "\Test.oft")
With OutMail
    .To = "test@abcd.com"
    .CC = ""
    .BCC = ""
    .Subject = "Test mail"
    .SentOnBehalfOfName = "zyz@abcd"
    .Attachments.Add str_jpeg_file, 1, 0
    .HTMLBody = Replace(.HTMLBody, "##IMAGE_PLACEHOLDER##", "<img src=""cid:test.jpg""height=520 width=750>")
    '.Send
    .display
End With

Edit:

jpg file path updated i.e. str_jpeg_file


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>