共用方式為


將自訂動作新增為郵件項目的回應

此範例示範如何使用 Actions 集合Add () 方法,將自定義動作新增為電子郵件項目的回應。

範例

注意事項

下列程式代碼範例是 Microsoft Office Outlook 2007 程式設計應用程式的摘錄。

您可以透過程式設計方式建立自定義動作,以出現在電子郵件回應中 [訊息] 引標籤上 [動作] 群組的功能區上。 在下列程式代碼範例中,ReplyWithVoiceMail 會建立名為「使用語音信箱回復」的自定義動作,並將其新增至Inspector命令行。 ReplyWithVoiceMail 會先取得_MailItem對象,然後呼叫與 MailItem 相關聯之 Actions 集合的 Add 方法來建立 Action 物件。 然後,它會將 Action 物件的 Name 屬性設定為 “Reply with Voice Mail”。 同時也會設定 ReplyStyleResponseStyleCopyLikeMessageClass 屬性。 最後, 會儲存MailItem

注意事項

您也可以使用 Outlook Forms Designer,在設計時間新增自定義動作。

If you use Visual Studio to test this code example, you must first add a reference to the Microsoft Outlook 15.0 Object Library component and specify the Outlook variable when you import the Microsoft.Office.Interop.Outlook namespace. The using statement must not occur directly before the functions in the code example but must be added before the public Class declaration. The following line of code shows how to do the import and assignment in C#.

using Outlook = Microsoft.Office.Interop.Outlook;

    private void ReplyWithVoiceMail()
    {
        Outlook.MailItem mail = (Outlook.MailItem)Application.ActiveInspector().CurrentItem;
        Outlook.Action action = mail.Actions.Add();
        action.Name = “Reply with Voice Mail”;
        action.ReplyStyle = Outlook.OlActionReplyStyle.olUserPreference;
        action.ResponseStyle = Outlook.OlActionResponseStyle.olOpen;
        action.CopyLike = Outlook.OlActionCopyLike.olReply;
        action.MessageClass = “IPM.Post.Voice Message”;
        mail.Save();
    }

另請參閱