protected RecipientCommonWindow(Utility.OutlookItemType type, List <RecipientInformationDto> recipients)
        {
            InitializeComponent();
            _type           = type;
            _recipientsList = recipients;

            _measureFont     = textBox1.Font;
            _measureGraphics = textBox1.CreateGraphics();
        }
예제 #2
0
        /// <summary>
        ///  アイテム送信時の宛先表示画面を生成する
        /// </summary>
        /// <param name="item">アイテム</param>
        /// <param name="cancel">送信をしないかどうか</param>
        private void ConfirmContact(object Item, ref bool Cancel)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                // アイテムタイプをMailで初期化
                Utility.OutlookItemType itemType = Utility.OutlookItemType.Mail;

                // アイテムの宛先を取得
                List <Outlook.Recipient> recipientsList = new List <Outlook.Recipient>();
                recipientsList = Utility.GetRecipients(Item, ref itemType, true);

                // 会議の招待に対する返事の場合、宛先表示しない
                if (itemType == Utility.OutlookItemType.MeetingResponse ||
                    recipientsList == null)
                {
                    return;
                }

                // 宛先情報のリストを取得
                SearchRecipient searchRecipient = new SearchRecipient();
                List <RecipientInformationDto> recipientList = searchRecipient.SearchContact(recipientsList, itemType);

                // 送信者のExchangeUserオブジェクトを取得
                RecipientInformationDto senderInformation = null;
                senderInformation = Utility.GetSenderInfomation(Item);

                // 受信者の宛先情報のリストに、送信者の情報も追加する
                if (senderInformation != null)
                {
                    recipientList.Add(senderInformation);
                }

                Cursor.Current = Cursors.Default;

                // 引数に宛先情報を渡し、宛先表示画面を表示する
                RecipientConfirmationWindow recipientWindow = new RecipientConfirmationWindow(itemType, recipientList);
                DialogResult result = recipientWindow.ShowDialog();

                // 画面でOK以外が選択された場合
                if (result != DialogResult.OK)
                {
                    // メール送信のイベントをキャンセルする
                    Cancel = true;
                }
            }
            /// 例外が発生した場合、エラーダイアログを表示
            /// 送信イベントをキャンセルする
            catch (Exception ex)
            {
                // エラーダイアログの呼び出し
                ErrorDialog.ShowException(ex);

                Cancel = true;
            }
        }
예제 #3
0
        /// <summary>
        /// 送信者、To、Cc、Bccを取得と検索し、宛先リスト画面を呼び出す
        /// </summary>
        private void ShowRecipientListWindow(object activeItem)
        {
            Cursor.Current = Cursors.WaitCursor;

            /// Mailで初期化
            Utility.OutlookItemType itemType          = Utility.OutlookItemType.Mail;
            RecipientInformationDto senderInformation = null;

            /// メールの宛先を取得
            List <Outlook.Recipient> recipientsList = new List <Outlook.Recipient>();

            recipientsList = Utility.GetRecipients(activeItem, ref itemType);

            ///  会議招集の返信の場合、そのまま送信する
            if (recipientsList == null)
            {
                return;
            }

            /// 検索し、受信者の宛先情報リストが戻ってくる
            SearchRecipient searchRecipient = new SearchRecipient();
            List <RecipientInformationDto> recipientList = searchRecipient.SearchContact(recipientsList, itemType);

            /// 送信者のExchangeUserオブジェクトを取得
            senderInformation = Utility.GetSenderInfomation(activeItem);

            /// 受信者の宛先情報のリストに、送信者の情報も追加する
            if (senderInformation != null)
            {
                recipientList.Add(senderInformation);
            }

            Cursor.Current = Cursors.Default;

            // 宛先リストの画面を表示する
            RecipientListWindow recipientListWindow = new RecipientListWindow(itemType, recipientList);

            recipientListWindow.ShowDialog();
        }
 public RecipientConfirmationWindow(Utility.OutlookItemType type, List <RecipientInformationDto> recipients) : base(type, recipients)
 {
     InitializeComponent();
 }
        /// <summary>
        /// メールのアドレスから宛先情報を検索する
        /// </summary>
        /// <param name="addressList">メールのTO, CC, BCC</param>
        /// <returns> 検索した宛先情報のリスト</returns>
        public List <RecipientInformationDto> SearchContact(List <Recipient> recipientsList, Utility.OutlookItemType itemType)
        {
            /// 検索結果の宛先情報のリスト
            List <RecipientInformationDto> _recipientInformationList = new List <RecipientInformationDto>();

            /// ファクトリオブジェクトに連絡先クラスのインスタンスの生成をしてもらう
            ContactFactory  contactFactory = new ContactFactory();
            List <IContact> contactList    = contactFactory.CreateContacts();

            /// ある1人の受信者の宛先情報を取得する
            foreach (var recipient in recipientsList)
            {
                RecipientInformationDto recipientInformation = null;

                try
                {
                    /// それぞれの連絡先クラスで検索する
                    foreach (var item in contactList)
                    {
                        ContactItem contactItem = item.getContactItem(recipient);

                        /// 送信先アドレスからその人の情報が見つかれば、名、部署、会社名、タイプをDtoにセット
                        if (contactItem != null)
                        {
                            string jobTitle = Utility.FormatJobTitle(contactItem.JobTitle);

                            // TaskRequstResponseは強制的にToにする
                            OlMailRecipientType recipientType = itemType != Utility.OutlookItemType.TaskRequestResponse ?
                                                                (OlMailRecipientType)recipient.Type :
                                                                OlMailRecipientType.olTo;

                            recipientInformation = new RecipientInformationDto(contactItem.FullName, contactItem.Department, contactItem.CompanyName, jobTitle, recipientType);
                            break;
                        }
                    }

                    if (recipientInformation == null)
                    {
                        recipientInformation = new RecipientInformationDto(
                            Utility.GetDisplayNameAndAddress(recipient),
                            (OlMailRecipientType)recipient.Type);
                    }
                    _recipientInformationList.Add(recipientInformation);
                }
                /// 例外が発生した場合、Nameを表示する
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    _recipientInformationList.Add(new RecipientInformationDto(
                                                      Utility.GetDisplayNameAndAddress(recipient),
                                                      (OlMailRecipientType)recipient.Type));
                }
            }

            return(_recipientInformationList);
        }