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);
            }
        }
Exemple #3
0
 internal void CheckAndSubmitMfn(TransportMailItem originalMailItem)
 {
     if (!this.ShouldGenerateMfn())
     {
         return;
     }
     using (MeetingRequest meetingRequest = MeetingRequest.Bind(this.item.Session, this.item.Item.Id))
     {
         using (MeetingForwardNotification meetingForwardNotification = meetingRequest.CreateNotification())
         {
             TransportMailItem transportMailItem = TransportMailItem.NewSideEffectMailItem(originalMailItem, this.submitter.OrganizationId, LatencyComponent.Agent, MailDirectionality.Originating, this.submitter.ExternalOrganizationId);
             transportMailItem.From = RoutingAddress.NullReversePath;
             if (this.TryCreateMfnSubjectAndBody(meetingForwardNotification))
             {
                 Stream stream = transportMailItem.OpenMimeWriteStream();
                 stream.Close();
                 this.CopyMfnRecipientsTo(meetingForwardNotification, transportMailItem);
                 this.CopyMfnContentTo(meetingForwardNotification, transportMailItem);
                 MailboxSession mailboxSession = this.item.Item.Session as MailboxSession;
                 Participant    participant    = Participant.TryConvertTo(this.item.Sender, "SMTP", mailboxSession);
                 if (participant == null)
                 {
                     participant = this.item.Sender;
                 }
                 if (mailboxSession != null)
                 {
                     MfnLog.LogEntry(mailboxSession, string.Format("Decorating MFN with the address - Name {0}, EmailAddress : {1}, RoutingType : {2}", participant.DisplayName, participant.EmailAddress, participant.RoutingType));
                 }
                 Components.DsnGenerator.DecorateMfn(transportMailItem, participant.DisplayName, participant.EmailAddress);
                 this.item.DecorateMessage(transportMailItem);
                 this.item.ApplySecurityAttributesTo(transportMailItem);
                 ClassificationUtils.PromoteStoreClassifications(transportMailItem.RootPart.Headers);
                 this.submitter.StoreDriverSubmission.ThrowIfStopped();
                 transportMailItem.UpdateCachedHeaders();
                 this.submitter.SendMailItem(new SubmissionReadOnlyMailItem(transportMailItem, MailItemType.OtherMessage), null);
             }
         }
     }
 }