Copy email to sharepoint with metadata solution
-
02-10-2020 - |
Frage
The usual way is to enable a library/list to receive emails but will this handle metadata?
There are several tools available to copy emails from Outlook to SharePoint with tagging but if I wanted to build a my own custom solution what would be involved?
Lösung
The most important metadata can you access via the Headers
property of the SPEmailMessage
type (the incoming mail) like:
foreach (SPEmailHeader header in emailMessage.Headers)
{
Trace.TraceInformation("EmailReceived emailMessage header {0}, {1}", header.Name, header.Value);
}
Unfortunately, the SharePoint object model does not include more advanced functionality out of the box.
If you need to manipulate the mail metadata, you should utilize some kind of 3rd party mime reader, as the one included in this post.
Based on this classes, I've created a SharePoint solution that can handle the metadata included in incoming mail messages. The first step was to convert the SPEmailMessage
instance into a MailMessage
object (System.Net.Mail
namespace). That can be achieved via the streams behind these objects.