Help needed to insert the Image on Body of the mail

gvreddyhr

New Member
Joined
May 5, 2010
Messages
26
Hi, </SPAN>

I have the code which generates email through out look with customized subject and body of the letter, is it possible to insert the image(JPEG or any format) with text (not as an attachment) in body of the email, can you please suggest me with coding how to do it.</SPAN>
PHP:
If FileName <> "" Then
        RDB_Mail_PDF_Outlook FileName, "ron@debruin.nl", "This is the subject", _
                             "This is the body of mail where i want to insert image" _
                           & vbNewLine & vbNewLine & "Regards Ron de bruin", False

Kindly help me with the coding for the above, thanks in advance</SPAN>

Regards,</SPAN>
GV Reddy</SPAN>
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Never tried this before--interesting idea, though. There might be a way to actually embed the image in your email, but it looks like it would be simpler to build your email in HTML format and link your image into your website so that it will be downloaded when opened. Not sure if that's an option for you, though.

Maybe this site will help a little: Sending Email Using Outlook through Excel VBA Macro

Good Luck.
 
Upvote 0
Ron has posted a ton of work on this sort of thing. Read through it...you'll find something that you could use. His work has helped me with a lot of my needs. Ron's Excel Tips
 
Upvote 0
Hi All,

Thank you so much for so quick in response, with the help of below code I can generate HTML with the selected range, but I don’t know why inserted images and background color of the excel range is not converting, can you please help me with the below.

PHP:
Sub Mail_Selection_Range_Outlook_Body()' Don't forget to copy the function RangetoHTML in the module.' Working in Office 2000-2010    Dim rng As Range    Dim OutApp As Object    Dim OutMail As Object
    Set rng = Nothing    On Error Resume Next    'Only the visible cells in the selection    Set rng = Sheets("Sheet1").Range("A1:k10").SpecialCells(xlCellTypeVisible)    'You can also use a range if you want    'Set rng = Sheets("YourSheet").Range("D4:D12").SpecialCells(xlCellTypeVisible)    On Error GoTo 0
    If rng Is Nothing Then        MsgBox "The selection is not a range or the sheet is protected" & _               vbNewLine & "please correct and try again.", vbOKOnly        Exit Sub    End If
    With Application        .EnableEvents = False        .ScreenUpdating = False    End With
    Set OutApp = CreateObject("Outlook.Application")    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next    With OutMail        .To = "ron@debruin.nl"        .CC = ""        .BCC = ""        .Subject = "This is the Subject line"        .HTMLBody = RangetoHTML(rng)        .Display   'or use .Display    End With    On Error GoTo 0
    With Application        .EnableEvents = True        .ScreenUpdating = True    End With
    Set OutMail = Nothing    Set OutApp = NothingEnd SubFunction RangetoHTML(rng As Range)' Changed by Ron de Bruin 28-Oct-2006' Working in Office 2000-2010    Dim fso As Object    Dim ts As Object    Dim TempFile As String    Dim TempWB As Workbook     TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"     'Copy the range and create a new workbook to past the data in    rng.Copy    Set TempWB = Workbooks.Add(1)    With TempWB.Sheets(1)        .Cells(1).PasteSpecial Paste:=8        .Cells(1).PasteSpecial xlPasteValues, , False, False        .Cells(1).PasteSpecial xlPasteFormats, , False, False        .Cells(1).Select        Application.CutCopyMode = False        On Error Resume Next        .DrawingObjects.Visible = True        .DrawingObjects.Delete        On Error GoTo 0    End With     'Publish the sheet to a htm file    With TempWB.PublishObjects.Add( _         SourceType:=xlSourceRange, _         Filename:=TempFile, _         Sheet:=TempWB.Sheets(1).Name, _         Source:=TempWB.Sheets(1).UsedRange.Address, _         HtmlType:=xlHtmlStatic)        .Publish (True)    End With     'Read all data from the htm file into RangetoHTML    Set fso = CreateObject("Scripting.FileSystemObject")    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)    RangetoHTML = ts.ReadAll    ts.Close    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _                          "align=left x:publishsource=")     'Close TempWB    TempWB.Close savechanges:=False     'Delete the htm file we used in this function    Kill TempFile     Set ts = Nothing    Set fso = Nothing    Set TempWB = NothingEnd Function

Thank you so much

Regards,
GV Reddy
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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