Inbox management and EWS in ExchangeInbox management and EWS in Exchange

了解如何通过使用收件箱规则和阻止发件人列表来管理 EWS 托管 API 或 EWS 应用程序中的收件箱。Find out how you can manage your Inbox in your EWS Managed API or EWS application by using Inbox rules and the blocked senders list.

Exchange 邮箱附带功能,可帮助用户自动组织传入邮件。Exchange mailboxes come equipped with features to help users organize their incoming mail automatically. 这些功能都在服务器上运行,无需用户干预,但它们满足不同的需求。These features all operate on the server without user intervention, but they serve different needs. EWS 托管 API 和 EWS 提供了对这些功能的访问权限,使用户可以管理其收件箱。The EWS Managed API and EWS provide access to these features, enabling your users to manage their Inboxes.

表1。收件箱管理功能Table 1. Inbox management features

如果您想要 .。。If you want to… 使用 .。。Use…
根据特定条件(如发件人、主题或附件)对传入邮件执行操作(例如将其移动到其他文件夹或将其删除)Take action on incoming messages (such as moving them to another folder or deleting them) based on specific criteria (such as sender, subject, or attachments)
收件箱规则Inbox rules
删除来自特定发件人的所有传入邮件Delete all incoming mail from a particular sender
阻止发件人列表Blocked Senders List

收件箱规则Inbox rules

让我们面对 it:并不是每封电子邮件的创建都相等。Let's face it: not every email message is created equal. 对于用户从其经理那里获得的每封电子邮件,从 Internet cat 视频通讯组列表中有一个,他或她以前加入了几年,而从未收到离开。For every email a user gets from his or her manager, there's one from an Internet cat video distribution list he or she joined years ago and never got around to leaving. 尽管 Internet cat 视频非常有趣,但通讯组列表获取的流量可能已过期,并且在收件箱中通讯组列表邮件的海洋中可以很容易地丢失重要邮件。While Internet cat videos are entertaining, the amount of traffic that distribution list gets can get out of hand, and important messages can easily be lost in the sea of distribution list mail in an Inbox. 许多用户会转到收件箱规则,帮助 pare 这些邮件,并使其收件箱地利用的位置变得很多。Many users turn to Inbox rules to help pare down those messages, and make their Inbox a much nicer place to be. 通过 Exchange Web 服务(EWS),应用程序可以让规则的强大功能得以承受。With Exchange Web Services (EWS), your application can bring the power of rules to bear.

EWS 托管 API 提供用于处理规则的GetInboxRulesExchangeService方法。The EWS Managed API provides the ExchangeService.GetInboxRules and ExchangeService.UpdateInboxRules methods for working with rules. EWS 提供用于处理规则的GetInboxRulesUpdateInboxRules操作。EWS provides the GetInboxRules and UpdateInboxRules operations for working with rules. 但是,请注意,在使用收件箱规则时,EWS 托管 API 和 EWS 具有以下限制:However, note that the EWS Managed API and EWS have the following limitations when working with Inbox rules:

  • EWS 无法访问或创建 "仅客户端" 规则或在 Outlook 中设置为 "仅在此计算机上运行" 的规则。EWS cannot access or create "client-only" rules or rules that are set in Outlook to run "on this computer only".

  • 若要使用 EWS 更改当前的一组规则,必须删除 Outlook 规则 BLOB (如果存在)。To change the current set of rules by using EWS, you have to remove the Outlook rules BLOB, if it is present. 这意味着,使用 EWS 修改规则将删除以前使用 Outlook 关闭(禁用)的任何规则。This means that using EWS to modify rules deletes any rules that were previously turned off (disabled) by using Outlook.

规则的工作原理How do rules work?

规则引擎充当用户邮箱的网关守卫。The rules engine acts as a gatekeeper to a user's mailbox. 当邮件到达用户的邮箱,但在收件箱中显示该邮件之前,将根据规则的排序列表对该邮件进行评估。As a message arrives in the user's mailbox, but before the message appears in the Inbox, that message is evaluated against an ordered list of rules. 请注意,这仅发生在到达时,并且仅发生在收件箱中。Note that this only occurs at arrival time, and only in the Inbox. 这些规则由三部分组成:条件操作例外These rules are comprised of three parts: Conditions, Actions, and Exceptions.

从规则列表顶部的规则开始,规则引擎将执行以下步骤,直至到达规则列表的末尾:Starting with the rule at the top of the rule list, the rules engine performs the following steps until it reaches the end of the list of rules:

  1. 检查邮件以确定它是否符合规则中指定的所有条件。Checks the message to determine whether it meets all the conditions specified in the rule.

  2. 如果它满足所有条件,请继续执行步骤2评估。If it meets all the conditions, evaluation continues with step 2.

  3. 如果它不符合所有条件,规则引擎将加载规则列表中的下一个规则,然后在步骤1中启动。If it does not meet all the conditions, the rules engine loads the next rule in the rule list and starts over at step 1.

  4. 检查邮件以确定它是否符合规则中指定的任何例外。Checks the message to determine whether it meets any of the exceptions specified in the rule.

  5. 如果它满足任何例外,规则引擎将加载规则列表中的下一个规则,然后在步骤1中启动。If it meets any of the exceptions, the rules engine loads the next rule in the rule list and starts over at step 1.

  6. 如果它不符合任何例外,请继续执行步骤3评估。If it does not meet any of the exceptions, evaluation continues with step 3.

  7. 对邮件执行规则中指定的操作。Performs the actions specified in the rule on the message.

  8. 如果指定了 "停止处理更多规则" 操作,规则引擎将对邮件执行所有其他操作,然后退出而不评估邮件的任何其他规则。If the "stop processing more rules" action is specified, the rules engine performs all the other actions on the message, then exits without evaluating any additional rules against the message.

  9. 如果未指定 "停止处理更多规则" 操作,规则引擎将加载规则列表中的下一个规则,然后在步骤1中启动。If the "stop processing more rules" action is not specified, the rules engine loads the next rule in the rule list and starts over at step 1.

下图显示规则引擎遵循的过程。The following figure shows the process that the rules engine follows.

图1:规则引擎概述Figure 1: Rules engine overview


将组成部分放在一起-规则的各个部分Putting the pieces together - parts of a rule

可视化规则的各个部分的一种方法是假设您向负责组织传入电子邮件的人员提供说明。One way to visualize the parts of a rule is to imagine that you are giving instructions to someone who is tasked with organizing your incoming email. 您可以向此人说: "当邮件到达时" <insert conditions here> ,则 <insert actions here> 除非邮件 <insert exceptions here> 。You might say to this person: "When a message arrives that <insert conditions here>, do <insert actions here>, unless the message <insert exceptions here>. 让我们进一步了解每个部分。Let's take a closer look at each part.


条件描述应何时应用规则。Conditions describe when a rule should be applied. 虽然您可以省略规则的条件(结果是应用于每个收到的邮件的规则),但对于规则而言,有一些条件适用于传入邮件的子集更常见。While you can omit the conditions of a rule (resulting in a rule that applies to every message received), it is far more common for rules to have conditions that apply to a subset of incoming messages. 一些示例包括 "当邮件来自 Sadie" 或 "当邮件发送到 ' Cat Video Lovers 更改 ' 通讯组列表 ' 时"。Some examples are "when a message is from Sadie" or "when a message is sent to the 'Cat Video Lovers' distribution list". 规则可以有多个条件。Rules can have multiple conditions. 当规则具有多个条件时,必须满足所有条件,规则引擎才能执行指定的操作。When rules have more than one condition, all the conditions must be met in order for the rules engine to take the specified action.


操作描述应用规则时所发生的情况。Actions describe what happens when a rule applies. 例如 "将邮件移动到 ' 猫 ' 文件夹" 或 "使用 ' 重要性 ' 较低的邮件标记"。Examples are "move the message to the 'Cats' folder" or "mark the message with 'Low' importance". 规则可以有多个操作。Rules can have multiple actions. 当您为某个规则指定多个操作时,将在应用该规则时执行所有操作。When you specify multiple actions for a rule, all the actions are performed when the rule is applied.


异常描述规则不应应用的时间,即使满足条件中指定的条件也是如此。Exceptions describe when a rule should not apply, even if the criteria specified in the conditions are met. 例如,"仅将邮件发送给我" 或 "邮件来自 Mom" 时除外。Examples are "except if the message is sent only to me" or "except if the message is from Mom". 一个规则可以有多个例外。A rule can have multiple exceptions. 如果规则具有多个异常,并且满足了任何异常,则不会应用该规则。When rules have more than one exception, and any of the exceptions are met, the rule is not applied.

示例: Herding 这些猫Example: Herding those cats

我们来看看您的用户如何使用规则来消除来自该 Internet cat 视频通讯组列表的流量。Let's take a look at how your users can use rules to eliminate the traffic from that Internet cat video distribution list. 让我们假定以下内容:Let's assume the following:

  • 这些邮件将被发送到名为 "Internet Cat Video 爱好者" 的通讯组列表。These messages are sent to a distribution list called "Internet Cat Video Enthusiasts".

  • 您的用户希望最终阅读这些邮件,它们只是不希望他们打乱其收件箱。Your users want to read these messages eventually, they just don't want them cluttering their Inbox. 而是将其文件放在名为 "猫" 的文件夹中。They'd rather file them in a folder called "Cats".

  • 您的用户希望立即阅读通过其母亲发送到此通讯组列表的邮件,因为 Mom 发送 funniest 视频。Your users want to read messages sent to this distribution list by their mother right away, because Mom sends the funniest videos.

这将告知规则引擎以下内容: "当邮件到达时发送到 ' Internet Cat 视频爱好者 ' 通讯组 ' 列表时,请将其移至" 猫 "文件夹,除非邮件来自 Mom。"This tells the rules engine the following: "When a message arrives that is sent to the 'Internet Cat Video Enthusiasts' distribution list, move it to the 'Cats' folder, unless the message is from Mom."

表2。规则定义Table 2. Rule definition

规则部件Rule part Value
发送到 "Internet Cat 视频爱好者" 通讯组列表Sent to the 'Internet Cat Video Enthusiasts' distribution list
将邮件移动到 "猫" 文件夹Move the message to the 'Cats' folder
并停止处理更多规则AND stop processing more rules
从 "Mom"From 'Mom'


请注意,"停止处理更多规则" 是结果规则中的操作之一。Notice that "stop processing more rules" is one of the actions in the resulting rule. 通常,最好将此操作包括在内,以避免因规则对任何给定的邮件起作用而产生困惑。In general it's a good idea to include this action to avoid confusion over which rules act on any given message. 但是,通过省略此操作并正确地对规则进行排序,可以实现对传入邮件的更高级处理。However, by omitting this action and properly ordering your rules, you can achieve more advanced processing of your incoming mail. 在这种情况下,可能是因为 Internet cat 视频邮件不需要很多高级处理方式。In this case, it's probably a safe bet that Internet cat video messages don't require much in the way of advanced processing.

在创建此规则后不久,将会收到一封新邮件。Shortly after creating this rule, a new message comes in. 同事希望向通讯组列表发送一封邮件。A coworker Hope sends a message to the distribution list. 如果我们 mentally 执行规则引擎的工作,则邮件将满足所有条件(它将发送到 "Internet Cat 视频爱好者"),并且不会满足任何例外(不是来自 "Mom"),因此规则将应用并将邮件移动到 "猫" 文件夹。If we mentally perform the work of the rules engine, the message meets all the conditions (it is sent to 'Internet Cat Videos Enthusiasts'), and it meets none of the exceptions (it isn't from 'Mom'), so the rule applies and the message gets moved to the 'Cats' folder.

下图显示了如何将规则应用于传入邮件。The following figure shows how the rule is applied to an incoming mail message.

图2。传入邮件由规则处理Figure 2. Incoming message is processed by a rule


阻止发件人Blocking senders

虽然您可以创建将来自特定发件人的所有邮件移动到 "垃圾邮件" 文件夹的规则,但您也可以通过使用 "垃圾邮件" 选项中的阻止发件人列表来执行此操作。Although you can create a rule that will move all mail from a specific sender to the Junk Mail folder, you can also do this by using the Blocked Senders List in your Junk Email options. 由于用户可以拥有的规则数有限制,因此使用阻止的发件人列表很有意义。Because there is a limit to how many rules a user can have, it makes sense to use the Blocked Senders List. 您可以使用ExchangeService EWS 托管 API 方法或MarkAsJunk Ews 操作在阻止发件人列表中添加或删除特定的电子邮件地址You can add or remove specific email addresses from the Blocked Senders List by using the ExchangeService.MarkAsJunk EWS Managed API method or the MarkAsJunk EWS operation. 请注意,为了使 EWS 能够访问阻止的发件人列表,用户的邮箱必须包含来自您要添加或删除的电子邮件地址的电子邮件。Note that in order for EWS to access the Blocked Senders List, the user's mailbox must contain an email message from the email address that you want to add or remove.

本节内容In this section

另请参阅See also