在使用C#调用Outlook Addin中的SaveAs之前,将MailItem设置为已发送 [英] Set a MailItem as sent before calling SaveAs in Outlook Addin with C#

查看:214
本文介绍了在使用C#调用Outlook Addin中的SaveAs之前,将MailItem设置为已发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Outlook 2010加载项,以将其与某些商业软件集成在一起,并捕获了ItemSend事件.我检查它是否是MailItem,是否调用SaveAs函数将其另存为.msg到文件系统(在用户的temp文件夹中).

I am building an Outlook 2010 addin to integrate it with some business software and have trapped the ItemSend Event. I check if it is a MailItem and if it is I call the SaveAs function to save it as a .msg to the file system (in the users temp folder).

void Application_ItemSend(object Item, ref bool Cancel)
{
    if(Item is Outlook.MailItem)
    {
        Outlook.MailItem mailitem = (Outlook.MailItem)Item;
        string filename = "somefilename.msg";
        string path = System.IO.Path.GetTempPath();
        string fullPathName = path+filename;
        mailitem.SaveAs(fullPathName, Outlook.OlSaveAsType.olMSG);
    }
}

我继续阅读文件内容,然后使用Web服务将文件发送到服务器.一切正常.

I go on to read the file contents and send the file to the server using webservices. It all works fine.

我遇到的问题是,如果我打开它保存的文件,然后Outlook将其打开,因为仍在编写邮件,用户可以非常容易地再次单击发送"按钮.

The issue I have is if I go and open the file that it saves, then Outlook opens it as a message still being composed and the user could very easily click the Send button again.

是否有一种方法可以标记该项目在保存之前已发送,因此在打开后便以可读电子邮件而不是内置电子邮件的形式打开了?

Is there a way to flag that the item has been sent before it gets saved so when opened after the fact it opens as a readable email rather than an in-composition email?

推荐答案

看看这篇文章(以及该页面上的最后一个答案),这可能会对您有所帮助.

Take a look at this post (and additionally at the last answer on that page), this might help you.

(使用 ItemAdd 事件)

这篇关于在使用C#调用Outlook Addin中的SaveAs之前,将MailItem设置为已发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆