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 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); }
private void AddUnparkedHeader(HeaderList headers, Guid messageId) { headers.RemoveAll("X-MS-Exchange-Calendar-Series-Instance-Unparked"); Header header = Header.Create("X-MS-Exchange-Calendar-Series-Instance-Unparked"); header.Value = messageId.ToString(); headers.AppendChild(header); }
internal static void SetProperty(HeaderList mimeHeaders, string name, string value) { mimeHeaders.RemoveAll(name); if (!string.IsNullOrEmpty(value)) { mimeHeaders.AppendChild(new TextHeader(name, value)); } }
private void CacheInstanceId(HeaderList headers, StoreId instanceCalendarItemId) { Header header = headers.FindFirst("X-MS-Exchange-Calendar-Series-Instance-Calendar-Item-Id"); if (header == null) { header = Header.Create("X-MS-Exchange-Calendar-Series-Instance-Calendar-Item-Id"); headers.AppendChild(header); } header.Value = StoreId.GetStoreObjectId(instanceCalendarItemId).ToBase64String(); }
private static void AddExchangeOrganizationBccHeader(List <MimeRecipient> bccRecipientList, TransportMailItem mailItem) { AddressHeader addressHeader = new AddressHeader("X-MS-Exchange-Organization-BCC"); foreach (MimeRecipient newChild in bccRecipientList) { addressHeader.AppendChild(newChild); } HeaderList headers = mailItem.Message.MimeDocument.RootPart.Headers; headers.AppendChild(addressHeader); }
public static void CopyHeaderBetweenList(HeaderList sourceHeaderList, HeaderList targetHeaderList, string headerName, bool onlyWriteFirstHeader) { Header header = sourceHeaderList.FindFirst(headerName); while (header != null) { if (onlyWriteFirstHeader) { Header header2 = targetHeaderList.FindFirst(headerName); if (header2 != null) { header2.Value = header.Value; return; } targetHeaderList.AppendChild(header.Clone()); return; } else { targetHeaderList.AppendChild(header.Clone()); header = sourceHeaderList.FindNext(header); } } }