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 OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailRecipient mailRecipient = storeDriverDeliveryEventArgsImpl.MailRecipient; DeliverableMailItem mailItem = storeDriverDeliveryEventArgsImpl.MailItem; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; bool flag = false; bool flag2 = ApprovalInitiation.IsArbitrationMailbox(mbxTransportMailItem.ADRecipientCache, mailRecipient.Email); if (!flag2 && string.Equals(messageItem.ClassName, "IPM.Note.Microsoft.Approval.Request.Recall", StringComparison.OrdinalIgnoreCase)) { flag = true; } EmailMessage message = mailItem.Message; TestMessageConfig testMessageConfig = new TestMessageConfig(message); if (testMessageConfig.IsTestMessage && (testMessageConfig.LogTypes & LogTypesEnum.Arbitration) != LogTypesEnum.None) { EmailMessage emailMessage = ArbitrationMailboxReport.GenerateContentReport(new SmtpAddress(mailRecipient.Email.ToString()), testMessageConfig.ReportToAddress, messageItem.Session, flag2); if (emailMessage != null) { ApprovalProcessingAgent.diag.TraceDebug(0L, "Submit arbitration mailbox content report message"); this.server.SubmitMessage(mbxTransportMailItem, emailMessage, mbxTransportMailItem.OrganizationId, mbxTransportMailItem.ExternalOrganizationId, false); } else { ApprovalProcessingAgent.diag.TraceDebug(0L, "Failed to generate arbitration mailbox content report"); } throw new SmtpResponseException(AckReason.ApprovalUpdateSuccess, base.Name); } if (!flag) { if (flag2) { ApprovalEngine approvalEngineInstance = ApprovalEngine.GetApprovalEngineInstance(message, (RoutingAddress)message.From.SmtpAddress, mailRecipient.Email, messageItem, mbxTransportMailItem, ApprovalProcessingAgent.MessageItemCreationDelegate); ApprovalEngine.ApprovalProcessResults resultInfo = approvalEngineInstance.ProcessMessage(); this.HandleResults(resultInfo, messageItem, mbxTransportMailItem, mailRecipient); } return; } if (!MultilevelAuth.IsInternalMail(message)) { return; } if (ApprovalRequestUpdater.Result.InvalidUpdateMessage == ApprovalRequestUpdater.TryUpdateExistingApprovalRequest(messageItem)) { throw new SmtpResponseException(AckReason.ApprovalInvalidMessage); } throw new SmtpResponseException(AckReason.ApprovalUpdateSuccess, base.Name); }
public void OnDeliveredMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailRecipient mailRecipient = storeDriverDeliveryEventArgsImpl.MailRecipient; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; if (!ApprovalInitiation.IsArbitrationMailbox(mbxTransportMailItem.ADRecipientCache, mailRecipient.Email)) { return; } DeliverableMailItem mailItem = storeDriverDeliveryEventArgsImpl.MailItem; MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; EmailMessage message = mailItem.Message; int?messageLocaleId = (storeDriverDeliveryEventArgsImpl.ReplayItem != null) ? storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueAsNullable <int>(MessageItemSchema.MessageLocaleId) : null; this.CheckArbitrationMailboxCapacity(messageItem.Session as MailboxSession, mbxTransportMailItem.OrganizationId); ApprovalEngine approvalEngineInstance = ApprovalEngine.GetApprovalEngineInstance(message, (RoutingAddress)message.From.SmtpAddress, mailRecipient.Email, messageItem, mbxTransportMailItem, ApprovalProcessingAgent.MessageItemCreationDelegate); if (approvalEngineInstance.CreateAndSubmitApprovalRequests(messageLocaleId) != ApprovalEngine.ProcessResult.InitiationMessageOk) { throw new SmtpResponseException(AckReason.ApprovalInvalidMessage); } }