0
다음 VSTO 추가 기능 코드가 있습니다. 그러나 items_ItemAdd()
메서드는 영향을받지 않습니다.VSTO ItemAdd 이벤트가 실행되지 않습니다.
public partial class ThisAddIn
{
Outlook.NameSpace outlookNameSpace;
Outlook.MAPIFolder inbox;
Outlook.Items items;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
outlookNameSpace = this.Application.GetNamespace("MAPI");
Debug.WriteLine("Starting Add-In");
inbox = outlookNameSpace.GetDefaultFolder(
Microsoft.Office.Interop.Outlook.
OlDefaultFolders.olFolderInbox);
items = inbox.Items;
items.ItemAdd +=
new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);
Debug.WriteLine("Started Add-In");
}
void items_ItemAdd(object Item)
{
Debug.WriteLine("New email arrived.");
Outlook.MailItem mail = (Outlook.MailItem)Item;
if (Item != null)
{
if (mail.MessageClass == "IPM.Note")
{
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "example.html");
Debug.WriteLine("Saving to " + path);
mail.SaveAs(path, Outlook.OlSaveAsType.olHTML);
}
}
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
이 예제는 MSDN과 매우 비슷합니다. 아이디어가 있습니까? Visual Studio 2010에서 VSTO Outlook 2007 추가 기능을 사용하여이를 개발하고 있습니다. 디버그 모드에서이 문제를 시도했지만 이벤트가 실행되지 않습니다. Outlook 2010을 내 dev 컴퓨터에 설치했습니다.