Exemplo n.º 1
0
        private TransportMailItem CreateMailItem()
        {
            TransportMailItem transportMailItem = TransportMailItem.NewSideEffectMailItem(this.context.MbxTransportMailItem, this.context.RecipientCache.OrganizationId, LatencyComponent.MailboxRules, MailDirectionality.Originating, this.context.MbxTransportMailItem.ExternalOrganizationId);

            base.CopyContentTo(transportMailItem);
            base.DecorateMessage(transportMailItem);
            base.ApplySecurityAttributesTo(transportMailItem);
            transportMailItem.PrioritizationReason = this.context.PrioritizationReason;
            transportMailItem.Priority             = this.context.Priority;
            ClassificationUtils.PromoteStoreClassifications(transportMailItem.RootPart.Headers);
            SubmissionItemUtils.PatchQuarantineSender(transportMailItem, base.QuarantineOriginalSender);
            HeaderList headers = transportMailItem.RootPart.Headers;

            if (headers.FindFirst(HeaderId.MessageId) == null)
            {
                headers.AppendChild(new AsciiTextHeader("Message-Id", string.Concat(new string[]
                {
                    "<",
                    Guid.NewGuid().ToString("N"),
                    "@",
                    this.SourceServerFqdn,
                    ">"
                })));
            }
            MimeInternalHelpers.CopyHeaderBetweenList(this.context.RootPart.Headers, headers, "X-MS-Exchange-Moderation-Loop");
            transportMailItem.UpdateCachedHeaders();
            return(transportMailItem);
        }
        public void Submit(MessageTrackingSource messageTrackingSource, MemorySubmissionItem.OnConvertedToTransportMailItemDelegate transportMailItemHandler, MbxTransportMailItem relatedMailItem)
        {
            TransportMailItem transportMailItem;

            if (relatedMailItem == null)
            {
                transportMailItem = TransportMailItem.NewMailItem(this.organizationId, LatencyComponent.StoreDriverSubmit, MailDirectionality.Originating, default(Guid));
            }
            else
            {
                transportMailItem = TransportMailItem.NewSideEffectMailItem(relatedMailItem, this.organizationId, LatencyComponent.StoreDriverSubmit, MailDirectionality.Originating, relatedMailItem.ExternalOrganizationId);
            }
            base.CopyContentTo(transportMailItem);
            base.DecorateMessage(transportMailItem);
            base.ApplySecurityAttributesTo(transportMailItem);
            if (relatedMailItem != null)
            {
                transportMailItem.PrioritizationReason = relatedMailItem.PrioritizationReason;
                transportMailItem.Priority             = relatedMailItem.Priority;
            }
            SubmissionItemUtils.CopySenderTo(this, transportMailItem);
            List <string> invalidRecipients = null;
            List <string> list = null;

            SubmissionItemUtils.CopyRecipientsTo(this, transportMailItem, null, ref invalidRecipients, ref list);
            ClassificationUtils.PromoteStoreClassifications(transportMailItem.RootPart.Headers);
            SubmissionItemUtils.PatchQuarantineSender(transportMailItem, base.QuarantineOriginalSender);
            bool flag = transportMailItem.Recipients.Count > 0;

            if (relatedMailItem != null)
            {
                MimeInternalHelpers.CopyHeaderBetweenList(relatedMailItem.RootPart.Headers, transportMailItem.RootPart.Headers, "X-MS-Exchange-Moderation-Loop");
            }
            bool flag2 = transportMailItemHandler(transportMailItem, flag);

            if (flag && flag2)
            {
                MsgTrackReceiveInfo msgTrackInfo = new MsgTrackReceiveInfo(StoreDriverDelivery.LocalIPAddress, (relatedMailItem != null) ? new long?(relatedMailItem.RecordId) : null, transportMailItem.MessageTrackingSecurityInfo, invalidRecipients);
                MessageTrackingLog.TrackReceive(messageTrackingSource, transportMailItem, msgTrackInfo);
                Utils.SubmitMailItem(transportMailItem, false);
            }
        }