public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { MailItem mailItem = args.MailItem; StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; MessageItem item = storeDriverSubmissionEventArgsImpl.SubmissionItem.Item; if (ApprovalInitiation.IsArbitrationMailbox((ADRecipientCache <TransportMiniRecipient>)mailItem.RecipientCache, mailItem.FromAddress)) { item.Load(ApprovalSubmitterAgent.ModeratedTransportProperties); ApprovalStatus?valueAsNullable = item.GetValueAsNullable <ApprovalStatus>(MessageItemSchema.ApprovalStatus); string valueOrDefault = item.GetValueOrDefault <string>(MessageItemSchema.ApprovalDecisionMaker, string.Empty); if (valueAsNullable != null && (valueAsNullable.Value & ApprovalStatus.Approved) == ApprovalStatus.Approved) { TransportMailItem transportMailItem = ((TransportMailItemWrapper)mailItem).TransportMailItem; ModeratedTransportHandling.ResubmitApprovedMessage(item, transportMailItem, valueOrDefault); return; } if (ObjectClass.IsOfClass(item.ClassName, "IPM.Microsoft.Approval.Initiation") || ObjectClass.IsOfClass(item.ClassName, "IPM.Note.Microsoft.Approval.Request.Recall")) { Header header = (TextHeader)Header.Create("X-MS-Exchange-Organization-Do-Not-Journal"); header.Value = "ArbitrationMailboxSubmission"; mailItem.MimeDocument.RootPart.Headers.AppendChild(header); Header newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Approval-Initiator", "mapi"); mailItem.MimeDocument.RootPart.Headers.AppendChild(newChild); } } }
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(); }
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); }