We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Migration from msg files (extracted from a pst file) to SharePoint

Hello,

I am working on a migration of msg files (from a pst) that I convert in eml files, then I add them in a SharePoint library, with the code below :

Mapimessage mailMsg = personalStorage.ExtractMessage(msgInfo);

MemoryStream stream = new MemoryStream();

mailMsg.Save(stream);

MailMessage mailMsg = MailMessage.Load(stream, MessageFormat.Msg);

stream.Close();

MemoryStream emlStream = new MemoryStream();

mailMsg.Save(emlStream, MessageFormat.Eml);

byte[] data = emlStream.ToArray();

destFolder.Files.Add(newEMailName, data, false);

emlStream.Close();

The problem is that when an item is added to this library, an item added event handler try to extract the file's attachments. It failed because each SPEmailAttachment has empty filename at this step. However, I can open manually the eml file and its attachments fron the library.

Code in ItemAdded Event Handler :

Stream emailStream = item.File.OpenBinaryStream();

SPEmailMessage emailMsg = new SPEmailMessage(emailStream, enveloppeSender);

SPEmailAttachmentCollection attachments = emailMsg.Attachments;

foreach (SPEmailAttachment attach in attachments)

{

// attach.FileName is null !

}

Please could you help me?

Thanks in advance,

Charline.

please continue at <a href="