private void MessageTrackMailItem(TransportMailItem mailItem, IList <string> invalidRecipients)
        {
            MsgTrackReceiveInfo msgTrackInfo = new MsgTrackReceiveInfo(StoreDriverDelivery.LocalIPAddress, ((ulong)this.workItem.Rule.ID).ToString(), this.context.Message.InternetMessageId, mailItem.MessageTrackingSecurityInfo, invalidRecipients);

            if (mailItem.Recipients.Count == 0)
            {
                MessageTrackingLog.TrackReceive(MessageTrackingSource.MAILBOXRULE, mailItem, msgTrackInfo);
                this.context.TraceDebug("SmtpSubmissionItem: Rule generated mail without valid recipients");
                return;
            }
            if (this.context.ProcessingTestMessage)
            {
                this.context.TraceDebug("SmtpSubmissionItem: Do not commit rule generated message from diagnostic test message");
                return;
            }
            MessageTrackingLog.TrackReceive(MessageTrackingSource.MAILBOXRULE, mailItem, msgTrackInfo);
            this.context.TraceDebug <long>("SmtpSubmissionItem committed new message {0}", mailItem.RecordId);
        }
        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);
            }
        }