private void ApplyTestMessageHeaders()
        {
            HeaderList      headers = this.message.RootPart.Headers;
            string          value   = string.Empty;
            AsciiTextHeader newChild;

            if (this.WasSpecifiedByUser("Options"))
            {
                newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message-Options", this.Options);
                headers.PrependChild(newChild);
            }
            if (this.WasSpecifiedByUser("SendReportTo"))
            {
                value    = this.SendReportTo.ToString();
                newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message-Send-Report-To", value);
                headers.PrependChild(newChild);
            }
            if (this.WasSpecifiedByUser("Arbitration"))
            {
                newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message-Log-For", this.arbitrationLogHeaderValue);
            }
            else if (this.WasSpecifiedByUser("TransportRules"))
            {
                newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message-Log-For", this.transportRulesLogHeaderValue);
            }
            else
            {
                newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message-Log-For", this.inboxRulesLogHeaderValue);
            }
            headers.PrependChild(newChild);
            value = "Supress";
            if (this.WasSpecifiedByUser("DeliverMessage") || this.WasSpecifiedByUser("Arbitration"))
            {
                value = "Deliver";
            }
            newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Test-Message", value);
            headers.PrependChild(newChild);
        }
Exemple #2
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();
        }