Пример #1
0
 // Token: 0x0600036F RID: 879 RVA: 0x00013FA4 File Offset: 0x000121A4
 private void ExpandPDL(RecipientAddress address, List <ResolvedRecipient> recipients)
 {
     Participant[] array;
     try
     {
         array = DistributionList.ExpandDeep(this.mailboxSession, address.StoreObjectId);
     }
     catch (ObjectNotFoundException)
     {
         return;
     }
     foreach (Participant participant in array)
     {
         StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
         if (storeParticipantOrigin != null)
         {
             StoreObjectId    originItemId = storeParticipantOrigin.OriginItemId;
             RecipientAddress recipientAddress;
             try
             {
                 recipientAddress = this.ConstructStoreRecipientAddress(participant, participant.DisplayName, originItemId);
             }
             catch (ObjectNotFoundException)
             {
                 goto IL_FF;
             }
             if (recipientAddress != null)
             {
                 recipients.Add(new ResolvedRecipient(recipientAddress));
             }
         }
         else
         {
             RecipientAddress recipientAddress2 = new RecipientAddress();
             recipientAddress2.RoutingType    = participant.RoutingType;
             recipientAddress2.SmtpAddress    = (participant.TryGetProperty(ParticipantSchema.SmtpAddress) as string);
             recipientAddress2.DisplayName    = participant.DisplayName;
             recipientAddress2.RoutingAddress = participant.EmailAddress;
             if (!string.IsNullOrEmpty(recipientAddress2.RoutingType) && participant.RoutingType == "EX")
             {
                 recipientAddress2.AddressOrigin = AddressOrigin.Directory;
             }
             else
             {
                 recipientAddress2.AddressOrigin = AddressOrigin.OneOff;
             }
             if (recipientAddress2.SmtpAddress != null)
             {
                 recipients.Add(new ResolvedRecipient(recipientAddress2));
             }
         }
         IL_FF :;
     }
 }
        public void ExpandDistributionList()
        {
            ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "RecipientWellEventHandler.ExpandDistributionList");
            RecipientInfo[]    array = (RecipientInfo[])base.GetParameter("Recips");
            List <Participant> list  = new List <Participant>();

            foreach (RecipientInfo recipientInfo in array)
            {
                if (recipientInfo.StoreObjectId == null || !Utilities.IsMapiPDL(recipientInfo.RoutingType))
                {
                    throw new OwaEventHandlerException("The requested recipient is not personal distribution list");
                }
                list.AddRange(DistributionList.ExpandDeep(base.UserContext.MailboxSession, recipientInfo.StoreObjectId));
            }
            using (List <Participant> .Enumerator enumerator = list.GetEnumerator())
            {
                AdRecipientBatchQuery adRecipientBatchQuery = new AdRecipientBatchQuery(enumerator, base.UserContext);
                bool flag = false;
                foreach (Participant participant in list)
                {
                    string            smtpAddress       = null;
                    string            sipUri            = null;
                    ADObjectId        adObjectId        = null;
                    StoreObjectId     storeObjectId     = null;
                    EmailAddressIndex emailAddressIndex = EmailAddressIndex.None;
                    string            mobilePhoneNumber = null;
                    if (participant.RoutingType == "EX")
                    {
                        ADRecipient adRecipient = adRecipientBatchQuery.GetAdRecipient(participant.EmailAddress);
                        if (adRecipient != null)
                        {
                            smtpAddress       = adRecipient.PrimarySmtpAddress.ToString();
                            adObjectId        = adRecipient.Id;
                            sipUri            = InstantMessageUtilities.GetSipUri((ProxyAddressCollection)adRecipient[ADRecipientSchema.EmailAddresses]);
                            mobilePhoneNumber = Utilities.NormalizePhoneNumber((string)adRecipient[ADOrgPersonSchema.MobilePhone]);
                        }
                    }
                    else
                    {
                        smtpAddress = participant.EmailAddress;
                        sipUri      = participant.EmailAddress;
                    }
                    RecipientAddress.RecipientAddressFlags recipientAddressFlags = RecipientAddress.RecipientAddressFlags.None;
                    if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsDistributionList))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.DistributionList;
                    }
                    else if (participant.GetValueOrDefault <bool>(ParticipantSchema.IsRoom))
                    {
                        recipientAddressFlags |= RecipientAddress.RecipientAddressFlags.Room;
                    }
                    StoreParticipantOrigin storeParticipantOrigin = participant.Origin as StoreParticipantOrigin;
                    if (storeParticipantOrigin != null)
                    {
                        storeObjectId     = storeParticipantOrigin.OriginItemId;
                        emailAddressIndex = storeParticipantOrigin.EmailAddressIndex;
                    }
                    RecipientWellNode.Render(this.Writer, base.UserContext, participant.DisplayName, smtpAddress, participant.EmailAddress, participant.RoutingType, participant.GetValueOrDefault <string>(ParticipantSchema.Alias), RecipientAddress.ToAddressOrigin(participant), (int)recipientAddressFlags, storeObjectId, emailAddressIndex, adObjectId, flag ? RecipientWellNode.RenderFlags.RenderCommas : RecipientWellNode.RenderFlags.None, sipUri, mobilePhoneNumber);
                    flag = true;
                }
            }
        }
Пример #3
0
        private EmailAddressWrapper[] GetCertsFromPrivateDL(Participant p, bool isCurrent)
        {
            Participant[] array = null;
            try
            {
                StoreObjectId originItemId = ((StoreParticipantOrigin)p.Origin).OriginItemId;
                array = DistributionList.ExpandDeep(this.storeSession, originItemId, false);
                if (array == null || array.Length == 0)
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                this.LogException(ex, "Error occurred when expanding PrivateDL: {0}", new object[]
                {
                    this.ParticipantToString(p)
                });
                return(this.GetCurrent(p, isCurrent, "PrivateDL"));
            }
            List <EmailAddressWrapper> list = new List <EmailAddressWrapper>();

            foreach (Participant participant in array)
            {
                string paticipantAddress = this.GetPaticipantAddress(participant);
                if (participant.Origin is StoreParticipantOrigin)
                {
                    EmailAddressWrapper[] collection;
                    if (string.IsNullOrEmpty(paticipantAddress))
                    {
                        if ((collection = this.GetCertsFromPrivateDL(participant, false)) != null)
                        {
                            list.AddRange(collection);
                        }
                    }
                    else if ((collection = this.GetCertsFromContact(participant, false)) != null)
                    {
                        list.AddRange(collection);
                    }
                }
                else if (participant.Origin is DirectoryParticipantOrigin)
                {
                    EmailAddressWrapper[] certsFromDirectory;
                    if ((certsFromDirectory = this.GetCertsFromDirectory(participant, false)) != null)
                    {
                        list.AddRange(certsFromDirectory);
                    }
                }
                else if (!string.IsNullOrEmpty(paticipantAddress))
                {
                    ADRecipient           adRecipient = this.GetAdRecipient(paticipantAddress);
                    EmailAddressWrapper[] certsFromDirectory;
                    if (adRecipient == null)
                    {
                        EmailAddressWrapper emailAddressWrapper = this.GetEmailAddressWrapper(participant, "OneOff");
                        list.Add(emailAddressWrapper);
                    }
                    else if ((certsFromDirectory = this.GetCertsFromDirectory(new Participant(adRecipient), false)) != null)
                    {
                        list.AddRange(certsFromDirectory);
                    }
                }
                else
                {
                    EmailAddressWrapper emailAddressWrapper2 = this.GetEmailAddressWrapper(participant, "Unknown");
                    list.Add(emailAddressWrapper2);
                }
            }
            return(list.ToArray());
        }
Пример #4
0
        private static string[] GetEmailAddressesFromContacts(MailboxSession itemStore)
        {
            List <string> list = new List <string>();

            PropertyDefinition[] dataColumns = new PropertyDefinition[]
            {
                ItemSchema.Id,
                ContactSchema.Email1EmailAddress,
                ContactSchema.Email2EmailAddress,
                ContactSchema.Email3EmailAddress,
                StoreObjectSchema.ItemClass,
                ContactSchema.Email1AddrType,
                ContactSchema.Email2AddrType,
                ContactSchema.Email3AddrType
            };
            List <StoreObjectId> contactsFolders = UserContacts.GetContactsFolders(itemStore);

            foreach (StoreObjectId storeObjectId in contactsFolders)
            {
                try
                {
                    using (Folder folder = Folder.Bind(itemStore, storeObjectId))
                    {
                        using (QueryResult queryResult = folder.ItemQuery(ItemQueryType.None, null, null, dataColumns))
                        {
                            for (;;)
                            {
                                object[][] rows = queryResult.GetRows(100);
                                if (rows.GetLength(0) == 0)
                                {
                                    break;
                                }
                                foreach (object[] array2 in rows)
                                {
                                    string text = array2[4] as string;
                                    if (!string.IsNullOrEmpty(text))
                                    {
                                        if (ObjectClass.IsContact(text))
                                        {
                                            int num = 5;
                                            int j   = 1;
                                            while (j <= 3)
                                            {
                                                string text2 = array2[j] as string;
                                                string a     = array2[num] as string;
                                                if (!(a == "EX") && !string.IsNullOrEmpty(text2))
                                                {
                                                    string text3 = text2.Trim();
                                                    if (text3.Length > 0)
                                                    {
                                                        list.Add(text3);
                                                    }
                                                }
                                                j++;
                                                num++;
                                            }
                                        }
                                        else if (ObjectClass.IsDistributionList(text))
                                        {
                                            VersionedId versionedId = array2[0] as VersionedId;
                                            if (versionedId != null)
                                            {
                                                Participant[] array3 = DistributionList.ExpandDeep(itemStore, versionedId.ObjectId);
                                                foreach (Participant participant in array3)
                                                {
                                                    if (!(participant.RoutingType == "EX") && !string.IsNullOrEmpty(participant.EmailAddress))
                                                    {
                                                        string text4 = participant.EmailAddress.Trim();
                                                        if (text4.Length > 0)
                                                        {
                                                            list.Add(text4);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (ObjectNotFoundException arg)
                {
                    UserContacts.Tracer.TraceDebug <IExchangePrincipal, StoreObjectId, ObjectNotFoundException>(0L, "Mailbox:{0}: Exception while binding or query folder={0}, while mining emails for known contacts, exception={2}", itemStore.MailboxOwner, storeObjectId, arg);
                }
            }
            return(UserContacts.SortAndRemoveDuplicates(list.ToArray(), itemStore));
        }