Esempio n. 1
0
        public T GetRefTypePropValue <T>(PropertyDefinition propDefinition) where T : class
        {
            object obj = this.messageItem.TryGetProperty(propDefinition);

            SubmissionItemBase.LogPropError(obj);
            return(obj as T);
        }
Esempio n. 2
0
        public static T GetRefTypePropValue <T>(Recipient recipient, PropertyDefinition propDefinition) where T : class
        {
            object obj = recipient.TryGetProperty(propDefinition);

            SubmissionItemBase.LogPropError(obj);
            return(obj as T);
        }
Esempio n. 3
0
        public T GetPropValue <T>(PropertyDefinition propDefinition, T defaultValue) where T : struct
        {
            object obj = this.messageItem.TryGetProperty(propDefinition);

            SubmissionItemBase.LogPropError(obj);
            if (obj != null && obj is T)
            {
                return((T)((object)obj));
            }
            return(defaultValue);
        }
Esempio n. 4
0
        public T?GetValueTypePropValue <T>(PropertyDefinition propDefinition) where T : struct
        {
            object obj = this.messageItem.TryGetProperty(propDefinition);

            SubmissionItemBase.LogPropError(obj);
            if (obj == null || !(obj is T))
            {
                return(null);
            }
            return(new T?((T)((object)obj)));
        }
Esempio n. 5
0
        public static T?GetValueTypePropValue <T>(Recipient recipient, PropertyDefinition propDefinition) where T : struct
        {
            object obj = recipient.TryGetProperty(propDefinition);

            SubmissionItemBase.LogPropError(obj);
            if (obj == null || !(obj is T))
            {
                return(null);
            }
            return(new T?((T)((object)obj)));
        }
Esempio n. 6
0
        internal static void CopyRecipientPropsFromXSOToTransport(SubmissionItemBase submissionItem, Recipient recipient, MailRecipient transportRecipient, int?recipientType, string displayName)
        {
            if (!string.IsNullOrEmpty(displayName))
            {
                transportRecipient.ExtendedProperties.SetValue <string>("Microsoft.Exchange.MapiDisplayName", displayName);
            }
            if (recipientType != null)
            {
                transportRecipient.ExtendedProperties.SetValue <int>("Microsoft.Exchange.Transport.RecipientP2Type", recipientType.Value);
            }
            int?valueTypePropValue = SubmissionItemBase.GetValueTypePropValue <int>(recipient, ItemSchema.SendInternetEncoding);

            if (valueTypePropValue != null)
            {
                transportRecipient.ExtendedProperties.SetValue <int>("Microsoft.Exchange.Transport.ClientRequestedInternetEncoding", valueTypePropValue.Value);
            }
            bool?valueTypePropValue2 = SubmissionItemBase.GetValueTypePropValue <bool>(recipient, ItemSchema.SendRichInfo);

            if (valueTypePropValue2 != null)
            {
                transportRecipient.ExtendedProperties.SetValue <bool>("Microsoft.Exchange.Transport.ClientRequestedSendRichInfo", valueTypePropValue2.Value);
            }
            bool?valueTypePropValue3 = SubmissionItemBase.GetValueTypePropValue <bool>(recipient, MessageItemSchema.IsDeliveryReceiptRequested);

            if (valueTypePropValue3 == null)
            {
                valueTypePropValue3 = submissionItem.GetValueTypePropValue <bool>(MessageItemSchema.IsDeliveryReceiptRequested);
            }
            if (valueTypePropValue3.GetValueOrDefault())
            {
                transportRecipient.DsnRequested = (DsnRequestedFlags.Success | DsnRequestedFlags.Failure | DsnRequestedFlags.Delay);
            }
            bool?valueTypePropValue4 = SubmissionItemBase.GetValueTypePropValue <bool>(recipient, MessageItemSchema.IsNonDeliveryReceiptRequested);

            if (valueTypePropValue4 == null)
            {
                valueTypePropValue4 = submissionItem.GetValueTypePropValue <bool>(MessageItemSchema.IsNonDeliveryReceiptRequested);
            }
            if (valueTypePropValue4.GetValueOrDefault())
            {
                transportRecipient.DsnRequested |= DsnRequestedFlags.Failure;
            }
            bool?flag = new bool?(false);

            if ((valueTypePropValue3 == flag && valueTypePropValue4 == flag) || string.Equals(submissionItem.MessageClass, "ipm.replication", StringComparison.OrdinalIgnoreCase))
            {
                transportRecipient.DsnRequested = DsnRequestedFlags.Never;
            }
        }
Esempio n. 7
0
        public void DecorateMessage(TransportMailItem message)
        {
            message.HeloDomain           = ConfigurationProvider.GetDefaultDomainName();
            message.ReceiveConnectorName = "FromLocal";
            message.RefreshMimeSize();
            long       mimeSize = message.MimeSize;
            HeaderList headers  = message.RootPart.Headers;

            if (!(headers.FindFirst(HeaderId.Date) is DateHeader))
            {
                DateHeader newChild = new DateHeader("Date", DateTime.UtcNow.ToLocalTime());
                headers.AppendChild(newChild);
            }
            headers.RemoveAll(HeaderId.Received);
            DateHeader     dateHeader = new DateHeader("Date", DateTime.UtcNow.ToLocalTime());
            string         value      = dateHeader.Value;
            ReceivedHeader newChild2  = new ReceivedHeader(this.SourceServerFqdn, SubmissionItemBase.FormatIPAddress(this.SourceServerNetworkAddress), this.LocalIP.HostName, this.ReceivedHeaderTcpInfo, null, this.mailProtocol, SubmissionItemBase.serverVersion, null, value);

            headers.PrependChild(newChild2);
            message.ExtendedProperties.SetValue <bool>("Microsoft.Exchange.Transport.ElcJournalReport", this.IsElcJournalReport);
            if (this.IsMapiAdminSubmission)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Mapi-Admin-Submission", string.Empty));
            }
            if (this.IsDlExpansionProhibited)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-DL-Expansion-Prohibited", string.Empty));
            }
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Processed-By-MBTSubmission", string.Empty));
            if (ConfigurationProvider.GetForwardingProhibitedFeatureStatus() && this.IsAltRecipientProhibited)
            {
                headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Alt-Recipient-Prohibited", string.Empty));
            }
            headers.RemoveAll("X-MS-Exchange-Organization-OriginalSize");
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-OriginalSize", mimeSize.ToString(NumberFormatInfo.InvariantInfo)));
            headers.RemoveAll("X-MS-Exchange-Organization-OriginalArrivalTime");
            Header newChild3 = new AsciiTextHeader("X-MS-Exchange-Organization-OriginalArrivalTime", Util.FormatOrganizationalMessageArrivalTime(this.OriginalCreateTime));

            headers.AppendChild(newChild3);
            headers.RemoveAll("X-MS-Exchange-Organization-MessageSource");
            Header newChild4 = new AsciiTextHeader("X-MS-Exchange-Organization-MessageSource", "StoreDriver");

            headers.AppendChild(newChild4);
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Transport-FromEntityHeader", RoutingEndpoint.Hosted.ToString()));
            headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-FromEntityHeader", RoutingEndpoint.Hosted.ToString()));
            message.Directionality = MailDirectionality.Originating;
            message.UpdateDirectionalityAndScopeHeaders();
        }
Esempio n. 8
0
 internal static bool GetP2RecipientType(bool resubmittedMessage, Recipient recipient, out int?recipientType)
 {
     recipientType = SubmissionItemBase.GetValueTypePropValue <int>(recipient, ItemSchema.RecipientType);
     if (resubmittedMessage && recipientType != null && recipientType.Value == 268435456)
     {
         recipientType = new int?(0);
         TraceHelper.StoreDriverTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "PR_RECIPIENT_TYPE is MAPI_P1. This is a P1 (resent) recipient");
         return(true);
     }
     if (!SubmissionItemUtils.IsValidP2RecipientType(recipientType))
     {
         TraceHelper.StoreDriverTracer.TraceFail <int?>(TraceHelper.MessageProbeActivityId, 0L, "PR_RECIPIENT_TYPE for resubmitted message is not set or invalid: {0}. RecipientP2Type will be assumed to be \"Unknown\"", recipientType);
         recipientType = new int?(0);
     }
     TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "This is recipient is {0}", resubmittedMessage ? "a P2 (non-deliverable) recipient on resubmitted message" : "an ordinary recipient on an ordinary (non-resubmitted) message");
     return(!resubmittedMessage);
 }
Esempio n. 9
0
        internal static void CopySenderTo(SubmissionItemBase submissionItem, TransportMailItem message)
        {
            string messageClass = submissionItem.MessageClass;

            if (messageClass.StartsWith("IPM.Note.Rules.OofTemplate.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Note.Rules.ExternalOofTemplate.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Recall.Report.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Conflict.Message", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Conflict.Folder", StringComparison.OrdinalIgnoreCase))
            {
                TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Message class is {0}, setting <> as the P1 reverse path", submissionItem.MessageClass);
                message.From = RoutingAddress.NullReversePath;
                return;
            }
            RoutingAddress from;

            if (SubmissionItemUtils.TryGetRoutingAddressFromParticipant(message.ADRecipientCache, submissionItem.Sender, "Sender", out from))
            {
                message.From = from;
                return;
            }
            throw new InvalidSenderException(submissionItem.Sender);
        }
Esempio n. 10
0
        internal static int CopyRecipientsTo(SubmissionItemBase submissionItem, TransportMailItem mailItem, SubmissionRecipientHandler recipientHandler, ref List <string> unresolvableRecipients, ref List <string> notResponsibleRecipientsList, bool useParticipantSmtpEmailAddressIfNecessary, out List <string> participantSmtpEmailAddressBeneficiaries)
        {
            participantSmtpEmailAddressBeneficiaries = new List <string>();
            TraceHelper.StoreDriverTracer.TracePass <long>(TraceHelper.MessageProbeActivityId, 0L, "SubmissionItemUtils.CopyRecipientsTo: Copy recipients to mailitem {0}", mailItem.RecordId);
            bool resubmittedMessage = submissionItem.ResubmittedMessage;

            mailItem.ExtendedProperties.SetValue <bool>("Microsoft.Exchange.Transport.ResentMapiMessage", resubmittedMessage);
            List <MimeRecipient> list  = new List <MimeRecipient>();
            List <string>        list2 = null;
            List <string>        list3 = null;
            int num = 0;

            TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Copying recipients for {0} message", resubmittedMessage ? "resubmitted" : "regular");
            foreach (Recipient recipient in submissionItem.Recipients)
            {
                string emailAddress = recipient.Participant.EmailAddress;
                TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Processing recipient: {0}", emailAddress);
                int?           num2 = null;
                RoutingAddress arg;
                bool           flag;
                if (!SubmissionItemUtils.GetP2RecipientType(resubmittedMessage, recipient, out num2))
                {
                    TraceHelper.StoreDriverTracer.TracePass <int>(TraceHelper.MessageProbeActivityId, 0L, "SubmissionItemUtils.CopyRecipientsTo: Saving recipient type {0} of P2 recipient on resubmitted message", num2.Value);
                    SubmissionItemUtils.SaveP2Recipient(mailItem, emailAddress, num2.Value, ref list2, ref list3);
                }
                else if (!SubmissionItemBase.GetValueTypePropValue <bool>(recipient, ItemSchema.Responsibility).GetValueOrDefault())
                {
                    TraceHelper.StoreDriverTracer.TracePass <Participant>(TraceHelper.MessageProbeActivityId, 0L, "SubmissionItemUtils.CopyRecipientsTo: Skip recipient {0} since PR_RESPONSIBILITY is not true", recipient.Participant);
                    if (notResponsibleRecipientsList == null)
                    {
                        notResponsibleRecipientsList = new List <string>(1);
                    }
                    string item = SubmissionItemUtils.BuildParticipantString(recipient.Participant);
                    notResponsibleRecipientsList.Add(item);
                }
                else if (!SubmissionItemUtils.TryGetRoutingAddressFromParticipant(mailItem.ADRecipientCache, recipient.Participant, "Recipient", out arg, out flag, useParticipantSmtpEmailAddressIfNecessary))
                {
                    if (recipientHandler != null)
                    {
                        recipientHandler(num2, recipient, mailItem, null);
                    }
                    if (unresolvableRecipients == null)
                    {
                        unresolvableRecipients = new List <string>(1);
                    }
                    string text = SubmissionItemUtils.BuildParticipantString(recipient.Participant);
                    unresolvableRecipients.Add(text);
                    TraceHelper.StoreDriverTracer.TraceFail <string>(TraceHelper.MessageProbeActivityId, 0L, "SubmissionItemUtils.CopyRecipientsTo: Invalid recipient {0}", text);
                }
                else
                {
                    TraceHelper.StoreDriverTracer.TracePass <RoutingAddress, int?>(TraceHelper.MessageProbeActivityId, 0L, "Added recipient: {0}, Type: {1}", arg, num2);
                    string text2 = arg.ToString();
                    if (flag)
                    {
                        participantSmtpEmailAddressBeneficiaries.Add(text2);
                    }
                    MailRecipient mailRecipient = mailItem.Recipients.Add(text2);
                    num++;
                    if (recipientHandler != null)
                    {
                        recipientHandler(num2, recipient, mailItem, mailRecipient);
                    }
                    string refTypePropValue = SubmissionItemBase.GetRefTypePropValue <string>(recipient, StoreObjectSchema.DisplayName);
                    SubmissionItemUtils.CopyRecipientPropsFromXSOToTransport(submissionItem, recipient, mailRecipient, num2, refTypePropValue);
                    if (num2 != null && num2 == 3)
                    {
                        MimeRecipient item2 = new MimeRecipient(refTypePropValue, text2);
                        list.Add(item2);
                    }
                }
            }
            SubmissionItemUtils.AddExchangeOrganizationBccHeader(list, mailItem);
            if (list2 != null)
            {
                mailItem.ExtendedProperties.SetValue <List <string> >("Microsoft.Exchange.Transport.ResentMapiP2ToRecipients", list2);
            }
            if (list3 != null)
            {
                mailItem.ExtendedProperties.SetValue <List <string> >("Microsoft.Exchange.Transport.ResentMapiP2CcRecipients", list3);
            }
            return(num);
        }
Esempio n. 11
0
        internal static int CopyRecipientsTo(SubmissionItemBase submissionItem, TransportMailItem mailItem, SubmissionRecipientHandler recipientHandler, ref List <string> unresolvableRecipients, ref List <string> notResponsibleRecipientsList)
        {
            List <string> list;

            return(SubmissionItemUtils.CopyRecipientsTo(submissionItem, mailItem, recipientHandler, ref unresolvableRecipients, ref notResponsibleRecipientsList, false, out list));
        }