コード例 #1
0
        internal IRecipient FindSendAsSender(ZPushAccount zpush, GABUser user)
        {
            // First try a simple resolve, this will work if the username is unique
            IRecipient recip = ThisAddIn.Instance.ResolveRecipient(user.UserName);

            if (recip != null)
            {
                // If it's resolved, we're good. Otherwise dispose and continue
                if (recip.IsResolved)
                {
                    return(recip);
                }
                else
                {
                    recip.Dispose();
                }
            }

            // Search through GAB to find the user
            if (GABLookup)
            {
                GABHandler handler = FeatureGAB.FindGABForAccount(zpush);
                if (handler != null && handler.Contacts != null)
                {
                    // Look for the email address. If found, use the account associated with the GAB
                    using (ISearch <IContactItem> search = handler.Contacts.Search <IContactItem>())
                    {
                        search.AddField("urn:schemas:contacts:customerid").SetOperation(SearchOperation.Equal, user.UserName);
                        using (IContactItem result = search.SearchOne())
                        {
                            if (result != null)
                            {
                                // Try resolving by email
                                return(ThisAddIn.Instance.ResolveRecipient(result.Email1Address));
                            }
                        }
                    }
                }
            }

            return(null);
        }
コード例 #2
0
        private IRecipient CreateRecipient(IRecipients recipients, string decoded)
        {
            // First try to resolve directly
            IRecipient recipient = recipients.Add(decoded);

            if (recipient.Resolve())
            {
                return(recipient);
            }

            // Nope, remove and create with email
            recipient.Dispose();
            recipient = null;
            recipients.Remove(recipients.Count - 1);

            string displayName;
            string email = ParseBCCHeader(decoded, out displayName);

            // TODO: is it possible to use the display name?
            recipient = recipients.Add(email);
            recipient.Resolve();
            return(recipient);
        }