本文介绍了使用EWS API以MSG格式保存电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在研究一种解决方案,使用EWS API从交换中提取电子邮件,然后在线上传到SharePoint。下面是文件创建的示例代码,在上传到sharepoint之前。



string mSubject = mItem.Subject;

string targetFileURL = targetFolderUrl +/+ Regex.Replace(mSubject,@[^ \\\\。@ - ],,RegexOptions.None,TimeSpan.FromSeconds(1.5));



//将URL限制为150个字符

if(targetFileURL.Length> 150)

targetFileURL = targetFileURL.Substring(0,150)+ .eml;

else

targetFileURL = targetFileURL +" .eml";



mItem。加载(新的PropertySet(ItemSchema.MimeContent));

MimeContent mc = mItem.MimeContent;

FileCreationInformation newFile = new FileCreationInformation();

newFile.Content = mc.Content;

newFile.Url = targetFileURL;

newFile.Overwrite = true;





它非常适合.EML格式,但是当我尝试以.MSG格式保存文件时,它会抛出错误。



有关如何以正确的MSG格式保存文件的任何建议?非常感谢快速回复。



谢谢

Hi,

I am working on a solution to to extract emails from exchange using EWS APIs and then upload to SharePoint online . Below is the sample code for file creation, and before upload to sharepoint.

string mSubject = mItem.Subject;
string targetFileURL = targetFolderUrl + "/" + Regex.Replace(mSubject, @"[^\w\.@-]", "", RegexOptions.None, TimeSpan.FromSeconds(1.5));

//limit URL to 150 characters
if (targetFileURL.Length > 150)
targetFileURL = targetFileURL.Substring(0, 150) +".eml";
else
targetFileURL = targetFileURL + ".eml";

mItem.Load(new PropertySet(ItemSchema.MimeContent));
MimeContent mc = mItem.MimeContent;
FileCreationInformation newFile = new FileCreationInformation();
newFile.Content = mc.Content;
newFile.Url = targetFileURL;
newFile.Overwrite = true;


It works perfectly well for .EML format but when I try to save the file in .MSG format it throws error.

Any suggestions on how to save the file in proper MSG format? Will greatly appreciate quick responses.

Thanks

推荐答案


这篇关于使用EWS API以MSG格式保存电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 12:36