I am unable to add inline images in an email. The mail just show a square having a red cross inside it.

Is there a way to add inline images to email which needs to be sent from SharePoint.


public static void SendMail(tenantContext,)
            Microsoft.SharePoint.Client.Utilities.Utility.SendEmail(tenantContext, new Microsoft.SharePoint.Client.Utilities.EmailProperties()
                From = from,
                To = email.to,
                Subject = "subject",
                Body = "hi <img src='image1.png'>",
  • Are you sending mail from designer? – Atish Dipongkor - MVP Nov 23 '15 at 8:53
  • No. I am using CSOM i.e SharePoint.EmailUtility class – nbi Nov 23 '15 at 9:03
  • when is it showing a square having a red cross inside*? from browser or desktop mail client? or both? – Atish Dipongkor - MVP Nov 23 '15 at 9:15
  • Could you post your code here – Unnie Nov 23 '15 at 9:19
  • @Unnie Updated the question – nbi Nov 23 '15 at 9:30

Looking at your code , the reason why you are getting red cross sqaure is either because the image source url is wrong or the image cannot be retrieved because authentication is not done/user not having permission on site. But in any case loading image from the site in email is not good approach as the images won't be available during offline viewing of email or if the user who reads the email does not have permission on the site hosting the image.

You can alternatively try the below(Not tested with emails):

  1. Convert image into Byte array.
  2. Inline Images with Data URLs : Here you won't specify the url of the image in the src attribute , but you will embed the image in bytes into the html.

| improve this answer | |
  • Unfortunately it didn't work :( – nbi Nov 23 '15 at 13:14
  • :-( What was the output you got? – Unnie Nov 23 '15 at 13:23
  • In mail, images are embedded using a multi-part message specifying a cid, please check: stackoverflow.com/questions/4312687/… – Prakash Nov 23 '15 at 16:13
  • @Prakash-CrowCanyon Sending Attachments are not available in Microsoft.SharePoint.Client.Utilities.Utility.SendEmail – Unnie Nov 23 '15 at 16:16
  • 1
    @Unnie, just as your answer, in multipart message, inline attachment content is part of message itself (Base 64 encoded). Mail clients look at cid in image source and find the corresponding part in message, decode the content, create a temporary file and replace the img source with that file path. – Prakash Nov 23 '15 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.