protected static RecipientItemType GetRecipientType(RuleEvaluationContextBase context)
        {
            RecipientItemType result = RecipientItemType.Unknown;
            string            text   = context.PropertyBag[StoreObjectSchema.ItemClass] as string;

            if (!string.IsNullOrEmpty(text) && ObjectClass.IsReport(text))
            {
                result = RecipientItemType.To;
            }
            else
            {
                RecipientCollection recipients = context.Message.Recipients;
                for (int i = 0; i < recipients.Count; i++)
                {
                    if (recipients[i].Participant.RoutingType != null && recipients[i].Participant.EmailAddress != null)
                    {
                        ProxyAddress addressToResolve = ProxyAddress.Parse(recipients[i].Participant.RoutingType, recipients[i].Participant.EmailAddress);
                        if (RuleUtil.IsSameUser(context, context.RecipientCache, addressToResolve, context.Recipient))
                        {
                            result = recipients[i].RecipientItemType;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        protected bool AddMessageRecipients(RecipientCollection recipients, RecipientItemType recipientItemType, string wellName)
        {
            bool flag = false;

            this.Writer.Write("<div id=\"");
            this.Writer.Write(wellName);
            this.Writer.Write("\">");
            RecipientInfo[] array = (RecipientInfo[])base.GetParameter(wellName);
            if (array == null)
            {
                this.Writer.Write("</div>");
                return(false);
            }
            List <Participant> list = new List <Participant>();

            foreach (RecipientInfo recipientInfo in array)
            {
                flag |= base.GetExchangeParticipantsFromRecipientInfo(recipientInfo, list);
            }
            for (int j = 0; j < list.Count; j++)
            {
                recipients.Add(list[j], recipientItemType);
            }
            this.Writer.Write("</div>");
            return(flag);
        }
Exemple #3
0
 public RecipientCollection FetchAll()
 {
     RecipientCollection coll = new RecipientCollection();
     Query qry = new Query(Recipient.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
 // Token: 0x0600060A RID: 1546 RVA: 0x0002E84C File Offset: 0x0002CA4C
 private bool CompareRecipients(RecipientCollection originalRecipients, RecipientCollection currentRecipients)
 {
     if (originalRecipients != null && currentRecipients != null)
     {
         if (originalRecipients.Count != currentRecipients.Count)
         {
             return(false);
         }
         using (IEnumerator <Recipient> enumerator = originalRecipients.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 Recipient value = enumerator.Current;
                 if (!currentRecipients.Contains(value, RecipientEqualityComparer.Default))
                 {
                     return(false);
                 }
             }
             return(true);
         }
     }
     if (originalRecipients != null || currentRecipients != null)
     {
         return(false);
     }
     return(true);
 }
Exemple #5
0
        /// <summary>
        /// Default constructor for creating InteropRecipientCollection.
        /// </summary>
        /// <param name="outer"></param>
        public InteropRecipientCollection(RecipientCollection outer)
        {
            _count = outer.Count;

            if (_count == 0)
            {
                _handle = IntPtr.Zero;
                return;
            }

            // allocate enough memory to hold all recipients
            int size = Marshal.SizeOf(typeof(MapiMailMessage.MAPIHelperInterop.MapiRecipDesc));

            _handle = Marshal.AllocHGlobal(_count * size);

            // place all interop recipients into the memory just allocated
            int ptr = (int)_handle;

            foreach (Recipient native in outer)
            {
                MapiMailMessage.MAPIHelperInterop.MapiRecipDesc interop = native.GetInteropRepresentation();

                // stick it in the memory block
                Marshal.StructureToPtr(interop, (IntPtr)ptr, false);
                ptr += size;
            }
        }
 public static void ClearRecipients(RecipientCollection collection, RecipientItemType recipientItemType)
 {
     for (int i = collection.Count - 1; i >= 0; i--)
     {
         if (collection[i].RecipientItemType == recipientItemType)
         {
             collection.RemoveAt(i);
         }
     }
 }
 // Token: 0x06000115 RID: 277 RVA: 0x0000710C File Offset: 0x0000530C
 private static void CloneSmsItem(MailboxSession session, MessageItem source, MailboxData mailboxData, Recipient recipient, ConversationIndex conversationIndex)
 {
     using (MessageItem messageItem = MessageItem.CloneMessage(session, StoreObjectId.FromProviderSpecificId(mailboxData.SentItemsFolderId), source))
     {
         RecipientCollection recipients = messageItem.Recipients;
         recipients.Clear();
         recipients.Add(recipient);
         SentItemsProcessor.SaveSmsItem(messageItem, conversationIndex);
     }
 }
Exemple #8
0
 public MessageChildren()
     : base()
 {
     MetaTagFXDelPropBeforeRecv = FTFactory.Instance.CreateFxDelMetaProperty();
     Recipients = FTFactory.Instance.CreateRecipientCollection();
     MetaTagFXDelPropBeforeAttach = FTFactory.Instance.CreateFxDelMetaProperty();
     Attachments = FTFactory.Instance.CreateAttachmentCollection();
     Children.Add(MetaTagFXDelPropBeforeRecv);
     Children.Add(Recipients);
     Children.Add(MetaTagFXDelPropBeforeAttach);
     Children.Add(Attachments);
 }
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string recipientString = (string)value;

            string[] recipients = recipientString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            RecipientCollection recipientCollection = new RecipientCollection();
            for (int i = 0; i < recipients.Length; i++)
            {
                recipientCollection.Add(Int32.Parse(recipients[i]));
            }

            return recipientCollection;
        }
Exemple #10
0
        private object ConvertRecipientCollectionFromString(object value)
        {
            string recipientString = (string)value;

            string[] recipients = recipientString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            RecipientCollection recipientCollection = new RecipientCollection();
            for (int i = 0; i < recipients.Length; i++)
            {
                recipientCollection.Add(Int32.Parse(recipients[i]));
            }

            return recipientCollection;
        }
Exemple #11
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string recipientString = (string)value;

            string[] recipients = recipientString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            RecipientCollection recipientCollection = new RecipientCollection();

            for (int i = 0; i < recipients.Length; i++)
            {
                recipientCollection.Add(Int32.Parse(recipients[i]));
            }

            return(recipientCollection);
        }
Exemple #12
0
        private object ConvertRecipientCollectionFromString(object value)
        {
            string recipientString = (string)value;

            string[] recipients = recipientString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

            RecipientCollection recipientCollection = new RecipientCollection();

            for (int i = 0; i < recipients.Length; i++)
            {
                recipientCollection.Add(Int32.Parse(recipients[i]));
            }

            return(recipientCollection);
        }
Exemple #13
0
        private object ConvertRecipientCollectionToString(object value)
        {
            RecipientCollection users   = (RecipientCollection)value;
            StringBuilder       builder = new StringBuilder();

            for (int i = 0; i < users.Count; i++)
            {
                if (i == 0)
                {
                    builder.Append(users[i].ToString());
                }
                else
                {
                    builder.AppendFormat(";{0}", users[i]);
                }
            }

            return(builder.ToString());
        }
Exemple #14
0
        private static ADRecipientOrAddress[] GetSpecifiedRecipients(RecipientCollection recipients, RecipientItemType recipientType)
        {
            if (recipients == null || recipients.Count <= 0)
            {
                return(null);
            }
            List <ADRecipientOrAddress> list = new List <ADRecipientOrAddress>(recipients.Count);

            for (int i = 0; i < recipients.Count; i++)
            {
                if (recipients[i].RecipientItemType == recipientType)
                {
                    list.Add(new ADRecipientOrAddress(recipients[i].Participant));
                }
            }
            if (list.Count <= 0)
            {
                return(null);
            }
            return(list.ToArray());
        }
 public static void SetRecipientCollection(RecipientCollection collection, RecipientItemType recipientItemType, string textString)
 {
     if (collection == null)
     {
         throw new ArgumentNullException("Recipient collection null");
     }
     if (textString == null)
     {
         throw new ArgumentNullException("Recipient string null");
     }
     string[] array = ParseRecipientHelper.ParseRecipientChunk(textString);
     EmailAddressConverter.ClearRecipients(collection, recipientItemType);
     for (int i = 0; i < array.Length; i++)
     {
         if (!string.IsNullOrEmpty(array[i]))
         {
             Participant participant = Participant.Parse(array[i]);
             EmailAddressConverter.ValidateParticipant(participant);
             collection.Add(participant, recipientItemType);
         }
     }
 }
Exemple #16
0
        public override object ConvertTo(
            ITypeDescriptorContext context,
            System.Globalization.CultureInfo culture,
            object value,
            Type destinationType)
        {
            RecipientCollection users   = (RecipientCollection)value;
            StringBuilder       builder = new StringBuilder();

            for (int i = 0; i < users.Count; i++)
            {
                if (i == 0)
                {
                    builder.Append(users[i].ToString());
                }
                else
                {
                    builder.AppendFormat(";{0}", users[i]);
                }
            }

            return(builder.ToString());
        }
Exemple #17
0
 public RecipientCollection FetchByID(object RecipientsKey)
 {
     RecipientCollection coll = new RecipientCollection().Where("recipients_key", RecipientsKey).Load();
     return coll;
 }
Exemple #18
0
 /// <summary>
 /// Creates a blank mail message.
 /// </summary>
 public MapiMailMessage()
 {
     _files = new ArrayList();
     _recipientCollection = new RecipientCollection();
     _manualResetEvent    = new ManualResetEvent(false);
 }
Exemple #19
0
        internal static bool SetRecipients(IRuleEvaluationContext context, MessageItem message, IList <ProxyAddress> senderAddresses, RecipientCollection recipients, bool promoteToEnvelope)
        {
            int num = 0;

            message.Recipients.Clear();
            foreach (Recipient recipient in recipients)
            {
                if (promoteToEnvelope && RuleUtil.IsRecipientSameAsSender(senderAddresses, recipient.Participant.EmailAddress))
                {
                    context.TraceDebug <string>("Skipping recipient {0} because that was the original sender.", recipient.Participant.EmailAddress);
                }
                else
                {
                    context.TraceDebug <string>("Adding recipient {0}.", recipient.Participant.ToString());
                    Recipient recipient2 = message.Recipients.Add(recipient.Participant, recipient.RecipientItemType);
                    recipient2[ItemSchema.Responsibility] = promoteToEnvelope;
                    num++;
                }
            }
            return(num > 0);
        }
Exemple #20
0
 internal void SetRecipients(RecipientCollection recipients)
 {
     this.Bcc = MailMessage.GetSpecifiedRecipients(recipients, RecipientItemType.Bcc);
     this.Cc  = MailMessage.GetSpecifiedRecipients(recipients, RecipientItemType.Cc);
     this.To  = MailMessage.GetSpecifiedRecipients(recipients, RecipientItemType.To);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MailDialog"/> class.
 /// </summary>
 public MailDialog()
 {
     _manualResetEvent = new ManualResetEvent(false);
     Attachments = new AttachmentCollection();
     Recipients = new RecipientCollection();
 }
Exemple #22
0
        private void InsertRecipientCount(string messageID, RecipientCollection recipientColl)
        {
            MySqlConnection connection = new MySqlConnection(conStr);
            MySqlCommand cmd = new MySqlCommand();
            int toCount =0, ccCount =0, bccCount = 0;

            connection.Open();
            cmd.Connection = connection;
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = "INSERT INTO emailDetailsRecipientCount VALUES (@messageID,@RecipientToCount,@RecipientCCCount,@RecipientBCCCount)";

            foreach (Recipient r in recipientColl)
            {
                string recipientType = r.RecipientType.ToString();
                switch (recipientType.ToUpper())
                {
                    case "TO":
                        toCount++;
                        break;
                    case "CC":
                        ccCount++;
                        break;
                    case "BCC":
                        bccCount++;
                        break;
                }
            }
            cmd.Parameters.Add(new MySqlParameter("messageID", messageID));
            cmd.Parameters.Add(new MySqlParameter("RecipientToCount", toCount));
            cmd.Parameters.Add(new MySqlParameter("RecipientCCCount", ccCount));
            cmd.Parameters.Add(new MySqlParameter("RecipientBCCCount", bccCount));
            cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            cmd.Connection.Close();
        }
Exemple #23
0
 /// <summary>
 /// Creates a blank mail message.
 /// </summary>
 public MapiMailMessage()
 {
     _files = new ArrayList();
     _recipientCollection = new RecipientCollection();
     _manualResetEvent = new ManualResetEvent(false);
 }
Exemple #24
0
        /// <summary>
        /// Default constructor for creating InteropRecipientCollection.
        /// </summary>
        /// <param name="outer"></param>
        public InteropRecipientCollection(RecipientCollection outer)
        {
            _count = outer.Count;

            if (_count == 0)
            {
                _handle = IntPtr.Zero;
                return;
            }

            // allocate enough memory to hold all recipients
            int size = Marshal.SizeOf(typeof(MapiMailMessage.MAPIHelperInterop.MapiRecipDesc));
            _handle = Marshal.AllocHGlobal(_count * size);

            // place all interop recipients into the memory just allocated
            int ptr = (int)_handle;
            foreach (Recipient native in outer)
            {
                MapiMailMessage.MAPIHelperInterop.MapiRecipDesc interop = native.GetInteropRepresentation();

                // stick it in the memory block
                Marshal.StructureToPtr(interop, (IntPtr)ptr, false);
                ptr += size;
            }
        }
Exemple #25
0
 public RecipientCollection FetchByQuery(Query qry)
 {
     RecipientCollection coll = new RecipientCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
        // Token: 0x06000114 RID: 276 RVA: 0x00006EAC File Offset: 0x000050AC
        private static void HandleSmsMessage(MailboxSession session, Item item, MailboxData mailboxData, ConversationIndexTrackingEx indexTrackingEx)
        {
            MessageItem messageItem = item as MessageItem;

            if (messageItem == null)
            {
                SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: the SMS message is not MessageItem", new object[]
                {
                    TraceContext.Get()
                });
                return;
            }
            RecipientCollection recipients = messageItem.Recipients;

            if (recipients.Count == 0)
            {
                return;
            }
            using (SmsRecipientInfoCache smsRecipientInfoCache = SmsRecipientInfoCache.Create(session, SentItemsProcessor.Tracer))
            {
                Dictionary <ConversationIndex, Recipient> dictionary = new Dictionary <ConversationIndex, Recipient>(recipients.Count);
                for (int i = recipients.Count - 1; i >= 0; i--)
                {
                    Recipient   recipient   = recipients[i];
                    Participant participant = recipient.Participant;
                    if (!(participant == null) && !string.IsNullOrEmpty(participant.EmailAddress))
                    {
                        string text = null;
                        if (string.Equals(participant.RoutingType, "MOBILE", StringComparison.OrdinalIgnoreCase))
                        {
                            text = participant.EmailAddress;
                            smsRecipientInfoCache.AddRecipient(participant);
                        }
                        else if (string.Equals(participant.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase))
                        {
                            ProxyAddress proxyAddress;
                            if (SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress) && string.Equals(proxyAddress.PrefixString, "MOBILE", StringComparison.OrdinalIgnoreCase))
                            {
                                text = proxyAddress.AddressString;
                            }
                            smsRecipientInfoCache.AddRecipient(new Participant(participant.DisplayName, text, "MOBILE"));
                        }
                        if (text != null)
                        {
                            ConversationIndex conversationIndex = ConversationIndex.GenerateFromPhoneNumber(text);
                            if (!(conversationIndex == ConversationIndex.Empty))
                            {
                                recipients.RemoveAt(i);
                                if (!dictionary.ContainsKey(conversationIndex))
                                {
                                    dictionary.Add(conversationIndex, recipient);
                                }
                            }
                        }
                    }
                }
                if (recipients.Count > 0)
                {
                    messageItem.Save(SaveMode.ResolveConflicts);
                    messageItem.Load();
                }
                int num = 0;
                foreach (KeyValuePair <ConversationIndex, Recipient> keyValuePair in dictionary)
                {
                    num++;
                    AggregationBySmsItemClassProcessor.ChunkSmsConversation(XSOFactory.Default, session, keyValuePair.Key, indexTrackingEx);
                    if (num < dictionary.Count || recipients.Count > 0)
                    {
                        SentItemsProcessor.CloneSmsItem(session, messageItem, mailboxData, keyValuePair.Value, keyValuePair.Key);
                    }
                    else
                    {
                        recipients.Add(keyValuePair.Value);
                        SentItemsProcessor.SaveSmsItem(messageItem, keyValuePair.Key);
                        messageItem.Load();
                    }
                }
                smsRecipientInfoCache.Commit();
            }
        }
        public static string GetRecipientString(RecipientCollection collection, RecipientItemType recipientItemType, IExchangePrincipal exchangePrincipal)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("Recipient collection null");
            }
            if (collection.Count == 0)
            {
                return(string.Empty);
            }
            int num = 0;

            Participant[] array  = new Participant[collection.Count];
            Participant[] array2 = new Participant[collection.Count];
            foreach (Recipient recipient in collection)
            {
                if (recipient == null)
                {
                    throw new ArgumentNullException("recipient is null");
                }
                array2[num] = recipient.Participant;
                if (recipient.Participant.RoutingType == "EX" && !string.IsNullOrEmpty(recipient.Participant.EmailAddress))
                {
                    Participant cachedParticipant = EmailAddressConverter.GetCachedParticipant(recipient.Participant.EmailAddress);
                    array[num++] = ((cachedParticipant == null) ? recipient.Participant : cachedParticipant);
                }
                else
                {
                    array[num++] = recipient.Participant;
                }
            }
            ParticipantUpdater.GetSMTPAddressesForParticipantsIfNecessary(array, collection);
            for (int i = 0; i < array.Length; i++)
            {
                Participant participant  = array2[i];
                Participant participant2 = array[i];
                if (participant.RoutingType != participant2.RoutingType)
                {
                    EmailAddressConverter.CacheParticipant(participant.EmailAddress, participant2);
                }
            }
            StringBuilder stringBuilder = new StringBuilder(collection.Count * 100);
            int           num2          = 0;

            foreach (Recipient recipient2 in collection)
            {
                Participant participant3 = array[num2++];
                if (recipientItemType == RecipientItemType.Unknown || recipient2.RecipientItemType == recipientItemType)
                {
                    if (participant3.DisplayName.StartsWith("\"") && participant3.DisplayName.EndsWith("\""))
                    {
                        stringBuilder.Append(participant3.DisplayName);
                        stringBuilder.Append(" <");
                    }
                    else
                    {
                        stringBuilder.Append('"');
                        stringBuilder.Append(participant3.DisplayName);
                        stringBuilder.Append("\" ");
                    }
                    stringBuilder.Append(EmailAddressConverter.LookupEmailAddressString(participant3, exchangePrincipal, true));
                    stringBuilder.Append(", ");
                }
                if (stringBuilder.Length > 32000)
                {
                    break;
                }
            }
            if (stringBuilder.Length > 1)
            {
                stringBuilder.Length -= 2;
            }
            AirSyncDiagnostics.TraceInfo <StringBuilder>(ExTraceGlobals.CommonTracer, null, "GetRecipientString = {0}", stringBuilder);
            return(stringBuilder.ToString());
        }