c# - System.Runtime.InteropServices.COMException (0x80004004):操作中止
问题描述
在我的项目中,我想提取附加在 msg 文件中的附件。它在我对开发项目进行测试时有效,但是一旦我放入服务器,我就会收到此错误“System.Runtime.InteropServices.COMException (0x80004004): Operation aborted”。
下面是我提取 msg 文件的代码。
var outlook = new Microsoft.Office.Interop.Outlook.Application();
MailItem item = (MailItem)outlook.CreateItemFromTemplate(file.fullPath, Type.Missing);
for (int i = 1; i <= item.Attachments.Count; i++)
{
FileInfo fzip = null;
if (Path.GetExtension(item.Attachments[i].FileName).ToLower().EndsWith(".zip"))
{
fzip = new FileInfo(SavePath + item.Attachments[i].FileName);
string attpath = strSavePath + item.Attachments[i].FileName;
item.Attachments[i].SaveAsFile(attpath);
..process zip...
}
错误在第二行。请帮忙...
解决方案
推荐阅读
- python - RegEX:如何在字符串之间排除并匹配重命名字符串
- powershell - Visual Studio Code 中的 Powershell 和 2 因素身份验证
- wordpress - 在内容之前插入 Wordpress 短代码
- angular - 如何在Angular的ts文件中使用自定义模式弹出窗口而不是使用确认对话框
- php - WooCommerce:如何在两个客户之间共享订单?
- c# - 如何使用 Visual Studio 的“即时窗口”调用外部汇编方法?
- git - Git 接受来自 Pull Request 的所有更改
- html - 如何在 md-tooltip 中编译/添加 HTML
- python - 循环遍历 2 个 Pandas 数据帧并将行值传递给计算距离的函数
- php - 如何在 php 中创建动态 url 和类似 wordpress 的内容?