【问题标题】:VSTO Outlook send MeetingItem from DraftsVSTO Outlook 从草稿发送 MeetingItem
【发布时间】:2017-07-01 01:00:00
【问题描述】:

我正在开发我的插件并面临下一个问题:看起来 MeetingItems 的工作方式与 MailItems 不同。

我需要做什么:

  1. 在发送之前将 MeetingItem 保存到草稿中。
  2. 添加附件。
  3. 发送。

1 将 MeetingItem 保存到草稿:

(Item as MeetingItem).GetAssociatedAppointment(false).GetInspector.Close(OlInspectorClose.olSave);

有效。

2。添加附件。

Attaches = (Item as MeetingItem).GetAssociatedAppointment(false).Attachments;
Attaches.Add(...).

它也有效。

3.发送邮件。

试一试:

(Item as MeetingItem).Send();  << it doesn't work.

Try2:

AppointmentItem appItem = Item.GetAssociatedAppointment(false);
appItem.Send(); << It works. But MeetingItem is still in drafts folder (???)
Item.Delete(); << Moved to deleted folder, and can't delete permanently.

它认为在第三步我做错了什么。你知道如何正确发送 MeetingItem 吗?

更新:

当我发送 MeetingItem 时,Outlook 会询问我“你想现在更新你自己的日历吗”。如果我按是,则根本不会调用 Application_ItemSend 回调,因此我无法添加附件。我很困惑那里发生了什么。

Outlook message box

更新 2:

看来,当我添加附件已经收到的消息时,我应该使用

(Item as MailItem).Attachments.Add(...)

但是当我发送邮件时,我应该使用

(Item as MailItem).GetAssociatedAppointment(false).Attachments.Add(...)

令人困惑。

【问题讨论】:

    标签: c# outlook vsto outlook-addin


    【解决方案1】:

    会议项目不是为用户保存或操作而设计的 - 它们是在发送约会时自动创建的。您确实需要将附件添加到约会本身。如果您仍然只希望它们仅用于会议项目,您可以处理 Application.ItemSend 事件并将附件添加到传递给您的事件处理程序的 MeetingItem 对象。

    【讨论】:

      【解决方案2】:

      无需使用 MeetingItem 类的GetAssociatedAppointment 方法。您可以通过调用 MeetingItem 类的GetInspector 属性直接获取 Inspector 类的实例。相同的规则适用于您需要调用的其他属性和方法 - SendAttachments 等。

      以编程方式创建会议请求时,首先创建一个AppointmentItem 对象而不是MeetingItem 对象。要指示约会是会议,请将 AppointmentItem 对象的 MeetingStatus 属性设置为 olMeeting 。要发送会议请求,请将Send 方法应用于该AppointmentItem 对象。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-09-03
        • 1970-01-01
        • 1970-01-01
        • 2021-08-19
        • 1970-01-01
        • 1970-01-01
        • 2022-10-12
        相关资源
        最近更新 更多