通过 Office 365 Outlook 电子邮件适配器发送和接收电子邮件-BizTalk ServerSend and receive email with Office 365 Outlook Email adapter - BizTalk Server

Office 365 Outlook 电子邮件适配器允许您通过 Office 365 Outlook 电子邮件从 BizTalk 发送和接收邮件。The Office 365 Outlook Email Adapter allows you to send and receive mails from your Office 365 Outlook Email from BizTalk.

使用发送端口发送邮件Send mail using a send port

  1. 在 BizTalk Server 管理控制台中,右键单击 "发送端口",选择 "新建",然后选择 "静态单向发送端口"。In the BizTalk Server Administration console, right-click Send Ports, select New, and select Static One-way send port.

    创建发送端口提供了一些指导。Create a Send Port provides some guidance.

  2. 输入名称Enter a Name. 在 "传输" 中,将 "类型" 设置为Office 365 Outlook 电子邮件,然后选择 "配置"。In Transport, set the Type to Office 365 Outlook Email, and select Configure.

  3. 选择 "登录",然后登录到 Office 365 帐户。Select Sign in …, and sign in to your Office 365 Account. 帐户会自动填充你的电子邮件地址。The account is auto-populated with your email address.

  4. 允许 BizTalk Server 审批访问权限:Allow BizTalk Server approval for permission to access:

    BizTalk Server](../core/media/office365-mail-permissions.png) 中 ![Office 365 适配器的邮件权限Office 365 adapter mail permissions in BizTalk Server

  5. 配置 Office 365 Outlook 电子邮件常规属性:Configure your Office 365 Outlook Email General properties:

    • 若要:输入默认的邮件地址,用 ";" 分隔(256个字符最大值)To: Enter your default To mail addresses separated by ';' (256 character max)
    • 抄送:输入由 ";" 分隔的默认 CC 邮件地址(256个字符最大值)CC: Enter your default CC mail addresses separated by ';' (256 character max)
    • Subject:提及默认邮件主题。Subject: Mention your default mail subject. (256个字符最大值)(256 character max)
    • 重要性:选择重要性的值。Importance: Select your value of Importance. 下拉列表包含的值为LownormalHigh ,默认值为normalDropdown contains values Low, Normal, and High with Normal being the default.

    完成后,属性如下所示:When finished, your properties look similar to the following:

    BizTalk Server](../core/media/office365-mail-send-properties.png) 中 ![Office 365 Outlook 电子邮件常规属性Office 365 Outlook Email General properties in BizTalk Server

  6. 配置 Office 365 Outlook 电子邮件附件属性:Configure your Office 365 Outlook Email Attachments properties:

    要发送的电子邮件的正文对应于 BizTalk 消息的正文部分。The body of the email being sent corresponds to the body part of the BizTalk message. 若要将附件添加到电子邮件中,请执行以下操作:To add attachments to the email, do the following:

    • 附加 biztalk 消息部分:如果选中,则会将 biztalk 消息的非正文部分作为附件添加到发送的电子邮件中。Attach BizTalk message parts: If checked, BizTalk message non-body parts are added as attachments to the email sent.
    • 文件:指定将一个或一条文件附加到电子邮件,并指定该文件的完整路径。Files: Specifies that a file or files are attached to the e-mail message and the full path to the file or files. 在运行时,适配器的主机必须能够访问指定的路径。The specified path or paths must be accessible to the host for the adapter at run time. 默认值:空。Default value: empty.

    选择一些文件后,附件属性如下所示:After selecting some files, the attachments properties look similar to the following:

    BizTalk Server](../core/media/office365-mail-send-attachments-properties.png) 中 ![Office 365 Outlook 电子邮件附件属性Office 365 Outlook Email Attachments properties in BizTalk Server

  7. 选择 "确定" 保存更改。Select Ok to save your changes.

重要详细信息Important details

  1. 还可以使用升级的属性更新默认属性:The default properties may also be updated using promoted properties:

    属性名称Property Name 升级的属性Promoted Property
    操作To OfficeMail.ToOfficeMail.To
    CCCC OfficeMail.CCOfficeMail.CC
    主题Subject OfficeMailOfficeMail.Subject
    仅次于Importance OfficeMailOfficeMail.Importance
    附加文件Attached Files OfficeMail.AttachedFilesOfficeMail.AttachedFiles
  2. OfficeMail. AttachedFiles属性值是文件列表,以 "|" 作为不同文件之间的分隔符。The OfficeMail.AttachedFiles property value is list of files with "|" as delimiter in between different files. 例如: "C:\Attachments\File1.pdf |C:\Attachments\File2.xml "。For instance: "C:\Attachments\File1.pdf|C:\Attachments\File2.xml".

  3. BizTalk 消息正文部分的 "ContentType" 属性可设置为 "Text" 或 "Html",以指示电子邮件正文的类型。The ContentType property of the BizTalk message body part can be set to "Text" or "Html" to indicate the type of the email body. 默认情况下,它将为 "Text"。By default, it will be "Text".

  4. 附加多部分 BizTalk 消息的某些部分时,如果提供了部分的 ContentType 属性,则会将该属性用作创建的附件的 MIME 类型。When parts of a multi-part BizTalk message are attached, the ContentType property of a part, if provided, is used as the MIME type for the attachment created. 默认情况下,附件的 MIME 类型设置为 "application/八进制流"。By default, the MIME type of the attachment is set to "application/octet-stream".

  5. 附加文件时,将从文件扩展名确定附件的 MIME 类型。When attaching files, the MIME type of the attachment is determined from the filename extension. 默认 MIME 类型为 "application/八进制流"。The default MIME type is "application/octet-stream".

测试发送端口Test your send port

你可以使用简单的文件接收端口和位置将消息发送到 Office 365 Outlook 电子邮件。You can use a simple File receive port and location to send messages to your Office 365 Outlook Email.

  1. 使用文件适配器创建接收端口。Create a receive port using the File adapter. 在接收位置中,将 "接收文件夹" 设置为 "在\中\Temp"\ ,并将文件掩码设置为 *.xmlWithin your receive location, set the Receive folder to C:\Temp\In\, and set the file mask to *.xml.

  2. 在 Office 365 Outlook 电子邮件适配器发送端口属性中,将筛选器设置为 BTS.ReceivePortName == <Receive Port Name>In your Office 365 Outlook Email adapter send port properties, set the Filters to BTS.ReceivePortName == <Receive Port Name>.

  3. 将以下内容粘贴到文本编辑器中,并将该文件另存为Office365MailPaste the following into a text editor, and save the file as Office365Mail.xml. 这是你的示例消息。This is your sample message.

    <ns0:Root xmlns:ns0="http://BizTalk_Server_Project1.Schema1"> 
        <Record> 
            <Name>BizTalk User</Name> 
            <ID>001</ID> 
        </Record> 
    </ns0:Root> 
    
  4. 启动 File 接收位置和 Office 365 Outlook 电子邮件适配器发送端口。Start the File receive location and the Office 365 Outlook Email adapter send port.

  5. Office365Mail示例消息复制到 Receive 文件夹中(C:\Temp\在\中)。Copy Office365Mail.xml sample message into the receive folder (C:\Temp\In\). 发送端口将该 XML 文件作为邮件正文发送到 Office 365 Outlook 电子邮件。The send port sends the XML file as mail body to your Office 365 Outlook Email. 端口配置的 "附件" 选项卡中指定的文件附加到电子邮件。Files specified in the Attachments tab of the port configuration are attached to the email.

使用接收端口接收电子邮件Receive email using a receive port

  1. 在 BizTalk Server 管理控制台中,右键单击 "接收端口",选择 "新建",然后选择 "单向接收端口"。In the BizTalk Server Administration console, right-click Receive Ports, select New, and select One-Way receive port.

    创建接收端口提供了一些指导。Create a receive port provides some guidance.

  2. 输入名称,并选择 "接收位置"。Enter a name, and select Receive Locations.

  3. 选择 "新建",并命名接收位置。Select New, and Name the receive location. 在 "传输" 中,从 "类型" 下拉列表中选择 " Office 365 Outlook 电子邮件",然后选择 "配置"。In Transport, select Office 365 Outlook Email from the Type drop-down list, and then select Configure.

  4. 选择 "登录",然后登录到 Office 365 帐户。Select Sign in …, and sign in to your Office 365 Account. 帐户会自动填充你的电子邮件地址。The account is auto-populated with your email address.

  5. 允许 BizTalk Server 审批访问权限:Allow BizTalk Server approval for permission to access:

    允许 BizTalk Server 批准访问 Office 365 邮件权限Allow BizTalk Server approval for permission to access Office 365 Mail permissions

  6. 配置终结点常规属性:Configure the endpoint General properties:

    • 文件夹:选择文件夹以获取电子邮件。Folder: Select the folder to get email. 默认文件夹为收件箱。The default folder is Inbox. 请注意,文件夹本质上并不是递归的。Note that folders aren’t recursive in nature. 例如,不检索子文件夹中的电子邮件。For example, email from subfolders are not retrieved.
    • 开始时间:输入从 Office 365 收到电子邮件的方式。Start from: Enter how email is received from Office 365. 此值指示 Office 365 Outlook 中的电子邮件的 receivedTimeStamp。This value indicates receivedTimeStamp of an email in Office 365 Outlook. 收到的电子邮件比输入的值晚。Email more recent than the entered values are received.
    • 仅限未读邮件:选中此选项可仅读取未读电子邮件。Unread mails only: Check this to read only unread email. 保持未选中状态以读取所有电子邮件。Keep it unchecked to read all email.
    • Post 操作:选择要在阅读电子邮件后执行的 post 操作。Post Action: Select a post action to be performed after an email is read. 默认值为 "",当 BizTalk 收到电子邮件后将不执行任何操作。None is the default, and does nothing after email is received by BizTalk. 标记为"已读" 表示当 BizTalk 收到电子邮件后,邮箱中的电子邮件将标记为 "已读"。Mark as read implies, that after an email is received by BizTalk, the email in your mailbox is marked as read. 删除意味着,当 BizTalk 收到电子邮件后,邮箱中的电子邮件将被删除。Delete implies, that after an email is received by BizTalk, the email in your mailbox is deleted. 最大程度地执行 Post 操作。Post actions are performed on a best-effort basis.

    完成后,属性如下所示:When finished, your properties look similar to the following:

    BizTalk Server](../core/media/office365-mail-receive-properties.png) 中 ![Office 365 邮件终结点属性Office 365 mail Endpoint properties in BizTalk Server

  7. 配置终结点负载属性(从 BizTalk Server 2020 和更高版本开始可用):Configure the endpoint Payload properties (available starting with BizTalk Server 2020 and newer):

    • 传递 mime:保存电子邮件的 mime 表示形式。Deliver MIME: Saves the MIME representation of an email. MIME 内容包括电子邮件正文和所有附件。The MIME content includes email body and all attachments.
    • 处理内容:保存电子邮件正文。Process content: Saves the email body. 它在默认情况下处于选中状态。It is selected by default. 电子邮件正文的内容类型保存在创建的 BizTalk 消息的 "ContentType" 属性中。The content type of the email body is saved in the ContentType property of the created BizTalk message.
    • 包含附件:将电子邮件附件保存为 BizTalk 消息的一部分。Include attachments: Saves email attachments as parts of the BizTalk message. 默认情况下未选中。It is unchecked by default. 每个 BizTalk 消息部分都将 "ContentType" 属性设置为附件的 MIME 类型。Each BizTalk message part has the ContentType property set to the MIME type of the attachment. 作为 Outlook 项(电子邮件、日历事件、联系人)的附件保存在其 MIME 表示形式中。Attachments that are Outlook items (emails, calendar events, contacts) are saved in their MIME representation.

    完成后,属性如下所示:When finished, your properties look similar to the following:

    BizTalk Server](../core/media/office365-mail-receive-payload-properties.png) 中 Office 365 适配器的 ![负载终结点属性Payload Endpoint properties for Office 365 adapter in BizTalk Server

  8. 选择 "确定" 保存更改。Select Ok to save your changes.

测试接收设置Test your receive settings

你可以使用简单的文件发送端口从你的 Office 365 Outlook 电子邮件接收消息。You can use a simple File send port to receive messages from your Office 365 Outlook Email.

  1. 使用文件适配器创建发送端口。Create a send port using the File adapter. 在发送端口属性中,将目标文件夹设置为C:\Temp\Out\ ,并将和文件名设置为 % MessageID% .xmlWithin your send port properties, set the Destination folder to C:\Temp\Out\, and set the and File name to %MessageID%.xml.
  2. 在文件发送端口属性中,将筛选器设置为 BTS.ReceivePortName == <Receive Port Name>In your File send port properties, set the Filters to BTS.ReceivePortName == <Receive Port Name>.
  3. 启动 Office 365 Outlook 电子邮件接收位置和文件发送端口。Start the Office 365 Outlook Email receive location and the File send port.
  4. 查找目标文件夹中的邮件(c:\temp\out)。Look for messages in the destination folder (c:\temp\out).

默认情况下,将升级接收管道中的以下属性:The following properties from the Receive Pipeline are promoted by default:

属性名称Property Name 升级的属性Promoted Property
仅次于Importance OfficeMail.ReceivedMailImportanceOfficeMail.ReceivedMailImportance
主题Subject OfficeMail.ReceivedMailSubjectOfficeMail.ReceivedMailSubject
SenderNameSenderName OfficeMail.SenderNameOfficeMail.SenderName
文本框SenderAddress OfficeMail. 文本框OfficeMail.SenderAddress
HasAttachmentsHasAttachments OfficeMail.HasAttachmentsOfficeMail.HasAttachments

后续步骤Next steps

查看所有Office 365 适配器See all the Office 365 adapters.