0

我正在开发 Outlook 2013 插件。

我的场景:

  1. 从 Outlook 邮件窗口获取所选电子邮件的电子邮件数据

  2. 创建新的电子邮件项目

  3. 使用所选电子邮件中的电子邮件数据更新新电子邮件项目

  4. 发送电子邮件

如果我选择不带附件的电子邮件并进行操作,那么它工作正常。

但是,如果选定的电子邮件有附件,那么我会收到错误成员未找到。(来自 HRESULT 的异常:0x80020003 (DISP_E_MEMBERNOTFOUND))

要获取选定的电子邮件数据,我使用以下代码

MailItem mailItem = null;
Attachments mtAttachments = null;

Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();

if (explorer != null && explorer.Selection != null && explorer.Selection.Count > 0)
            {
                object item = explorer.Selection[1];
                if (item is MailItem)
                {
                    mailItem = item as MailItem;
                    subject = mailItem.Subject;
                    body = mailItem.HTMLBody;
                    mtAttachments = mailItem.Attachments;
                }
            }    

要发送带有附件的新电子邮件,我正在使用以下代码。

在此处输入图像描述

而且我正在低于 Error 。

在此处输入图像描述

谁能帮帮我吗。?

4

1 回答 1

1

Attachments.Add 只能采用带有文件名的字符串或另一个 Outlook 项目(MailItem、XContactItem 等)。它不将 Attachments 对象的实例作为参数。

如果要将附件从一封邮件复制到另一封邮件,请先将其另存为文件,然后将附件文件名作为参数传递。

于 2014-11-11T16:30:36.207 回答