logo
search
VBA & Macro Problems

How to Send Scheduled Birthday Emails with Embedded Images from Excel using VBA

Khadija KhanKhadija Khan Oct 15, 2026 868 views

Question details

The user wants to automate sending customized birthday emails to employees from an Excel list, with unique images embedded directly into the email body rather than added as standard attachments.

How to Send Scheduled Birthday Emails with Embedded Images from Excel
Product
Microsoft Excel / Outlook
Device & OS
not provided
Scenario
Automating personalized birthday greetings with unique inline images for each employee based on data and local image paths stored in an Excel worksheet.
Observed behavior
A macro needs to dynamically generate HTML emails referencing specific local image paths and attach them as inline content IDs (cid) instead of standard attachments.
Before you start

Ensure you have Microsoft Outlook installed and configured on your device, and verify that all image file paths listed in your Excel worksheet are accurate and locally accessible by your system.

Solution 1Recommended

Use VBA and Content-ID (CID) to Embed Images in Outlook Emails

This method uses an Outlook VBA script from Excel to attach an image as an inline resource and reference it in the HTML body using its Content-ID.

When sending emails via Outlook from Excel VBA, standard attachments appear at the bottom or top of the email frame. To embed an image directly into the text body (like a customized birthday card), you must construct an HTML email body and reference the attachment using a unique Content-ID (cid).

1
Prepare the Excel Worksheet Data

Set up your Excel sheet with columns for Employee Name, Birthday, Email Address, Delivery Time, and Image Path (e.g., C:\Images\bday1.jpg). Note the column indexes so your VBA script can reference them accurately.

2
Open the VBA Editor

Press Alt + F11 in Excel to open the Visual Basic for Applications editor. Navigate to Insert > Module to create a new blank module for your code.

3
Enable Outlook Object References

In the VBA Editor, go to Tools > References. Scroll down the list, find 'Microsoft Outlook Object Library', check the box next to it, and click OK. This allows Excel to control Outlook functions.

4
Write the VBA Code using HTMLBody and CID

Create a loop to read each row in your worksheet. For each employee, create an Outlook MailItem. Use the .Attachments.Add method to attach the specific image path. Assign a unique Content-ID for this attachment using the PropertyAccessor method if necessary, or simply match the CID syntax.

5
Construct the HTML Body and Schedule

Set the .HTMLBody property to include your custom greeting and an HTML image tag pointing to the CID. Example: <img src='cid:YourContentID'>. Finally, assign the employee's scheduled time to the .DeferredDeliveryTime property and use .Send to queue the email in Outlook.

Use VBA and Content-ID (CID) to Embed Images in Outlook Emails
Dynamic Content IDs: Ensure the CID referenced in your HTML <img src='cid:...'> string exactly matches the CID assigned to the attached image file in your VBA script, otherwise the image will show up as a broken link.
Automate with WPS Spreadsheets

Use WPS Office to Run Advanced VBA Macros

WPS Office provides robust built-in support for VBA macros, allowing you to run powerful automation scripts such as sending scheduled emails with embedded images. It is highly compatible with Microsoft Excel macro-enabled files.

  1. 1. Download and Install WPS Office: Get the latest version of WPS Office from the official website and ensure you install the edition that includes VBA support.
  2. 2. Open Your Macro-Enabled Workbook: Launch WPS Spreadsheets and open your existing .xlsm file containing the employee birthday data and macro script.
  3. 3. Access the Developer Tools: Navigate to the Developer tab on the ribbon and click on 'Macros' or 'Visual Basic' to view and edit your script.
  4. 4. Run Your Automation: Execute the VBA script directly within WPS Spreadsheets to trigger Outlook and seamlessly queue your automated birthday emails.
Fully compatible with Microsoft Excel formats, including .xls, .xlsx, and .xlsm.Supports advanced VBA programming for cross-application COM automation.Lightweight and fast, ensuring complex macros execute smoothly without lagging.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my embedded image showing up as a blank box or red X in Outlook?

This usually happens if the Content-ID (cid) in your HTML string does not perfectly match the CID assigned to the attached image in the VBA script, or if the local image path referenced in your Excel sheet is incorrect or inaccessible.

Can I use VBA to send emails without using the Outlook application?

Yes, you can use CDO (Collaboration Data Objects) in VBA to send emails directly via an SMTP server without needing the Outlook client. However, embedding inline images with CDO requires carefully structuring the MIME parts of the email message.

How do I schedule an email to be sent at a specific future time using VBA?

When creating the Outlook MailItem object via VBA, you can assign a specific date and time to the .DeferredDeliveryTime property before calling the .Send method. The email will stay in your Outbox until the scheduled time arrives.

Does WPS Office support Excel VBA macros for Outlook automation?

Yes, WPS Office provides excellent VBA compatibility. You can run most standard Excel VBA macros, including scripts that automate and interact with Outlook via COM objects, by enabling the Developer tools in WPS Spreadsheets.