I have a Sharepoint list with incoming email enabled, and an email event receiver to create items out of incoming emails. Once an email is received, it sends an email back to the sender with the contents as a confirmation.

You can send an attachment and the receiver will add the attachment to the list item, but most users paste screenshots into emails instead of attaching saved images (easier).

Is there a way to parse these pasted images and add them to the list item as an attachment?

  • Aren't they just embedded as <img /> tags? Aug 2, 2012 at 18:20
  • Yeah but the src is different, eg: <img width="277" height="588" id="Picture_x0020_1" src="cid:[email protected]" alt="Description: cid:[email protected]">
    – cbrad
    Aug 2, 2012 at 18:23

1 Answer 1


This is probably a good place to start:


Once you can decode the image (look at the example return data here: https://stackoverflow.com/questions/4332400/python-parsing-emails-with-embedded-images) then it's a matter of simply adding the image as an attachment.

One of the big issues you're going to run into is making this work with email from all email clients, as different clients use different formatting.

As far as uploading it as an attachment to the list, see this post:


And here's the code snippet:

foreach (FileInfo attachment in attachments)
    FileStream fs = new FileStream(attachment.FullName, FileMode.Open, FileAccess.Read);

    byte[] ImageData = new byte[fs.Length];
    fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));

    item.Attachments.Add(attachment.Name, ImageData); 
  • Cheers, should have checked there first, more of a general outlook thing. I'm not too concerned about other email clients as it's an internal site and we only use outlook here. I may have to modify it for the outlook web app depending if it formats things differently.
    – cbrad
    Aug 2, 2012 at 18:28
  • Asked a more specific question, posted here: stackoverflow.com/questions/11784013/…
    – cbrad
    Aug 2, 2012 at 19:00
  • Personally, I would break off the SharePoint portions of that other question. You might get barked at for that. SO is a good place to ask about email parsing. This is a good place to ask about SharePoint. I'm going to edit my answer here to include a code sample to upload an attachment to a list item. Aug 2, 2012 at 19:15
  • Still having problems with this... Not sure how to go about it.
    – cbrad
    Aug 14, 2012 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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