0

VS 2010 、ドット ネット フレームワーク 2.0 を使用しています。Extensibility->Shared Add-ins for Outlook でプロジェクトを作成しました。

Outlook.MailItem オブジェクトを explorer_SelectionChange() の DataTable に保存し、この Outlook.MailItem オブジェクトを使用して件名と本文を後で操作したいと考えています。

Mailitem のオブジェクトをデータテーブルに保存すると、SYS.ComAddins として保存されます。コードクラス変数は次のとおりです。

private Outlook.MailItem connectingMailItem;
private Outlook.Inspectors inspectors;
private Outlook.Application applicationObject;
private object addInInstance;
private Outlook.Explorer explorer;
DataTable dtMailItem = new DataTable();

OnConnection :

    explorer = this.Application.ActiveExplorer();
    explorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(explorer_SelectionChange);
    dtMailItem.Columns.Add("MailItem",typeOf(Outlook.MailItem));
    tFollowUp = new Timer();
    tFollowUp.Interval = 100000;
    tFollowUp.Tick += new EventHandler(tFollowUp_Tick);

explorer_SelectionChange

void explorer_SelectionChange()
{
    if (connectingMailItem != null && connectingMailItem is Outlook.MailItem)
    {
        Marshal.ReleaseComObject(connectingMailItem);
        // Perform a Garbage Collection
        GC.Collect();
        connectingMailItem = null;
        return;
    }
    foreach (object selectedItem in explorer.Selection)
    {
        connectingMailItem = selectedItem as Outlook.MailItem;
        break;
    }
    if (connectingMailItem != null && connectingMailItem is Outlook.MailItem)
    {                
        dtMailItem.Rows.Add(connectingMailItem);
        dtMailItem.AcceptChanges();
    } 
}

tFollowUp_Tick

 void tFollowUp_Tick(object sender, EventArgs e)
{
    if(dtMailItem.Rows.Count <= 0)
    {
        foreach(DataRow dr in dtMailItem.Rows)
        {
           // Manipulation code for subject and body or remove the Mailitem from Datatable
        }
    }
}

メールアイテムのオブジェクトまたはプロパティを保存して、どのメールアイテムが保存されたかを特定するにはどうすればよいですか

4

1 に答える 1

1

この質問で提案されていることを試して、EntryID を保存し、後で同じ ID を使用して取得することができます。

于 2013-05-09T12:13:04.710 に答える