public override void Execute() { if (!this.ShouldExecuteOnThisStage) { return; } if (base.Context.DetectLoop()) { string[] valueOrDefault = base.Context.Message.GetValueOrDefault <string[]>(MessageItemSchema.XLoop, null); if (valueOrDefault == null || valueOrDefault.Length != 1) { return; } base.Context.TraceDebug("Sending to Delegates even though loop was detected due to 1 XLoop header in the message."); } base.Context.TraceDebug("Delegate action: Creating message to forward."); using (MessageItem messageItem = RuleMessageUtils.CreateDelegateForward(base.Context.Message, base.Context.StoreSession.PreferedCulture, base.Context.DefaultDomainName, base.Context.XLoopValue, base.Context)) { if (this.ShouldSubmit(messageItem)) { this.SetDelegateProperties(messageItem); if (base.Context.PropertiesForDelegateForward != null) { foreach (KeyValuePair <PropertyDefinition, object> keyValuePair in base.Context.PropertiesForDelegateForward) { base.Context.TraceDebug <PropertyDefinition, object>("Delegate action: setting {0} to {1}", keyValuePair.Key, keyValuePair.Value ?? "(null)"); messageItem.SetOrDeleteProperty(keyValuePair.Key, keyValuePair.Value); } } messageItem.AutoResponseSuppress = AutoResponseSuppress.All; RuleUtil.SetRecipients(base.Context, messageItem, null, this.recipients, true); base.SubmitMessage(messageItem); } } }
private MessageItem CreateReply(MessageItem template) { MessageItem messageItem; if ((this.flags & RuleAction.Reply.ActionFlags.UseStockReplyTemplate) != RuleAction.Reply.ActionFlags.None) { base.Context.TraceDebug("Reply action: creating stock reply."); CultureInfo preferedCulture = base.Context.StoreSession.PreferedCulture; string body = ServerStrings.StockReplyTemplate.ToString(preferedCulture); messageItem = RuleMessageUtils.CreateStockReply(base.Context.Message, body, preferedCulture, base.Context.XLoopValue); } else { base.Context.TraceDebug("Reply action: creating reply."); messageItem = RuleMessageUtils.CreateReply(base.Context.Message, template, base.Context.StoreSession.PreferedCulture, base.Context.XLoopValue, base.Context); } string subject = template.Subject; if (!string.IsNullOrEmpty(subject)) { base.Context.TraceDebug <string>("Reply action: setting subject: {0}", subject); messageItem.Subject = subject; } messageItem[ItemSchema.SpamConfidenceLevel] = -1; messageItem.AutoResponseSuppress = AutoResponseSuppress.All; return(messageItem); }
private MessageItem CreateMessage() { if ((this.flags & RuleAction.Forward.ActionFlags.SendSmsAlert) != RuleAction.Forward.ActionFlags.None) { return(RuleMessageUtils.CreateSmsAlert(base.Context.Message, base.Context.StoreSession.PreferedCulture, base.Context.DefaultDomainName, base.Context.XLoopValue, base.Context.DetermineRecipientTimeZone(), base.Context)); } if (this.IsForwarding) { bool asAttachment = (this.flags & RuleAction.Forward.ActionFlags.ForwardAsAttachment) != RuleAction.Forward.ActionFlags.None; return(RuleMessageUtils.CreateForward(base.Context.Message, asAttachment, base.Context.StoreSession.PreferedCulture, base.Context.DefaultDomainName, base.Context.XLoopValue, base.Context.DetermineRecipientTimeZone(), base.Context)); } return(RuleMessageUtils.CreateRedirect(base.Context.Message, base.Context.StoreSession.PreferedCulture, base.Context.DefaultDomainName, base.Context.XLoopValue, base.Context)); }
private void CreateDAM() { MailboxSession mailboxSession = base.Context.StoreSession as MailboxSession; base.Context.TraceDebug("Deferred action: Creating deferred action message."); using (DeferredAction deferredAction = RuleMessageUtils.CreateDAM(mailboxSession, this.folder.Id.ObjectId, this.provider)) { foreach (DeferredActionWorkItem.ActionInfo actionInfo in this.actions) { base.Context.TraceDebug <RuleAction>("Deferred action: Adding deferred action {0}.", actionInfo.Action); deferredAction.AddAction(actionInfo.RuleId, actionInfo.Action); } StoreId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox); bool flag = RuleUtil.EqualsStoreId(defaultFolderId, base.Context.FinalDeliveryFolderId); deferredAction.Message[ItemSchema.DeferredActionMessageBackPatched] = !flag; base.Context.DeliveredMessage.Load(DeferredError.EntryId); byte[] value = (byte[])base.Context.DeliveredMessage[StoreObjectSchema.EntryId]; deferredAction.Message[ItemSchema.OriginalMessageEntryId] = value; base.Context.TraceDebug("Deferred action: Saving deferred action message."); deferredAction.SerializeActionsAndSave(); base.Context.TraceDebug("Deferred action: Deferred action message saved."); } }
public override void Execute() { if (!this.ShouldExecuteOnThisStage) { return; } if (base.Context.DetectLoop()) { string[] valueOrDefault = base.Context.Message.GetValueOrDefault <string[]>(MessageItemSchema.XLoop, null); if (valueOrDefault == null || valueOrDefault.Length != 1) { return; } base.Context.TraceDebug("Sending OOF even though loop was detected due to 1 XLoop header in the message."); } if (string.IsNullOrEmpty(base.Context.SenderAddress)) { base.Context.TraceDebug("Sender address was empty, this OOF reply work item is not executed."); return; } MapiFolder nonIpmSubtreeFolder = null; MapiFolder oofHistoryFolder = null; OofHistory oofHistory = null; try { MailboxSession mailboxSession = base.Context.StoreSession as MailboxSession; bool shouldSendOofReply = true; bool shouldKeepOofHistory = true; if ((base.Rule.StateFlags & RuleStateFlags.KeepOOFHistory) == (RuleStateFlags)0) { base.Context.TraceError("Rule does not have 'keep OOF history' flag set, OOF history operation skipped."); shouldKeepOofHistory = false; } if (shouldKeepOofHistory && mailboxSession == null) { base.Context.TraceError("This is a public folder delivery, OOF history operation skipped."); shouldKeepOofHistory = false; } if (shouldKeepOofHistory && mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion < 1937801494) { base.Context.TraceError("Recipient's mailbox doesn't support OOF history."); shouldKeepOofHistory = false; } if (string.IsNullOrEmpty(base.Context.SenderAddress)) { base.Context.TraceError("Sender address was empty, OOF history operation skipped."); shouldKeepOofHistory = false; } if (shouldKeepOofHistory) { RuleUtil.RunMapiCode(ServerStrings.UpdateOOFHistoryOperation, delegate(object[] param0) { MapiStore mapiStore = this.Context.StoreSession.Mailbox.MapiStore; byte[] globalRuleId = mapiStore.GlobalIdFromId(this.Rule.ID); byte[] bytes = Encoding.ASCII.GetBytes(this.Context.SenderAddress); oofHistory = new OofHistory(bytes, globalRuleId, this.Context); if (!oofHistory.TryInitialize()) { shouldKeepOofHistory = false; return; } if (mailboxSession.IsMailboxOof()) { shouldSendOofReply = oofHistory.ShouldSendOofReply(); this.Context.TraceDebug <bool>("Should send automatic reply: {0}.", shouldSendOofReply); return; } this.Context.TraceDebug("Mailbox is not OOF, not sending oof reply"); }, new object[0]); } if (!shouldSendOofReply) { if (!ObjectClass.IsOfClass(base.Context.Message.ClassName, "IPM.Note.Microsoft.Approval.Request")) { base.Context.TraceDebug("Automatic reply will not be sent."); return; } base.Context.TraceDebug("Sending automatic reply anyway - the incoming message is an approval request."); } if (!base.Context.LimitChecker.DoesExceedAutoReplyLimit()) { using (MessageItem messageItem = base.OpenMessage(this.messageTemplateEntryId)) { using (MessageItem messageItem2 = RuleMessageUtils.CreateOofReply(base.Context.Message, messageItem, base.Context.StoreSession.PreferedCulture, new InboundConversionOptions(base.Context.StoreSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), base.Context.DefaultDomainName), base.Context.XLoopValue)) { messageItem2[ItemSchema.SpamConfidenceLevel] = -1; messageItem2.AutoResponseSuppress = AutoResponseSuppress.All; base.Context.SetMailboxOwnerAsSender(messageItem2); base.SetRecipientsResponsibility(messageItem2); base.SubmitMessage(messageItem2); } } if (shouldKeepOofHistory && oofHistory != null) { RuleUtil.RunMapiCode(ServerStrings.AppendOOFHistoryEntry, delegate(object[] param0) { oofHistory.AppendEntry(); }, new object[0]); } } } finally { if (oofHistory != null) { RuleUtil.RunMapiCode(ServerStrings.UnlockOOFHistory, delegate(object[] param0) { oofHistory.Dispose(); }, new object[0]); } if (oofHistoryFolder != null) { RuleUtil.RunMapiCode(ServerStrings.DisposeOOFHistoryFolder, delegate(object[] param0) { oofHistoryFolder.Dispose(); }, new object[0]); } if (nonIpmSubtreeFolder != null) { RuleUtil.RunMapiCode(ServerStrings.DisposeNonIPMFolder, delegate(object[] param0) { nonIpmSubtreeFolder.Dispose(); }, new object[0]); } } }
internal MessageItem CreateNrn() { return(RuleMessageUtils.CreateNotReadNotification(base.Context.Message)); }