You can insert a picture directly into the body of an Outlook email from Excel VBA using the MailItem's HTMLBody property plus an attachment that is marked as inline — the picture shows up in the message itself, not as a paperclip attachment. The shortest working recipe is: create the mail item, add the image with Attachments.Add, set .PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F", "myImage") to give it a content ID, then build an <img src="cid:myImage"> tag and assign it to .HTMLBody. The recipient sees the picture inline as soon as they open the message.
This is useful for standardised messages: a logo in a signature, a chart snapshot, a product photo, a scanned document preview. Because everything runs from Excel, you can loop over rows in a worksheet and send a different picture, or a different message, to each recipient.
What You'll Need
- Microsoft Excel and Microsoft Outlook installed on the same Windows PC (the full desktop Outlook application, not Outlook on the web).
- Macro security settings that allow you to run your own code — either a macro-enabled workbook (.xlsm) with macros enabled, or the Trust Center set to allow VBA in this location.
- One or more image files saved on disk or on a network share the Excel user can read. PNG or JPG works best; very large files bloat the message.
- Basic familiarity with the VBA editor: press
Alt+F11to open it, andCtrl+Gfor the Immediate window to test single lines. - Outlook already configured with a working account, since VBA drives the running Outlook session.
Step-by-Step
- Confirm Outlook is running or will start. The code uses
CreateObject("Outlook.Application"), which connects to the open Outlook instance or launches one. If Outlook is closed and the profile is fine, this still works; if Outlook is showing a dialog, the code will hang, so close any prompts first. - Open the VBA editor in Excel with
Alt+F11. In the Project Explorer, right-click your workbook, choose Insert > Module. Menu wording can differ slightly by version and region, but the Insert > Module command has been stable for years. - Add a reference to the Outlook object library (optional but helpful): Tools > References and tick Microsoft Outlook Object Library. With early binding you get IntelliSense and clearer errors. If you skip this, late binding via
CreateObjectandObjectvariables still works and avoids version-mismatch errors when another PC has a different Outlook version. - Write the core procedure. A minimal version looks like this:
Sub EmailWithPicture()
Dim olApp As Object, mail As Object
Dim picPath As String, cid As String
picPath = "C:\Pictures\logo.png"
cid = "logoImage"
Set olApp = CreateObject("Outlook.Application")
Set mail = olApp.CreateItem(0) ' 0 = MailItem
With mail
.To = "someone@example.com"
.Subject = "Your report"
.Attachments.Add picPath
' mark the attachment as inline and give it a Content-ID
.Attachments(1).PropertyAccessor.SetProperty _
"http://schemas.microsoft.com/mapi/proptag/0x3712001F", cid
.HTMLBody = "<p>Hello,</p>" & _
"<p><img src=\"cid:" & cid & "\"></p>" & _
"<p>Regards</p>"
.Display ' or .Send
End With
End Sub
- Set the picture path correctly. Use an absolute path. Relative paths depend on Excel's current directory, which changes depending on how the workbook was opened, so a path like
"logo.png"may work one day and fail the next. - Keep the cid value unique per message. If you send many messages in a loop, use something like
"pic" & ifor each image so two attachments do not share an ID. - Test with .Display first, never .Send. Run the macro, look at the message window, and check the image renders. Only when you are satisfied should you change
.Displayto.Send— and even then, test with your own address. - Build the HTML string carefully. VBA string literals need doubled quotes. Concatenating with
&on separate lines keeps it readable. If you need more than one picture, repeat the attachment, cid and img-tag block for each. - Preserve an existing signature if you want one. Assigning
.HTMLBodyreplaces the signature. Workaround: call.Displayfirst, read.HTMLBodyinto a variable, then append your image HTML to it. This is a dealbreaker for many people, so plan for it early.
Common Mistakes
- Using cid without setting the Content-ID property. The image tag points to a cid the attachment does not have, so the recipient sees a broken picture icon.
- Forgetting that the string is HTML. Plain-text newlines inside the body do nothing; use
<p>,<br>or<div>tags. - Attaching from a path the user cannot read — a mapped drive that is not available, or a OneDrive placeholder not yet downloaded. The macro errors at
Attachments.Add. - Overwriting the signature by setting
.HTMLBodywholesale after display. - Relying on images to be visible when Outlook blocks them. Many recipients have automatic image download turned off; the picture shows a placeholder until they choose to download images.
Tips
- Embed images at a sensible size before attaching. Rescale large photos in an editor; enormous files slow sending and may exceed the mailbox limit.
- Use PNG for logos and screenshots, JPG for photos.
- Add a plain-text alternative by also setting
.Body— Outlook uses it when HTML is not shown. - Store the picture path in a cell or named range so non-technical users can change it without editing code.
- Wrap your procedure with error handling and always
Set mail = Nothingat the end.
Troubleshooting
If the image shows as a broken icon or an empty box, check the Content-ID property and the src="cid:..." value match exactly. They are case-sensitive in some clients.
If the macro reports that an object is missing or the automation errors immediately, make sure Outlook is running and not blocked by a security dialog such as an "Allow access" prompt.
If the body appears as plain HTML source text, you assigned to .Body instead of .HTMLBody. Fix the property name.
If Excel throws a compile error about the Outlook library, remove the reference and switch to late binding (declare everything as Object).
If the macro does nothing when run, check that macros are enabled and that the procedure is in a standard module, not a worksheet module or ThisWorkbook.
If sending fails or Outlook asks for permission, check that the account can send and that no protected view or add-in is intercepting the message.
Frequently Asked Questions
Can I insert a picture without attaching it at all?
No — Outlook has no separate "inline image" API from VBA. The image must be an attachment with a Content-ID and referenced in HTML, which is what makes it display inline rather than as a file.
Why does the picture show as a paperclip attachment instead of inline?
The Content-ID property was not set, or the HTML references a cid that does not match. Both steps are required.
Will the image show for recipients who block images?
It may not display until they choose to download images. The attachment is still in the message, so they can open it.
Does this work on Mac Excel?
VBA for Outlook differs on Mac and is much more limited; the reliable approach is Windows Excel with desktop Outlook. Check your version's documentation before relying on it.
How do I embed a picture from a worksheet cell or chart?
Export the chart or range as an image first (for charts, Chart.Export to a PNG path), then attach that file as shown above. There is no direct VBA method to insert a live Excel object into the Outlook body.
Can I send different images to many people in one run?
Yes. Put the file paths in a column, loop over the rows, create a new mail item each iteration, and use a unique cid per message.