【问题标题】:Saving a file automatically from an hyperlink in the body of outlook mail从 Outlook 邮件正文中的超链接自动保存文件
【发布时间】:2014-09-03 23:12:31
【问题描述】:

我正在尝试从 outlookmail 正文中的超链接保存 Word 文档。

m 是邮件;

try
            {
               string s;
               System.Net.WebClient wc = new System.Net.WebClient();
                Word.Hyperlink wlink = null;
                if (m.GetInspector.IsWordMail())
                {
                    Word.Document oDoc = m.GetInspector.WordEditor;
                    Word.Hyperlinks links = oDoc.Hyperlinks;
                    for (int j = 1; j <=links.count(); j++)
                    {
                        object index = (object)j;
                        if (links.get_Item(ref index).Address.Contains("format=msw"))
                        {
                            wlink = links.get_Item(ref index);
                            s = wlink.Address;
                                wc.DownloadFile(s, AppSettings.Default.savefolderpath + filename + " Word.docx");
                                index = null;
                                break;
                        }
                    }
                }
            }

我收到以下错误: 尝试的操作失败。找不到对象。在 Microsoft.Office.Interop.Outlook.FoldersClass.get_Item(对象索引)

【问题讨论】:

  • 有没有其他方法可以使用邮件中的超链接下载文档

标签: c#-4.0 outlook automation


【解决方案1】:

您确定在您的代码的 sn-p 中引发了错误吗?看起来您正在按名称访问一个文件夹,但它不存在:MAPIFolder.Folders("I do not exist")

【讨论】:

    猜你喜欢
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多