使用 Azure 逻辑应用管理 Office 365 Outlook 中的电子邮件、联系人和日历Manage email, contacts, and calendars in Office 365 Outlook by using Azure Logic Apps

使用 Azure 逻辑应用Office 365 Outlook 连接器,可以通过构建逻辑应用来创建用于管理工作或学校帐户的自动化任务和工作流。With Azure Logic Apps and the Office 365 Outlook connector, you can create automated tasks and workflows that manage your work or school account by building logic apps. 例如,可以自动执行以下任务:For example, you can automate these tasks:

  • 获取、发送和回复电子邮件。Get, send, and reply to email.
  • 在日历上安排会议。Schedule meetings on your calendar.
  • 添加和编辑联系人。Add and edit contacts.

可以使用任何触发器来启动工作流,例如,当新电子邮件到达时、当日历项更新时或其他服务(例如 Salesforce)中发生某个事件时。You can use any trigger to start your workflow, for example, when a new email arrives, when a calendar item is updated, or when an event happens in a difference service, such as Salesforce. 可以使用对触发器事件做出响应的操作,例如,发送电子邮件或创建新的日历事件。You can use actions that respond to the trigger event, for example, send an email or create a new calendar event.

先决条件Prerequisites

  • 一个使用工作或学校帐户登录的 Outlook 帐户。An Outlook account where you sign in with a work or school account. 如果你具有 @outlook.com 或 @hotmail.com 帐户,请改用 Outlook.com 连接器If you have an @outlook.com or @hotmail.com account, use the Outlook.com connector instead. 若要使用其他用户帐户(例如服务帐户)连接到 Outlook,请参阅使用其他帐户进行连接To connect to Outlook with a different user account, such as a service account, see Connect using other accounts.

  • Azure 帐户和订阅。An Azure account and subscription. 如果没有 Azure 订阅,请注册试用版 Azure 订阅If you don't have an Azure subscription, sign up for a trial Azure subscription.

  • 你要在其中访问 Outlook 帐户的逻辑应用。The logic app where you want to access your Outlook account. 若要通过 Office 365 Outlook 触发器启动工作流,需要有一个空白逻辑应用To start your workflow with an Office 365 Outlook trigger, you need to have a blank logic app. 若要向工作流中添加 Office 365 Outlook 操作,逻辑应用需要已有一个触发器。To add an Office 365 Outlook action to your workflow, your logic app needs to already have a trigger.

添加触发器Add a trigger

触发器是一个事件,用于启动逻辑应用中的工作流。A trigger is an event that starts the workflow in your logic app. 此示例逻辑应用使用一个“轮询”触发器,该触发器根据指定的时间间隔和频率检查电子邮件帐户中是否有任何更新的日历事件。This example logic app uses a "polling" trigger that checks for any updated calendar event in your email account, based on the specified interval and frequency.

  1. Azure 门户中,在逻辑应用设计器中打开你的空白逻辑应用。In the Azure portal, open your blank logic app in the Logic App Designer.

  2. 在搜索框中,输入 office 365 outlook 作为筛选器。In the search box, enter office 365 outlook as your filter. 此示例选择“即将启动将要发生的事件时” 。This example selects When an upcoming event is starting soon.

    选择用于启动逻辑应用的触发器

  3. 如果你没有连接到 Outlook 帐户的活动连接,系统将提示你登录并创建该连接。If you don't have an active connection to your Outlook account, you're prompted to sign in and create that connection. 若要使用其他用户帐户(例如服务帐户)连接到 Outlook,请参阅使用其他帐户进行连接To connect to Outlook with a different user account, such as a service account, see Connect using other accounts. 否则,请提供触发器属性的相关信息。Otherwise, provide the information for the trigger's properties.

    备注

    即使你更改了登录凭据,你的连接也不会过期,直到撤销为止。Your connection doesn't expire until revoked, even if you change your sign-in credentials.

    此示例选择供触发器检查的日历,例如:This example selects the calendar that the trigger checks, for example:

    配置触发器的属性

  4. 在触发器中,设置“频率” 和“间隔” 值。In the trigger, set the Frequency and Interval values. 若要添加其他可用的触发器属性(例如“时区” ),请从“添加新参数” 列表中选择那些属性。To add other available trigger properties, such as Time zone, select those properties from the Add new parameter list.

    例如,如果希望触发器每 15 分钟检查一次日历,请将“频率” 设置为“分钟” ,将“间隔” 设置为 15For example, if you want the trigger to check the calendar every 15 minutes, set Frequency to Minute, and set Interval to 15.

    为触发器设置频率和间隔

  5. 在设计器工具栏上选择“保存”。 On the designer toolbar, select Save.

现在,添加一个在触发器触发后运行的操作。Now add an action that runs after the trigger fires. 例如,可以添加 Twilio“发送消息” 操作,当日历事件将在 15 分钟内启动时,该操作会发送一个文本。For example, you can add the Twilio Send message action, which sends a text when a calendar event starts in 15 minutes.

添加操作Add an action

操作是指由逻辑应用中的工作流运行的操作。An action is an operation that's run by the workflow in your logic app. 此示例逻辑应用在 Office 365 Outlook 中新建一个联系人。This example logic app creates a new contact in Office 365 Outlook. 可以使用来自其他触发器或操作的输出创建联系人。You can use the output from another trigger or action to create the contact. 例如,假设你的逻辑应用使用 Dynamics 365 触发器“创建记录时”。 For example, suppose your logic app uses the Dynamics 365 trigger, When a record is created. 你可以添加 Office 365 Outlook 的“创建联系人” 操作,并使用来自 SalesForce 触发器的输出来新建联系人。You can add the Office 365 Outlook Create contact action and use the outputs from the SalesForce trigger to create the new contact.

  1. Azure 门户的逻辑应用设计器中打开逻辑应用。In the Azure portal, open your logic app in the Logic App Designer.

  2. 若要将某个操作添加为工作流的最后一步,请选择“新建步骤” 。To add an action as the last step in your workflow, select New step.

    若要在步骤之间添加操作,请将鼠标指针移到这些步骤之间的箭头上。To add an action between steps, move your pointer over the arrow between those steps. 选择出现的加号 ( + ),然后选择“添加操作”。 Select the plus sign (+) that appears, and then select Add an action.

  3. 在搜索框中,输入 office 365 outlook 作为筛选器。In the search box, enter office 365 outlook as your filter. 此示例选择“创建联系人” 。This example selects Create contact.

    选择要在逻辑应用中运行的操作

  4. 如果你没有连接到 Outlook 帐户的活动连接,系统将提示你登录并创建该连接。If you don't have an active connection to your Outlook account, you're prompted to sign in and create that connection. 若要使用其他用户帐户(例如服务帐户)连接到 Outlook,请参阅使用其他帐户进行连接To connect to Outlook with a different user account, such as a service account, see Connect using other accounts. 否则,请提供操作属性的相关信息。Otherwise, provide the information for the action's properties.

    备注

    即使你更改了登录凭据,你的连接也不会过期,直到撤销为止。Your connection doesn't expire until revoked, even if you change your sign-in credentials.

    此示例选择可供操作在其中创建新联系人的联系人文件夹,例如:This example selects the contacts folder where the action creates the new contact, for example:

    配置操作的属性

    若要添加其他可用的操作属性,请从“添加新参数”列表中选择那些属性。 To add other available action properties, select those properties from the Add new parameter list.

  5. 在设计器工具栏上选择“保存”。 On the designer toolbar, select Save.

使用其他帐户进行连接Connect using other accounts

如果尝试使用与当前登录到 Azure 的帐户不同的帐户连接到 Outlook,则可能会出现单一登录 (SSO) 错误。If you try connecting to Outlook by using a different account than the one currently signed in to Azure, you might get single sign-on (SSO) errors. 当使用一个帐户登录 Azure 门户,但使用其他帐户来创建连接时,会发生此问题。This problem happens when you sign in to the Azure portal with one account, but use a different account to create the connection. 设计器需要使用已登录到 Azure 门户的帐户。The designer expects that you use the account that's signed in to the Azure portal. 若要解决此问题,可采用以下选项:To resolve this problem, you have these options:

  • 在逻辑应用的资源组中,使用“参与者”角色设置另一个帐户。Set up the other account with the Contributor role in your logic app's resource group.

    1. 在逻辑应用的资源组菜单中,选择“访问控制(IAM)”。On your logic app's resource group menu, select Access control (IAM). 使用参与者角色设置其他帐户。Set up the other account with the Contributor role.

      有关详细信息,请参阅使用 Azure 门户分配 Azure 角色For more information, see Assign Azure roles using the Azure portal.

    2. 设置此角色后,使用现在已有参与者权限的帐户登录到 Azure 门户。After you set up this role, sign in to the Azure portal with the account that now has Contributor permissions. 现在可以使用此帐户创建与 Outlook 的连接。You can now use this account to create the connection to Outlook.

  • 设置另一个帐户,使工作或学校帐户具有“发送方式”权限。Set up the other account so that your work or school account has "send as" permissions.

    如果你具有管理员权限,请在服务帐户的邮箱上设置你的工作或学校帐户,该帐户具有“发送方式”或“代表发送”权限 。If you have admin permissions, on the service account's mailbox, set up your work or school account with either Send as or Send on behalf of permissions. 有关详细信息,请参阅向其他用户授予邮箱权限 - 管理帮助For more information, see Give mailbox permissions to another user - Admin Help. 然后,可使用工作或学校帐户创建连接。You can then create the connection by using your work or school account. 现在,在可指定发送方的触发器或操作中,可使用服务帐户的电子邮件地址。Now, in triggers or actions where you can specify the sender, you can use the service account's email address.

    例如,“发送电子邮件”操作有一个名为“发件人(发送方式)”的可选参数,你可将它添加到操作,并使用你的服务帐户的电子邮件地址作为发件人 。For example, the Send an email action has an optional parameter, From (Send as), which you can add to the action and use your service account's email address as the sender. 若要添加此参数,请执行以下步骤:To add this parameter, follow these steps:

    1. 在“发送电子邮件”操作中,打开“添加参数”列表,然后选择“发件人(发送方式)”参数 。In the Send an email action, open the Add a parameter list, and select the From (Send as) parameter.

    2. 在操作中显示该参数后,输入服务帐户的电子邮件地址。After the parameter appears on the action, enter the service account's email address.

连接器参考Connector reference

有关此连接器的技术详细信息,例如触发器、操作和限制(如此连接器的 Swagger 文件所述),请参阅连接器的参考页For technical details about this connector, such as triggers, actions, and limits, as described by the connector's Swagger file, see the connector's reference page.

后续步骤Next steps