Пример #1
0
        private bool RecipientContainsString(Outlook.Recipient recipient, string name)
        {
            Outlook.AddressEntry addressEntry = recipient.AddressEntry;
            if (addressEntry == null)
            {
                return(false);
            }

            if (addressEntry.Name.ContainsWholeWord(name, ignoreCase: true))
            {
                return(true);
            }

            Outlook.ContactItem contact = addressEntry.GetContact();
            if (contact != null)
            {
                string email = contact.Email1Address;
                if (email != null && email.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }

                email = contact.Email2Address;
                if (email != null && email.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }

                email = contact.Email3Address;
                if (email != null && email.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }

                string fullName = contact.FullName;
                if (fullName != null && fullName.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }
            }

            Outlook.ExchangeUser exchageUser = addressEntry.GetExchangeUser();
            if (exchageUser != null)
            {
                string alias = exchageUser.Alias;
                if (alias.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }

                string primarySmptAddress = exchageUser.PrimarySmtpAddress;
                if (primarySmptAddress.ContainsWholeWord(name, ignoreCase: true))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        private void ProcessContact(Outlook.AddressEntry address, bool useAddress = true)
        {
            var contact = address.GetContact();

            if (contact == null && useAddress)
            {
                Email.Add(address.Address);
                return;
            }

            ProcessContact(contact);
        }
Пример #3
0
        private void ProcessExchangeUser(Outlook.AddressEntry address)
        {
            if (Globals.ThisAddIn.Offline)
            {
                var contact = address.GetContact();
                if (contact != null)
                {
                    ProcessContact(contact);
                    return;
                }
            }

            ProcessExchangeUser(address.GetExchangeUser());
        }
Пример #4
0
        /// <summary>
        /// MeetingItemの送信者情報(Dto)を取得する
        /// </summary>
        /// <param name="Item">MeetingItemオブジェクト</param>
        /// <returns>送信者の宛先情報DTO(送信者が取得できない場合null)</returns>
        private static RecipientInformationDto GetSenderInformation(Outlook.MeetingItem item)
        {
            // SenderEmailAddressから、送信者のAddressEntry及びExchangeUserを取得
            Outlook.Recipient recipient = Globals.ThisAddIn.Application.Session.CreateRecipient(item.SenderEmailAddress);

            Outlook.AddressEntry addressEntry = null;
            Outlook.ExchangeUser exchUser     = null;
            Outlook.ContactItem  contactItem  = null;
            if (recipient != null)
            {
                addressEntry = recipient.AddressEntry;
                exchUser     = getExchangeUser(addressEntry);
                try
                {
                    contactItem = addressEntry.GetContact();
                }
                catch
                {
                    contactItem = null;
                }
            }

            RecipientInformationDto senderInformation = null;

            // 送信者のExchangeUserが取得できた場合
            if (exchUser != null)
            {
                senderInformation = new RecipientInformationDto(exchUser.Name,
                                                                exchUser.Department,
                                                                exchUser.CompanyName,
                                                                FormatJobTitle(exchUser.JobTitle),
                                                                Outlook.OlMailRecipientType.olOriginator);
            }
            // Exchangeアドレス帳にないが、「連絡先」にいる場合
            else if (contactItem != null)
            {
                senderInformation = new RecipientInformationDto(contactItem.FullName,
                                                                contactItem.Department,
                                                                contactItem.CompanyName,
                                                                FormatJobTitle(contactItem.JobTitle),
                                                                Outlook.OlMailRecipientType.olOriginator);
            }
            // Exchangeアドレス帳にも「連絡先」にもない場合
            else
            {
                string displayName;
                if (item.SenderName != null && !Utility.IsEmailAddress(item.SenderName))
                {
                    displayName = FormatDisplayNameAndAddress(item.SenderName, item.SenderEmailAddress);
                }
                else if (recipient != null && !Utility.IsEmailAddress(recipient.Name))
                {
                    displayName = GetDisplayNameAndAddress(recipient);
                }
                else if (addressEntry != null)
                {
                    displayName = FormatDisplayNameAndAddress(addressEntry.Name, addressEntry.Address);
                }
                else
                {
                    displayName = FormatDisplayNameAndAddress(item.SenderName, item.SenderEmailAddress);
                }

                senderInformation = new RecipientInformationDto(displayName, Outlook.OlMailRecipientType.olOriginator);
            }
            return(senderInformation);
        }