コード例 #1
0
ファイル: MailDescriptor.cs プロジェクト: mo5h/omeo
        private void CreateSenderContact(IResource resMail)
        {
            IContact contact = null;

            if (OwnerEmailDetector.IsOwnerEmail(_senderEmail))
            {
                contact = Core.ContactManager.FindOrCreateMySelfContact(_senderEmail, _senderName);
                resMail.SetProp(Core.Props.Date, _sentOn);
                _bSentMySelf = true;
            }
            else
            {
                contact = Core.ContactManager.FindOrCreateContact(_senderEmail, _senderName);
            }
            if ((_bSentMySelf || _bSentToMe) && contact.LastCorrespondDate.CompareTo(resMail.GetProp(Core.Props.Date)) < 0)
            {
                contact.LastCorrespondDate = (DateTime)resMail.GetProp(Core.Props.Date);
            }

            Core.ContactManager.LinkContactToResource(Core.ContactManager.Props.LinkFrom, contact.Resource, resMail, _senderEmail, _senderName);
            if (!resMail.HasLink(Core.ContactManager.Props.LinkFrom, contact.Resource))
            {
                throw new ApplicationException("Core.ContactManager.LinkContactToResource did not linked mail to contact");
            }
        }
コード例 #2
0
ファイル: MailDescriptor.cs プロジェクト: mo5h/omeo
        private void PrepareRecipients(IEMessage message)
        {
            IETable recips = message.GetRecipients();

            if (recips != null)
            {
                using ( recips )
                {
                    long count = recips.GetRowCount();
                    for (long i = 0; i < count; i++)
                    {
                        IERowSet rowSet = recips.GetNextRow();
                        if (rowSet != null)
                        {
                            using ( rowSet )
                            {
                                string emailAddr = rowSet.FindStringProp(MAPIConst.PR_SMTP_ADDRESS);
                                if (emailAddr == null || emailAddr.Length == 0)
                                {
                                    emailAddr = rowSet.FindStringProp(MAPIConst.PR_EMAIL_ADDRESS);
                                }
                                if (emailAddr != null && emailAddr.Length > 0)
                                {
                                    string displayName = rowSet.FindStringProp(MAPIConst.PR_DISPLAY_NAME);

                                    bool isTo   = (rowSet.FindLongProp(MAPIConst.PR_RECIPIENT_TYPE) == (int)RecipientType.To);
                                    bool mySelf = OwnerEmailDetector.IsOwnerEmail(emailAddr);

                                    if (mySelf)
                                    {
                                        _bSentToMe = true;
                                    }
                                    _recipients.Add(new RecipientHelper(emailAddr, displayName, isTo, mySelf));
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        public IContact FindOrCreateContact(string entryID)
        {
            if (!CheckIfNamesValid())
            {
                return(null);
            }
            IContact contactBO = null;
            bool     isMyself  = OwnerEmailDetector.IsOwnerEmail(_emailAddress);

            IResource person = Contact.FindByEntryID(entryID);

            if (person == null && isMyself)
            {
                contactBO = Core.ContactManager.MySelf;
                if (contactBO.Resource.HasProp(PROP.EntryID) && contactBO.Resource.GetStringProp(PROP.EntryID) != entryID)
                {
                    contactBO = FindOrCreateRegularContact(entryID);
                }
                else
                {
                    UpdateFields(contactBO);
                }
                contactBO.AddAccount(_emailAddress);
            }
            else
            {
                if (person != null)
                {
                    contactBO = Core.ContactManager.GetContact(person);
                    UpdateFields(contactBO);
                    contactBO.AddAccount(_emailAddress);
                }
                else
                {
                    contactBO = FindOrCreateRegularContact(entryID);
                }
            }
            return(contactBO);
        }