private void SetEnvelopeRecipients(TransportMailItem mailItem, IEnumerable <Participant> recipients, ref IList <string> invalidAddresses) { this.context.TraceDebug <long>("SmtpSubmissionItem.SetEnvelopeRecipients: Setting envelope recipients on mailitem {0}", mailItem.RecordId); foreach (Participant participant in recipients) { RoutingAddress argument; if (participant == null) { this.context.TraceError("SmtpSubmissionItem.SetEnvelopeRecipients: Null participant found in recipient list."); } else if (SubmissionItemUtils.TryGetRoutingAddress(mailItem.ADRecipientCache, participant.EmailAddress, participant.RoutingType, "SmtpSubmissionItem.SetEnvelopeRecipients", out argument)) { this.context.TraceDebug <RoutingAddress>("SmtpSubmissionItem.SetEnvelopeRecipients: Added envelope recipient: {0}", argument); mailItem.Recipients.Add(argument.ToString()); } else { if (invalidAddresses == null) { invalidAddresses = new List <string>(1); } string item = SubmissionItemUtils.BuildParticipantString(participant); invalidAddresses.Add(item); this.context.TraceError <string, string, string>("SmtpSubmissionItem.SetEnvelopeRecipients: Could not get routing address for \"{0}\" / \"{1}:{2}\"", participant.DisplayName, participant.RoutingType, participant.EmailAddress); } } }
public static void SubmitMailItem(TransportMailItem mailItem, bool suppressDSNs) { try { TraceHelper.StoreDriverDeliveryTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Start sending email generated by delivery agent."); if (suppressDSNs) { foreach (MailRecipient mailRecipient in mailItem.Recipients) { mailRecipient.DsnRequested = DsnRequestedFlags.Never; } } SmtpMailItemResult smtpMailItemResult = SmtpMailItemSender.Instance.Send(new MbxTransportMailItem(mailItem)); if (smtpMailItemResult.ConnectionResponse.AckStatus != AckStatus.Success || smtpMailItemResult.MessageResponse.AckStatus != AckStatus.Success) { TraceHelper.StoreDriverDeliveryTracer.TraceFail <AckStatus, AckStatus>(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Failure sending email generated by delivery agent. ConnectionResponse {0} MessageResponse {1}", smtpMailItemResult.ConnectionResponse.AckStatus, smtpMailItemResult.MessageResponse.AckStatus); throw new StoreDriverAgentTransientException(Strings.StoreDriverAgentTransientExceptionEmail); } SubmitHelper.AgentMessageCounter.AddValue(1L); } catch (Exception ex) { TraceHelper.StoreDriverDeliveryTracer.TraceFail <string>(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Failure sending email generated by delivery agent. Error {0}", ex.ToString()); throw new StoreDriverAgentTransientException(Strings.StoreDriverAgentTransientExceptionEmail, ex); } TraceHelper.StoreDriverDeliveryTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Completed sending email generated by delivery agent."); }
internal static bool ResubmitApprovedMessage(MessageItem messageItem, TransportMailItem transportMailItem, string approverAddress) { DateTime utcNow = DateTime.UtcNow; HeaderList headerList = (transportMailItem.RootPart != null) ? transportMailItem.RootPart.Headers : null; if (!ModerationHelper.RestoreOriginalMessage(messageItem, transportMailItem, TraceHelper.ModeratedTransportTracer, TraceHelper.MessageProbeActivityId)) { return(false); } transportMailItem.RootPart.Headers.RemoveAll("X-MS-Exchange-Organization-Approval-Approved"); TextHeader textHeader = (TextHeader)Header.Create("X-MS-Exchange-Organization-Approval-Approved"); textHeader.Value = (string)transportMailItem.Recipients[0].Email; foreach (MailRecipient mailRecipient in transportMailItem.Recipients) { if (mailRecipient.Status == Status.Ready) { textHeader.Value = (string)mailRecipient.Email; break; } } transportMailItem.RootPart.Headers.AppendChild(textHeader); if (transportMailItem.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-Moderation-SavedArrivalTime") == null) { Header header = transportMailItem.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-OriginalArrivalTime"); string value = null; if (header != null) { value = header.Value; } if (!string.IsNullOrEmpty(value)) { transportMailItem.RootPart.Headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-Moderation-SavedArrivalTime", value)); } } TextHeader textHeader2 = (TextHeader)Header.Create("X-Moderation-Data"); ExDateTime?valueAsNullable = messageItem.GetValueAsNullable <ExDateTime>(MessageItemSchema.ApprovalDecisionTime); if (valueAsNullable != null) { textHeader2.Value = valueAsNullable.ToString(); transportMailItem.RootPart.Headers.AppendChild(textHeader2); } if (headerList != null) { Header[] array = headerList.FindAll(HeaderId.Received); foreach (Header header2 in array) { Header header3 = Header.Create(HeaderId.Received); header2.CopyTo(header3); transportMailItem.RootPart.Headers.PrependChild(header3); } } transportMailItem.RootPart.Headers.RemoveAll("X-MS-Exchange-Organization-OriginalArrivalTime"); transportMailItem.RootPart.Headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-OriginalArrivalTime", Util.FormatOrganizationalMessageArrivalTime(utcNow))); transportMailItem.UpdateDirectionalityAndScopeHeaders(); transportMailItem.UpdateCachedHeaders(); MessageTrackingLog.TrackReceiveForApprovalRelease(transportMailItem, approverAddress, messageItem.InternetMessageId); return(true); }
private void SubmitMailItem(TransportMailItem mailItem, IList <string> invalidRecipients) { this.SetGeneratedByRulePropertyIfNecessary(mailItem); this.MessageTrackMailItem(mailItem, invalidRecipients); if (this.context.ProcessingTestMessage) { this.context.TraceDebug("SubmitMailItem: Do not enqueue rule generated message from diagnostic test message"); return; } if (mailItem.Recipients.Count == 0) { this.context.TraceDebug("SubmitMailItem: Skipping submission since there are no recipients"); return; } for (int i = 1; i <= 3; i++) { try { this.context.Server.SubmitMailItem(mailItem, false); break; } catch (StoreDriverAgentTransientException ex) { this.context.TraceDebug(string.Format(CultureInfo.InvariantCulture, "SubmitMailItem: Encountered StoreDriverAgentTransientException on attempt {0} of {1}: {2}", new object[] { i, 3, ex })); } } }
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 static void SaveP2Recipient(TransportMailItem mailItem, string recipientAddress, int recipientType, ref List <string> mapiToRecipients, ref List <string> mapiCcRecipients) { List <string> list; if (recipientType == 1) { if (mapiToRecipients == null) { mapiToRecipients = new List <string>(); } list = mapiToRecipients; } else { if (recipientType != 2) { TraceHelper.StoreDriverTracer.TraceFail <int>(TraceHelper.MessageProbeActivityId, 0L, "Error, recipient type of MAPI_P2 recipient was not To or Cc: {0}", recipientType); return; } if (mapiCcRecipients == null) { mapiCcRecipients = new List <string>(); } list = mapiCcRecipients; } int num = list.BinarySearch(recipientAddress, StringComparer.OrdinalIgnoreCase); if (num < 0) { num = ~num; } list.Insert(num, recipientAddress); }
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 override void SubmitMailItem(TransportMailItem mailItem, bool suppressDSNs) { StoreDriverDeliveryEventArgs storeDriverDeliveryEventArgs = null; if (base.AssociatedAgent != null && base.AssociatedAgent.Session != null && base.AssociatedAgent.Session.CurrentEventArgs != null) { storeDriverDeliveryEventArgs = (base.AssociatedAgent.Session.CurrentEventArgs as StoreDriverDeliveryEventArgs); } bool flag = this.agentLoopChecker.IsEnabledInSubmission(); bool flag2 = false; if (storeDriverDeliveryEventArgs != null && !string.IsNullOrEmpty(base.AssociatedAgent.Name)) { flag2 = this.agentLoopChecker.CheckAndStampInSubmission(storeDriverDeliveryEventArgs.MailItem.Message.RootPart.Headers, mailItem.RootPart.Headers, base.AssociatedAgent.Name); if (flag2) { MessageTrackingLog.TrackAgentGeneratedMessageRejected(MessageTrackingSource.STOREDRIVER, flag, mailItem); } } if (flag2 && flag) { using (IEnumerator <MailRecipient> enumerator = mailItem.Recipients.GetEnumerator()) { while (enumerator.MoveNext()) { MailRecipient mailRecipient = enumerator.Current; mailRecipient.Ack(AckStatus.Fail, SmtpResponse.AgentGeneratedMessageDepthExceeded); } return; } } Utils.SubmitMailItem(mailItem, suppressDSNs); }
// Token: 0x06000013 RID: 19 RVA: 0x000028BA File Offset: 0x00000ABA private SmtpResponse HandleAcceptedMessage(TransportMailItem mailItem) { if (mailItem == null) { throw new ArgumentNullException("mailItem", "TransportMailItem is null"); } return(Components.StoreDriverDelivery.DoLocalDelivery(mailItem)); }
private void RecipientHandler(int?recipientType, Recipient recipient, TransportMailItem mailItem, MailRecipient mailRecipient) { if (mailRecipient == null) { Participant participant = recipient.Participant; this.context.TraceError <string, string, string>("SmtpSubmissionItem.RecipientHandler: Could not get routing address for \"{0}\" / \"{1}:{2}\"", participant.DisplayName, participant.RoutingType, participant.EmailAddress); } }
// Token: 0x0600001E RID: 30 RVA: 0x0000341E File Offset: 0x0000161E public void OnSubmit(TransportMailItem item, MailDirectionality directionality, PickupType pickupType) { if (directionality != MailDirectionality.Undefined) { item.Directionality = directionality; } item.CommitImmediate(); Components.CategorizerComponent.EnqueueSubmittedMessage(item); }
public bool WriteMessage(TransportMailItem mailItem, IEnumerable <MailRecipient> recipients, out SmtpResponse smtpResponse, out string exceptionMessage) { Stream stream = null; bool result = false; exceptionMessage = null; smtpResponse = SmtpResponse.NoopOk; try { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("{0}-{1}-{2}.{3}.eml", new object[] { Environment.MachineName, mailItem.RecordId, DateTime.UtcNow.ToString("yyyyMMddHHmmssZ", DateTimeFormatInfo.InvariantInfo), ((IQueueItem)mailItem).Priority }); string path = Path.Combine(this.dropDirectory, stringBuilder.ToString()); if (!ExportStream.TryCreate(mailItem, recipients, true, out stream) || stream == null) { throw new InvalidOperationException("Failed to create an export stream because there were no ready recipients"); } using (stream) { using (FileStream fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.Write, FileShare.None)) { stream.Position = 0L; for (;;) { int num = stream.Read(this.buffer, 0, 65536); if (num == 0) { break; } fileStream.Write(this.buffer, 0, num); } } } result = true; } catch (PathTooLongException) { smtpResponse = AckReason.GWPathTooLongException; } catch (IOException ex) { exceptionMessage = ex.Message; smtpResponse = AckReason.GWIOException; } catch (UnauthorizedAccessException) { smtpResponse = AckReason.GWUnauthorizedAccess; } return(result); }
public void Submit(ProxyAddress sender, IEnumerable <Participant> recipients) { TransportMailItem mailItem = this.CreateMailItem(); this.SetEnvelopeSender(mailItem, sender); IList <string> invalidRecipients = null; this.SetEnvelopeRecipients(mailItem, recipients, ref invalidRecipients); this.ValidateRecipientCollections(mailItem, invalidRecipients); this.SubmitMailItem(mailItem, invalidRecipients); }
public override void SubmitMessage(IReadOnlyMailItem originalMailItem, EmailMessage message, OrganizationId organizationId, Guid externalOrganizationId, bool suppressDSNs) { try { TransportMailItem mailItem = SubmitHelper.CreateTransportMailItem(originalMailItem, message, this.Name, this.Version, (base.AssociatedAgent != null) ? base.AssociatedAgent.Name : "StoreDriverServer", null, null, organizationId, externalOrganizationId, false); this.SubmitMailItem(mailItem, suppressDSNs); } catch (Exception innerException) { throw new StoreDriverAgentTransientException(Strings.StoreDriverAgentTransientExceptionEmail, innerException); } }
public void Submit() { TransportMailItem transportMailItem = this.CreateMailItem(); SubmissionItemUtils.CopySenderTo(this, transportMailItem); List <string> invalidRecipients = null; List <string> list = null; SubmissionItemUtils.CopyRecipientsTo(this, transportMailItem, new SubmissionRecipientHandler(this.RecipientHandler), ref invalidRecipients, ref list); this.ValidateRecipientCollections(transportMailItem, invalidRecipients); this.SubmitMailItem(transportMailItem, invalidRecipients); }
private void SetEnvelopeSender(TransportMailItem mailItem, ProxyAddress sender) { RoutingAddress routingAddress; if (!SubmissionItemUtils.TryGetRoutingAddress(mailItem.ADRecipientCache, sender.AddressString, sender.PrefixString, "SmtpSubmissionItem.SetEnvelopeSender", out routingAddress)) { this.context.TraceError <string>("SmtpSubmissionItem.SetEnvelopeSender: Could not get routing address for sender {0}.", sender.ToString()); throw new InvalidSenderException(sender); } this.context.TraceDebug <RoutingAddress>("SmtpSubmissionItem.SetEnvelopeSender: Setting envelope sender: {0}", routingAddress); mailItem.From = routingAddress; mailItem.MimeSender = routingAddress; }
private void ValidateRecipientCollections(TransportMailItem mailItem, IList <string> invalidRecipients) { if (this.IsGeneratingReply()) { return; } if ((invalidRecipients != null && invalidRecipients.Count > 0) || mailItem.Recipients.Count == 0) { Rule rule = this.workItem.Rule; RuleAction.Type actionType = this.workItem.Rule.Actions[this.workItem.ActionIndex].ActionType; int actionIndex = this.workItem.ActionIndex; this.context.MarkRuleInError(rule, actionType, actionIndex, DeferredError.RuleError.Execution); } }
private static bool SilentlyDropProbeMessages(TransportMailItem transportMailItem) { Header header = transportMailItem.RootPart.Headers.FindFirst("X-Exchange-Probe-Drop-Message"); if (header != null && header.Value == "MailboxTransportDelivery-SDD-250") { StoreDriverDeliveryDiagnostics.Diag.TraceDebug <string, string, string>(0L, "Email '{0}' will be dropped because header '{1}' with value '{2}' was detected", transportMailItem.InternetMessageId ?? "not available", "X-Exchange-Probe-Drop-Message", "MailboxTransportDelivery-SDD-250"); Queue <AckStatusAndResponse> queue = new Queue <AckStatusAndResponse>(); queue.Enqueue(new AckStatusAndResponse(AckStatus.SuccessNoDsn, SmtpResponse.ProbeMessageDropped)); transportMailItem.Ack(AckStatus.SuccessNoDsn, SmtpResponse.ProbeMessageDropped, transportMailItem.Recipients, queue); return(true); } return(false); }
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 static void ResolveItemRecipients(TransportMailItem item) { try { List <ProxyAddress> list = new List <ProxyAddress>(item.Recipients.Count); foreach (MailRecipient mailRecipient in item.Recipients) { list.Add(new SmtpProxyAddress((string)mailRecipient.Email, false)); } item.ADRecipientCache.FindAndCacheRecipients(list); } catch (ADTransientException exception) { throw new RetryException(new MessageStatus(MessageAction.Retry, AckReason.NotResolvedRecipient, exception)); } }
public void ApplySecurityAttributesTo(TransportMailItem mailitem) { TransportConfigContainer transportConfigObject = Configuration.TransportConfigObject; if (this.GetPropValue <bool>(MessageItemSchema.ClientSubmittedSecurely, false)) { MultilevelAuth.EnsureSecurityAttributes(mailitem, SubmitAuthCategory.Internal, MultilevelAuthMechanism.SecureMapiSubmit, null); return; } if (transportConfigObject.VerifySecureSubmitEnabled) { MultilevelAuth.EnsureSecurityAttributes(mailitem, SubmitAuthCategory.Anonymous, MultilevelAuthMechanism.MapiSubmit, null); return; } MultilevelAuth.EnsureSecurityAttributes(mailitem, SubmitAuthCategory.Internal, MultilevelAuthMechanism.MapiSubmit, null); }
internal virtual void AckMailItem(AckStatus ackStatus, SmtpResponse smtpResponse, AckDetails ackDetails, TimeSpan?retryInterval, string messageTrackingSourceContext) { if (ackStatus == AckStatus.Retry && smtpResponse.SmtpResponseType != SmtpResponseType.TransientError) { smtpResponse = TransportMailItem.ReplaceFailWithRetryResponse(smtpResponse); } this.mailItem.Ack(ackStatus, smtpResponse, this.GetRecipients(), this.recipientResponses); this.FinalizeDeliveryLatencyTracking(LatencyComponent.StoreDriverDelivery); this.mailItemResponse = SmtpResponseGenerator.GenerateResponse(this.MessageLevelAction, this.Recipients, smtpResponse, retryInterval); foreach (MailRecipient mailRecipient in this.Recipients) { if (mailRecipient.ExtendedProperties.Contains("ExceptionAgentName")) { mailRecipient.ExtendedProperties.Remove("ExceptionAgentName"); } } }
public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; if (MfnSubmitterAgent.ShouldGenerateMfn(storeDriverSubmissionEventArgsImpl.SubmissionItem.MessageClass)) { using (MfnSubmitter mfnSubmitter = new MfnSubmitter(storeDriverSubmissionEventArgsImpl.SubmissionItem, storeDriverSubmissionEventArgsImpl.MailItemSubmitter)) { TransportMailItem originalMailItem = null; TransportMailItemWrapper transportMailItemWrapper = args.MailItem as TransportMailItemWrapper; if (transportMailItemWrapper != null) { originalMailItem = transportMailItemWrapper.TransportMailItem; } mfnSubmitter.CheckAndSubmitMfn(originalMailItem); } } }
public TimeSpan CopyContentTo(TransportMailItem mailItem) { this.ConversionOptions.RecipientCache = mailItem.ADRecipientCache; this.ConversionOptions.UserADSession = mailItem.ADRecipientCache.ADSession; mailItem.CacheTransportSettings(); this.ConversionOptions.ClearCategories = mailItem.TransportSettings.ClearCategories; this.ConversionOptions.UseRFC2231Encoding = mailItem.TransportSettings.Rfc2231EncodingEnabled; this.ConversionOptions.AllowDlpHeadersToPenetrateFirewall = true; this.storeDriverTracer.StoreDriverCommonTracer.TracePass <long>(this.storeDriverTracer.MessageProbeActivityId, 0L, "Generate content for mailitem {0}", mailItem.RecordId); ExDateTime utcNow = ExDateTime.UtcNow; using (Stream stream = mailItem.OpenMimeWriteStream(MimeLimits.Default)) { this.conversionResult = ItemConversion.ConvertItemToSummaryTnef(this.messageItem, stream, this.ConversionOptions); stream.Flush(); } return(ExDateTime.UtcNow - utcNow); }
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); }
internal static void CopySenderTo(SubmissionItemBase submissionItem, TransportMailItem message) { string messageClass = submissionItem.MessageClass; if (messageClass.StartsWith("IPM.Note.Rules.OofTemplate.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Note.Rules.ExternalOofTemplate.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Recall.Report.", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Conflict.Message", StringComparison.OrdinalIgnoreCase) || messageClass.StartsWith("IPM.Conflict.Folder", StringComparison.OrdinalIgnoreCase)) { TraceHelper.StoreDriverTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Message class is {0}, setting <> as the P1 reverse path", submissionItem.MessageClass); message.From = RoutingAddress.NullReversePath; return; } RoutingAddress from; if (SubmissionItemUtils.TryGetRoutingAddressFromParticipant(message.ADRecipientCache, submissionItem.Sender, "Sender", out from)) { message.From = from; return; } throw new InvalidSenderException(submissionItem.Sender); }
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); } }
public static bool CopySenderAndRecipientsFromHeaders(string headers, TransportMailItem mailItem) { if (string.IsNullOrEmpty(headers)) { TraceHelper.MapiStoreDriverSubmissionTracer.TracePass(TraceHelper.MessageProbeActivityId, 0L, "DAV header is not present."); return(false); } try { DavHeader davHeader = new DavHeader(headers); davHeader.Parse(); davHeader.CopyTo(mailItem); return(true); } catch (FormatException arg) { TraceHelper.MapiStoreDriverSubmissionTracer.TracePass <FormatException>(TraceHelper.MessageProbeActivityId, 0L, "Parsing Error: {0}", arg); } return(false); }
private void SetGeneratedByRulePropertyIfNecessary(TransportMailItem mailItem) { if (OrganizationId.ForestWideOrgId.Equals(mailItem.OrganizationId)) { this.context.TraceDebug <string>("Skip setting {0} property because we are in Enterprise environment.", "Microsoft.Exchange.Transport.GeneratedByMailboxRule"); return; } if (mailItem.Recipients.Count == 0) { this.context.TraceDebug <string, string>("Skip setting {0} property because there were no recipients on the generated message. RuleName={1}", "Microsoft.Exchange.Transport.GeneratedByMailboxRule", this.context.CurrentRule.Name); return; } string text = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[] { this.context.Recipient.AddressString, this.context.CurrentRule.Name }); this.context.TraceDebug <string, string>("Set {0} property to value {1}", "Microsoft.Exchange.Transport.GeneratedByMailboxRule", text); mailItem.ExtendedProperties.SetValue <string>("Microsoft.Exchange.Transport.GeneratedByMailboxRule", text); }
public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { if (SubmissionConfiguration.Instance.App.EnableUnparkedMessageRestoring) { MailItem mailItem = args.MailItem; StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; MessageItem item = storeDriverSubmissionEventArgsImpl.SubmissionItem.Item; StoreSession session = storeDriverSubmissionEventArgsImpl.SubmissionItem.Session; if (ObjectClass.IsParkedMeetingMessage(storeDriverSubmissionEventArgsImpl.SubmissionItem.MessageClass)) { DateTime utcNow = DateTime.UtcNow; TransportMailItem transportMailItem = ((TransportMailItemWrapper)mailItem).TransportMailItem; ModerationHelper.RestoreOriginalMessage(item, transportMailItem, TraceHelper.ParkedItemSubmitterAgentTracer, TraceHelper.MessageProbeActivityId); transportMailItem.RootPart.Headers.RemoveAll("X-MS-Exchange-Organization-OriginalArrivalTime"); transportMailItem.RootPart.Headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-OriginalArrivalTime", Util.FormatOrganizationalMessageArrivalTime(utcNow))); transportMailItem.ExtendedProperties.Clear(); transportMailItem.UpdateDirectionalityAndScopeHeaders(); transportMailItem.UpdateCachedHeaders(); } } }