- 入门指南
- 教程
- 自动化项目
- 创建自动化
- 故障排除

StudioX user guide
教程:保存、重命名和移动附件
在本教程中,我们将创建一个自动化程序,将 Outlook 搜索文件夹中所有电子邮件的附件保存到您的计算机,然后将这些文件移动到计算机上的另一个文件夹,并通过在文件名中添加今天的日期来重命名它们。要重命名文件,我们将使用 StudioX 中可用的默认项目笔记本中的公式。
We will create a project and start by adding a Use Desktop Outlook App activity to indicate the Outlook account to use. Inside this activity, we will add a For Each Email activity and then the common scenario Iterate through mail attachments to indicate that we want to save the attachments for each email and then process each file after it is saved. Iterating through each file in the folder where the attachments are saved, we will then add a Write Cell activity to copy the file name and edit the name in the Project Notebook, and a Move File activity to move the file with the updated name to another folder.
-
在计算机上创建两个文件夹,并在 Outlook 中创建一个搜索文件夹。
- 在计算机 C 盘的根目录中创建两个文件夹,分别称为“输入”和“输出”。
- 打开 Outlook,然后右键单击“文件夹”窗格中的“搜索文件夹”,然后选择“新建搜索文件夹”。
- 在“新建搜索文件夹”窗口中,选择“创建自定义搜索文件夹” > “选择”。
- 在“自定义搜索文件夹”窗口的“名称”框中输入“上周的附件”,然后选择“条件”。
- 在“搜索文件夹条件”窗口的“消息”选项卡中,从“时间”旁边的下拉菜单中选择“已接收”和“上周”。
- 在“更多选择”选项卡中选择“仅项目”,然后从相邻的下拉菜单中选择一个或多个附件。
- 单击“确定”三次以关闭窗口并保存搜索文件夹。
-
设置项目。
-
将 Outlook 帐户添加到项目中。
-
在“活动”面板中,选择“邮件”选项卡,然后双击“使用桌面 Outlook App”。该活动随即添加到“设计器”面板中。
-
在活动中,“帐户”字段中已经选择默认的电子邮件帐户。如果您要使用其他帐户,请从下拉菜单中选择。
在“引用为”字段中,保留默认值
Outlook作为在自动化中引用该帐户时使用的名称。
-
-
遍历 Outlook 搜索文件夹中的消息。
-
在“活动”面板中,将“遍历电子邮件”活动拖放到“使用桌面 Outlook App”活动中。
-
In the For Each Email activity, click Plus
on the right side of the In emails from field, and then select Outlook > [Search Folders] > [Last week's attachments]. Your selection is displayed in the field as Last week's attachments.您已指明要遍历 Outlook 文件夹“Last week's attachments”中的电子邮件。

-
-
遍历邮件附件。
-
Click Add activity
inside the For Each Email activity and then, in the search box at the top of the screen, select the common scenario Iterate through mail attachments. -
浏览并选择“收件箱”文件夹,然后单击“确定” 。
将两个活动添加到您的项目中:
-
Save Email Attachments with
CurrentMailselected for the Email field, indicating that the attachments from the current mail in the iteration should be saved to the In folder that is indicated by theC:\Inselected in the Save to folder field. -
“遍历文件夹中的文件”,在“文件夹”字段中选择
C:\In,以指明您将遍历此文件夹中的文件。如果您单击“开始”以立即执行自动化,则邮件附件将下载并保存到“收件箱”文件夹中。

-
-
-
重命名邮件附件并将其移动到其他文件夹。
-
在“活动”面板中,选择“Excel”选项卡,然后将“使用 Excel 文件”活动拖放到“遍历文件夹中的文件”活动中。
-
Add a Write Cell activity inside the Use Excel File activity.
-
在“写入单元格”活动中:
- 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 Notebook > 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.
- Click Plus
-
Click Notebook in the StudioX ribbon. In the Project_Notebook.xslx file, go to the File sheet, update the value in the named cell
ReformattedFileName(B14) to the following:=FileNameNoExtension & "-" & YYYYMMDD & "." & FileExtensionand save the file. This formula adds the current date at the end of the file name. -
在活动面板中,选择“文件”选项卡,然后将“移动文件”活动拖放到“便利文件夹中的文件”内的“写入单元格”活动之后。
-
在“移动文件”活动中:
- 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 Notebook > File [Sheet] > ReformattedFileName [Cell]. The path in the Text Builder should look like this: C:\Out\[Notes] File!ReformattedFileName. - Make sure the Overwrite option is selected.
- Click Plus
-
Click Save in the Text Builder.

-
在 StudioX 功能区中单击“保存”,以保存自动化,然后单击“运行”来执行此自动化。
The attachments from each email in the Outlook Search Folder are saved to the In folder on the computer, then today's date is added to the name and they are moved to the Out folder.Download example
-