1

在 Outlook 中,我可以设置新邮件的主题(在撰写新邮件时),但我想添加文本。所以我需要先获取主题,然后设置它。

Outlook.Application application = Globals.ThisAddIn.Application;
Outlook.Inspector inspector = application.ActiveInspector();
Outlook.MailItem myMailItem = (Outlook.MailItem)inspector.CurrentItem;

if (myMailItem != null && !string.IsNullOrEmpty(myMailItem.Subject))
{
    myMailItem.Subject = "Following up on your order";
}

此代码适用于回复,但不适用于新邮件,因为在这种情况下,myMailItem 为空。

4

1 回答 1

1

这就是我一直在寻找的:

if (thisMailItem != null)
{
    thisMailItem.Save();

    if (thisMailItem.EntryID != null)
    {
        thisMailItem.Subject = "prepended text: " + thisMailItem.Subject;
        thisMailItem.Send();
    }
}

在保存邮件项目之前,主题为空,因为它已发送或作为草稿。我们可以以编程方式保存它,然后获取主题。

另一个注意事项:如果保存时主题为空白,它仍将显示为空。

于 2010-06-16T20:47:00.327 回答