积极答复者
请教outlook插件:如何修改outlook中已有的窗体和拦截处理分类事件

问题
答案
-
你好:
欢迎来到MSDN中文论坛。
VSTO没有这样内置事件供你调用,但是你可以换一种方式,使用NewMailEx事件,在接收到邮件之后进行一些处理。参考这篇英文帖子中的示例代码:
Custom Action using a VSTO addin
public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx); } void Application_NewMailEx(string EntryIDCollection) { //more than one new mail arrives string[] entryIDs = EntryIDCollection.Split(','); foreach (string entryID in entryIDs) { if (DialogResult.Yes == MessageBox.Show("Do you want to save your new message?", "You have got a new mail", MessageBoxButtons.YesNo)) { Outlook.NameSpace ns = Application.Session; Outlook.MailItem newmail = ns.GetItemFromID(entryID, missing) as Outlook.MailItem; if (newmail != null) { SaveAttachmentsToDisk(newmail); } } } } public void SaveAttachmentsToDisk(Outlook.MailItem message) { string rootPath = "C:\\Temp"; foreach (Outlook.Attachment attachment in message.Attachments) { string fileName = string.Format("{0}\\{1}", rootPath, attachment.FileName); attachment.SaveAsFile(fileName); } } }
这个实例代码的作用是在接收到一封或者多封邮件之后,将邮件中的附件保存到磁盘上。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 LINZISO 2014年4月25日 5:40
全部回复
-
你好:
欢迎来到MSDN中文论坛。
VSTO没有这样内置事件供你调用,但是你可以换一种方式,使用NewMailEx事件,在接收到邮件之后进行一些处理。参考这篇英文帖子中的示例代码:
Custom Action using a VSTO addin
public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(Application_NewMailEx); } void Application_NewMailEx(string EntryIDCollection) { //more than one new mail arrives string[] entryIDs = EntryIDCollection.Split(','); foreach (string entryID in entryIDs) { if (DialogResult.Yes == MessageBox.Show("Do you want to save your new message?", "You have got a new mail", MessageBoxButtons.YesNo)) { Outlook.NameSpace ns = Application.Session; Outlook.MailItem newmail = ns.GetItemFromID(entryID, missing) as Outlook.MailItem; if (newmail != null) { SaveAttachmentsToDisk(newmail); } } } } public void SaveAttachmentsToDisk(Outlook.MailItem message) { string rootPath = "C:\\Temp"; foreach (Outlook.Attachment attachment in message.Attachments) { string fileName = string.Format("{0}\\{1}", rootPath, attachment.FileName); attachment.SaveAsFile(fileName); } } }
这个实例代码的作用是在接收到一封或者多封邮件之后,将邮件中的附件保存到磁盘上。
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 LINZISO 2014年4月25日 5:40