activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

生产力活动

上次更新日期 2026年3月6日

在本地创建并保存电子邮件

以下示例说明了如何创建和保存带有附件的 Outlook 邮件。它显示了保存邮件消息保存附件等活动。您可以在“UiPath.Mail.Activities”包中找到这些活动。

此自动化流程的构建方法如下:

  1. 打开 Studio ,创建一个新“流程”

  2. 将“序列”容器拖动至“工作流设计器”

    • 创建以下变量:

      变量名称变量类型默认值
      mailMessageSystem.Collections.Generic.List<System.Net.Mail.MailMessage>
  3. 将“调用代码”活动拖动至“序列”容器中。

    • 单击“编辑代码”按钮并添加以下代码:

      "'Create a message and set up the recipients.
      Dim sender As String = "sender@outlook.com"
      Dim receiver As String = "receiver@outlook.com"
      Dim subject As String = "Project plan"
      Dim body As String = "See the attached document."
      message = New MailMessage(sender, receiver, subject, body)
      'Create the file attachment for this email message.
      Dim data As Attachment = New Attachment("Input\Project-plan.xlsx")
      'Add the file attachment to the email message.
      message.Attachments.Add(data)"
      "'Create a message and set up the recipients.
      Dim sender As String = "sender@outlook.com"
      Dim receiver As String = "receiver@outlook.com"
      Dim subject As String = "Project plan"
      Dim body As String = "See the attached document."
      message = New MailMessage(sender, receiver, subject, body)
      'Create the file attachment for this email message.
      Dim data As Attachment = New Attachment("Input\Project-plan.xlsx")
      'Add the file attachment to the email message.
      message.Attachments.Add(data)"
      
    • 单击“编辑参数”按钮并创建一个名为 message 的新参数,其中“方向”设置为 Out,“类型”设置为 MailMessage,“值”设置为 mailMessage

    备注:

    确保将 sender@outlook.comreceiver@outlook.com 电子邮件地址替换为所需的电子邮件地址。 附加的项目中使用了不同的电子邮件帐户。

  4. 将“保存邮件消息”活动拖动到“调用代码”活动下方。

    • 在“邮件消息”字段中添加“mailMessage”变量。
    • 在“文件路径”字段中添加表达式“"Output\email.eml"”。
  5. 将“保存附件”活动拖动到“保存邮件消息”活动下方。

    • 在“邮件消息”字段中添加“mailMessage”变量。
    • 在“文件夹路径”字段中添加表达式 "Output\Attachments"
    • 您的工作流应如下所示:

    docs image

  6. 运行流程。系统将使用您设置的发件人和收件人以及附件来创建邮件。然后,邮件和附件将保存到指定的文件夹中。

    备注:

    项目 ZIP 文件中的输出文件夹已包含附件,该文件夹应为空。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新