UiPath Documentation
studiox
2022.10
false
StudioX 用户指南
重要 :
新发布内容的本地化可能需要 1-2 周的时间才能完成。

教程:保存、重命名和移动附件

在本教程中,我们将创建一个自动化程序,将 Outlook 搜索文件夹中所有电子邮件的附件保存到您的计算机,然后将这些文件移动到计算机上的另一个文件夹,并通过在文件名中添加今天的日期来重命名它们。要重命名文件,我们将使用 StudioX 中可用的默认项目笔记本中的公式。

我们将创建一个项目,并首先添加 “使用 Outlook 桌面 App”活动以指示要使用的 Outlook 帐户。在此活动中,我们将添加遍历电子邮件活动,然后添加常见场景遍历邮件附件,以指明我们要保存每封电子邮件的附件,然后在保存每个文件后对其进行处理。遍历保存附件的文件夹中的每个文件,然后添加一个写入单元格活动,以复制文件名并在项目笔记本中编辑名称,并添加一个移动文件活动,以将具有更新名称的文件移动到另一个文件夹文件夹中。

  1. 步骤 1:在计算机上创建两个文件夹,在 Outlook 中创建一个搜索文件夹。

    1. 在计算机 C 盘的根目录中创建两个文件夹,分别称为“输入”和“输出”
    2. 打开 Outlook,然后右键单击“文件夹”窗格中的“搜索文件夹”,然后选择“新建搜索文件夹”
    3. 在“新建搜索文件夹”窗口中,选择“创建自定义搜索文件夹” > “选择”
    4. 在“自定义搜索文件夹”窗口的“名称”框中输入“上周的附件”,然后选择“条件”
    5. 在“搜索文件夹条件”窗口的“消息”选项卡中,从“时间”旁边的下拉菜单中选择“已接收”和“上周”
    6. 在“更多选择”选项卡中选择“仅项目”,然后从相邻的下拉菜单中选择一个或多个附件。
    7. 单击“确定”三次以关闭窗口并保存搜索文件夹。
  2. 步骤 2:建立项目。

  3. 步骤 3:将 Outlook 帐户添加到项目中。

    1. 在“活动”面板中,选择“邮件”选项卡,然后双击“使用桌面 Outlook App”。该活动随即添加到“设计器”面板中。

    2. 在活动中,“帐户”字段中已经选择默认的电子邮件帐户。如果您要使用其他帐户,请从下拉菜单中选择。

      在“引用为”字段中,保留默认值 Outlook 作为在自动化中引用该帐户时使用的名称。

  4. 步骤 4:遍历 Outlook 搜索文件夹中的消息。

    1. 在“活动”面板中,将“遍历电子邮件”活动拖放到“使用桌面 Outlook App”活动中。

    2. “遍历电子邮件”活动中,单击加号文档图像 ,然后选择“Outlook” > “[搜索文件夹]” > “[上一周的附件]” 。您的选择在该字段中显示为Last week's attachments

      您已指明要遍历 Outlook 文件夹“Last week's attachments”中的电子邮件。

  5. 步骤 5:遍历邮件附件。

    1. 单击“添加活动”文档图像“遍历电子邮件”活动中,然后在屏幕顶部的搜索框中选择常见场景“遍历邮件附件”

    2. 浏览并选择“收件箱”文件夹,然后单击“确定”

      将两个活动添加到您的项目中:

      • Save Email Attachments with CurrentMail selected for the From Message field, indicating that the attachments from the current mail in the iteration should be saved to the In folder that is indicated by the C:\In selected in the Save to folder field.

      • “遍历文件夹中的文件”,在“文件夹”字段中选择 C:\In,以指明您将遍历此文件夹中的文件。

        如果您单击“开始”以立即执行自动化,则邮件附件将下载并保存到“收件箱”文件夹中。

  6. 步骤 6:重命名邮件附件并将其移动到另一个文件夹。

    1. 在“活动”面板中,选择“Excel”选项卡,然后将“使用 Excel 文件”活动拖放到“遍历文件夹中的文件”活动中。

    2. 在“使用 Excel 文件”活动中添加“写入单元格”活动。

    3. 在“写入单元格”活动中:

      • Click Plus文档图像 on the right side of the What to write field and then select CurrentFile > Full Name (includes full path) to indicate that we want to copy the full path of the current file in the iteration.
      • Click Plus文档图像 on the right side of the Where to write field and then select Project Notebook (Notes) > File [Sheet] > FullFileName [Cell] to indicate that we want to paste the full path of the current file in the iteration to the FullFileName named cell in the File sheet of the Project Notebook.
    4. 单击 StudioX 功能区中的“项目笔记本”。在 Project_Notebook.xslx 文件中,转到“File”工作表,将已命名单元格 ReformattedFileName (B14) 中的值更新为 =FileNameNoExtension & "-" & YYYYMMDD & "." & FileExtension 并保存文件。此公式会将当前日期添加到文件名的末尾。

    5. 在活动面板中,选择“文件”选项卡,然后将“移动文件”活动拖放到“便利文件夹中的文件”内的“写入单元格”活动之后。

    6. 在“移动文件”活动中:

      • Click Plus文档图像 on the right side of the From field and then select CurrentFile > Full Name (includes full path) to indicate the full path of the current file in the iteration.
      • Click Plus文档图像 on the right side of the To field and then select Text. In the Text Builder, enter C:\Out\ and then click Plus文档图像 on the right side of the window and select Project Notebook (Notes) > File [Sheet] > ReformattedFileName [Cell]. The path in the Text Builder should look like this: C:\Out\[Excel] File!ReformattedFileName.
      • Make sure the Overwrite option is selected.
    7. Click Save in the Text Builder.

    8. 在 StudioX 功能区中单击“保存”,以保存自动化,然后单击“运行”来执行此自动化。

      Outlook 搜索文件夹中每封电子邮件的附件都将保存到计算机上的“收件箱”文件夹中,程序会将今天的日期添加到文件名称中,然后将其移到“发件箱”文件夹中。

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新