您好,我正在使用以下代码通过Outlook Addin下载包含约20个以上附件(〜9MB)的电子邮件,并收到以下错误-没有足够的可用内存来运行此程序。退出一个或多个程序,然后重试。该异常作为MailItem.SaveAs方法抛出,以将MSG保存到本地临时路径。我尝试使用可用的kb修复程序来更改注册表设置,但这对这里没有帮助。
if (mailItem.Subject != null)
{
fileName = Path.GetInvalidFileNameChars().Aggregate(mailItem.Subject, (current, c) => current.Replace(c.ToString(), string.Empty));
}
fileName = mailindex + "- " + fileName + ".msg";
var fullPath = CustomUtility.TrimFilePath(location, fileName);
emailItemDetails.MsgFileName = Path.GetFileName(fullPath);
mailItem.SaveAs(fullPath, OlSaveAsType.olMSG);
int attachmentIndex = 1;
foreach (Attachment attachment in mailItem.Attachments)
{
string attachmentName = mailindex + "-" + string.Format("{0:00}", attachmentIndex) + " " + attachment.FileName;
var attachmentPath = CustomUtility.TrimFilePath(location, attachmentName);
attachment.SaveAsFile(attachmentPath);
attachmentIndex++;
}
以下是我在eventvwr中看到的异常。
自定义URI:file:/// C:/ Program Files(x86)/ Common 文件/ Microsoft共享/VSTA/Pipeline.v10.0/PipelineSegments.store 异常:异常读取清单来自 file:/// C:/ Program%20Files%20(x86)/Common%20Files/Microsoft%20Shared/VSTA/Pipeline.v10.0/PipelineSegments.store: 清单可能无效或无法打开文件。
**************异常文本************** System.Deployment.Application.InvalidDeploymentException:异常 阅读清单 file:/// C:/ Program%20Files%20(x86)/Common%20Files/Microsoft%20Shared/VSTA/Pipeline.v10.0/PipelineSegments.store: 清单可能无效或无法打开文件。 -> System.Xml.XmlException:'',十六进制值0x01,是无效的 字符。第1行,位置1。
如有任何建议,请帮助