Outlook メール作成時にBCCで固定の宛先を追加する

  • デル株式会社
  • お疲れ様。

    最近、外出先からメールを返信する事が多くなってきて、
    会社に戻った時に、何を返信したか忘れちゃう時があるんですよね。

    んで、Outlookでメール作成時に自動でBCCを入れてくれる機能が無いもんかと探していたら、
    結局、アドインで追加するしか無さそうだったんで作った。

    MSのチュートリアル見ながら作ったけど簡単だった。
    また、何か作ってみようかな。。

    MSチュートリアル
    チュートリアル : 初めての Outlook 用アプリケーション レベルのアドインの作成

    基本、チュートリアルの内容と一緒。
    BCCを追加するには、下記のソースを追加する。

    // メールの成時にBCCを追加する
    mailItem.BCC = "xxxxxx@xxxxx.xx.jp";
    
    

    んでソース。
    今度から、DLできるようにしようかなぁ。

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;
    using System.Windows.Forms;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using Office = Microsoft.Office.Core;
    
    namespace OutlookAddIn_BccAdd
    {
        public partial class ThisAddIn
        {
            Outlook.Inspectors inspectors;
    
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                inspectors = this.Application.Inspectors;
    
                inspectors.NewInspector +=
                    new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_NewInspector);
            }
    
            void Inspectors_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
            {
                Outlook.MailItem mailItem = Inspector.CurrentItem as Outlook.MailItem;
    
                if (mailItem != null)
                {
                    if (mailItem.EntryID == null)
                    {
                        if(MessageBox.Show("メールにBCCを追加しますか?", "確認", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            // メールの成時にBCCを追加する
                            mailItem.BCC = "xxxxxx@xxxxx.xx.jp";
                        }
    
                    }
                }
            }
    
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {
            }
    
            #region VSTO で生成されたコード
    
            /// <summary>
            /// デザイナーのサポートに必要なメソッドです。
            /// このメソッドの内容をコード エディターで変更しないでください。
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }
    
            #endregion
        }
    }
    

     

     

     

    関連記事

    ページ上部へ戻る