私たちは、Outlook プラグインの開発者です。デフォルトの [送信] ボタンの代替として機能するボタンを提供します。ボタンによって返信されたすべての MailItem を特定のカテゴリに保存する必要があります。ユーザーが (新しいインスペクターで) メールに返信するとき、メインの MailItem に返信するにはどうすればよいですか?
2 に答える
ユーザーは Explorer または Inspector から返信できます。
エクスプローラーの場合、イベントをトラップExplorer.SelectionChange
し、選択したアイテムにイベント シンクを設定します。イベントをトラップできMailItem.Reply/ReplyAll/Forward
ます。
インスペクタの場合、イベントをトラップし、返された fromプロパティApplication.Inspectors.NewInspector
にイベント シンクを設定します。その後、再び イベントをトラップします。MailItem
Inspector.CurrentItem
MailItem.Reply/ReplyAll/Forward
このアイテムが属する会話を表すConversationオブジェクトを返す MailItem クラスのGetConversationメソッドを使用できます。
アイテムの会話が存在しない場合、GetConversation は Null (Visual Basic では Nothing) を返します。次のシナリオでは、アイテムの会話は存在しません:
- アイテムは保存されていません。アイテムは、プログラム、ユーザー アクション、または自動保存によって保存できます。
- 送信可能なアイテム (メール アイテム、予定アイテム、連絡先アイテムなど) の場合、アイテムは送信されていません。
- Windows レジストリによって会話が無効になっています。
- ストアはスレッド ビューをサポートしていません (たとえば、Outlook は、Microsoft Exchange Server 2010 より前のバージョンの Microsoft Exchange に対して従来のオンライン モードで実行されています)。Store オブジェクトの IsConversationEnabled プロパティを使用して、ストアが会話ビューをサポートしているかどうかを判断します。
会話は、1 つ以上のフォルダーおよびストア内の 1 つ以上のアイテムを表します。会話内のアイテムを削除済みアイテム フォルダーに移動した後、GetChildren、GetRootItems、または GetTable メソッドを使用して会話を列挙すると、そのアイテムは返されるオブジェクトに含まれません。
void DemoConversation()
{
object selectedItem =
Application.ActiveExplorer().Selection[1];
// This example uses only
// MailItem. Other item types such as
// MeetingItem and PostItem can participate
// in the conversation.
if (selectedItem is Outlook.MailItem)
{
// Cast selectedItem to MailItem.
Outlook.MailItem mailItem =
selectedItem as Outlook.MailItem;
// Determine the store of the mail item.
Outlook.Folder folder = mailItem.Parent
as Outlook.Folder;
Outlook.Store store = folder.Store;
if (store.IsConversationEnabled == true)
{
// Obtain a Conversation object.
Outlook.Conversation conv =
mailItem.GetConversation();
// Check for null Conversation.
if (conv != null)
{
// Obtain Table that contains rows
// for each item in the conversation.
Outlook.Table table = conv.GetTable();
Debug.WriteLine("Conversation Items Count: " +
table.GetRowCount().ToString());
Debug.WriteLine("Conversation Items from Table:");
while (!table.EndOfTable)
{
Outlook.Row nextRow = table.GetNextRow();
Debug.WriteLine(nextRow["Subject"]
+ " Modified: "
+ nextRow["LastModificationTime"]);
}
Debug.WriteLine("Conversation Items from Root:");
// Obtain root items and enumerate the conversation.
Outlook.SimpleItems simpleItems
= conv.GetRootItems();
foreach (object item in simpleItems)
{
// In this example, only enumerate MailItem type.
// Other types such as PostItem or MeetingItem
// can appear in the conversation.
if (item is Outlook.MailItem)
{
Outlook.MailItem mail = item
as Outlook.MailItem;
Outlook.Folder inFolder =
mail.Parent as Outlook.Folder;
string msg = mail.Subject
+ " in folder " + inFolder.Name;
Debug.WriteLine(msg);
}
// Call EnumerateConversation
// to access child nodes of root items.
EnumerateConversation(item, conv);
}
}
}
}
}
void EnumerateConversation(object item,
Outlook.Conversation conversation)
{
Outlook.SimpleItems items =
conversation.GetChildren(item);
if (items.Count > 0)
{
foreach (object myItem in items)
{
// In this example, only enumerate MailItem type.
// Other types such as PostItem or MeetingItem
// can appear in the conversation.
if (myItem is Outlook.MailItem)
{
Outlook.MailItem mailItem =
myItem as Outlook.MailItem;
Outlook.Folder inFolder =
mailItem.Parent as Outlook.Folder;
string msg = mailItem.Subject
+ " in folder " + inFolder.Name;
Debug.WriteLine(msg);
}
// Continue recursion.
EnumerateConversation(myItem, conversation);
}
}
}