Web Outlook email images are not displaying on email Body.
- Use the content_ID for the embedded images, to view the image in the email body in the OWA Outlook application.
- Use the below snippet of code in the InvokeCode activity .
Code:
try
{
var outlookApp = new Microsoft.Office.Interop.Outlook.Application();
var mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
// Set email properties
mailItem.Subject = "HelloImg";
mailItem.Body = "FYI";
mailItem.To = emailTo;
string imagePath = @"C:\Users\Documents\ShareX\Screenshots\2023-06\import.png";
// Embed the local image
var attachment = mailItem.Attachments.Add(imagePath, Microsoft.Office.Interop.Outlook.OlAttachmentType.olEmbeddeditem, null, "Image");
var imageCid = "image001"; // Content ID for the embedded image
attachment.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E", imageCid);
// Display the image in the email body
mailItem.HTMLBody = $"
// Send the email
mailItem.Send();
}
catch (System.Exception ex)
{
Console.WriteLine("Error sending email: " + ex.Message);
}