活动
最新
False
横幅背景图像
生产力活动
上次更新日期 2024年4月26日

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

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

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

  1. 打开 Studio ,创建一个新“流程”
  2. 工作流设计器中拖动“序列”容器。

    • 创建以下变量:

      变量名称

      变量类型

      默认值

      mailMessage

      System.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"
    • 您的工作流应如下所示:



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

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

此页面是否有帮助?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath 白色徽标
信任与安全
© 2005-2024 UiPath. All rights reserved.