- 发行说明
- 入门指南
- 教程
- 自动化项目
- 创建自动化
- 故障排除
在本教程中,我们将创建一个自动化项目,将 Outlook 搜索文件夹中所有电子邮件的附件保存到名称中包含今天日期的文件夹中,并创建一个文本文件,其中将复制所有文件名。自动化程序将首先检查用于保存文件的文件夹是否已经存在,如果是这种情况,它将询问用户是否应删除并重新创建该文件夹,或者是否应在下载附件之前将内容移动到另一个文件夹中。
我们将首先添加“存在文件”活动,以检查要下载附件的文件夹是否已经存在。然后添加一个“If 条件”活动,并在其中添加一个“创建文件夹”活动,以便在文件夹不存在时创建该文件夹。如果该文件夹确实存在,我们将添加一个“消息框”活动,以提示用户选择如何继续。根据用户的选择,系统将随后推出另一个包含两组要执行的独立活动的“IF 条件”活动,这两组独立活动分别为删除文件夹并重新创建,及将现有文件夹移动到其他位置。然后,我们将添加活动以保存 Outlook 中的附件,然后在目标文件夹中创建两个文件夹,其中一个用于创建文本文件,其中包含已保存文件的相关信息,另一个用于在添加后移动文件将文件信息添加到文本文件。要将今天的日期添加到文件夹名称中,我们将使用项目笔记本中内置的公式。
-
步骤 1:在 Outlook 中创建搜索文件夹。
- 打开 Outlook,然后右键单击“文件夹”窗格中的“搜索文件夹”,然后选择“新建搜索文件夹”。
- 在“新建搜索文件夹”窗口中,选择“创建自定义搜索文件夹” > “选择”。
- 在“自定义搜索文件夹”窗口的“名称”框中输入“上周的附件”,然后选择“条件”。
- 在“搜索文件夹条件”窗口的“消息”选项卡中,从“时间”旁边的下拉菜单中选择“已接收”和“上周”。
- From the More Choices tab, select Only items with, and then one or more attachments from the adjacent drop-down menu.
- 单击“确定”三次以关闭窗口并保存搜索文件夹。
-
步骤 2:建立项目。
-
步骤 3:检查用于保存附件的文件夹是否存在。
-
在“活动”面板中,选择“文件”选项卡,然后双击“存在文件夹”。“存在文件夹”活动随即添加到“设计器”面板中。
-
在“文件夹存在”活动中:
-
Click Plus
on the right side of the Folder path field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder. -
Click Plus
on the right side of the Output field, and then select Save for Later Use. Give the value the name Folder 'MailAttachments' Existsand click OK您已指明要检查是否存在具有今天日期的文件夹 MailAttachments,并且希望保存此验证的输出结果以供以后在自动化中使用。
-
-
-
步骤 4:添加在文件夹存在和不存在时要执行的活动。
-
在“活动”面板中,选择“常用”选项卡,然后将“IF 条件”活动拖放到“存在文件夹”活动下方。“IF 条件”活动随即添加到“设计器”面板中。
-
在 If 活动中:
- 单击“显示 Else”以添加“Else”分支。
- Click Plus
on the right side of the Condition field, and then select Condition Builder.
-
在条件生成器中,添加条件“如果文件夹存在”:
-
Click Plus
on the right side of the field on the left, and then select Use Saved Value > Folder 'MailAttachments' Exists to select the output of the Folder Exists activity as the value to evaluate in the condition. -
从中间的下拉菜单中,选择“为 True”,然后单击“保存”。
如果文件夹存在,将执行您在 If 活动的 Then 分支中添加的活动。如果文件夹不存在,将执行添加到 Else 分支的活动。
-
-
在“活动”面板中,选择“文件”选项卡,然后将“创建文件夹”活动拖放到 If 活动的“Else”分支中。“创建文件夹”活动随即添加到“设计器”面板中。
-
In the Create Folder activity, click Plus
on the right side of the Folder name field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder.您已指明,如果文件夹 MailAttachments 尚不存在,您要创建该文件夹,并且要在名称中包含今天的日期。
-
在“活动”面板中,选择“常用”选项卡,然后将“消息框”活动拖放到 If 活动的“Else”分支中。“消息框”活动随即添加到“设计器”面板中。
-
单击“消息框”活动右侧的“加号”
,然后选择“文本”。在文本生成器中,输入要显示给用户的消息,例如:An older MailAttachments_ folder already exists. Do you want to delete the old one and create a new one? If you choose "No", the old one will be moved to a backup folder and a new one will be created.. To add the current date to the folder name, place the mouse cursor afterMailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. Click Save in the Text Builder. -
选择已添加到“设计器”面板中的“消息框”活动,然后打开其“属性”面板:
-
从“按钮”下拉菜单中,选择“是/否”。
-
单击字段右侧的“加号”
,然后选择“保存以备后用”并为值命名,例如ChosenButton from Message Box FolderAlreadyExists。您已表明要通过显示带有两个按钮选项“是”和“否”的消息框来提示用户选择是否应删除该文件夹(如果该文件夹已存在)。用户的选择将被保存以供以后在自动化中使用。
-
-
-
步骤 5:添加当用户选择删除任何具有相同名称的现有文件夹或将其移动时执行的活动。
-
在“活动”面板中,选择“常用”选项卡,然后将另一个“IF 条件”活动拖放到第一个“IF 条件”活动分支的“消息框”下方。“IF 条件”活动随即添加到“设计器”面板中。
-
在 If 活动中:
- 单击“显示 Else”以添加“Else”分支。
- Click Plus
on the right side of the Condition field, and then select Condition Builder.
-
在条件生成器中,添加条件“如果用户点击‘是’”:
-
Click Plus
on the right side of the field on the left, and then select Use Saved Value > ChosenButton from Message Box FolderAlreadyExists. This selects the user's choice (the button clicked in the Message Box activity) as the value to evaluate in the condition. -
从中间的下拉菜单中,选择“等于”。
-
单击字段右侧的“加号”
,然后选择文本。在文本生成器中,输入Yes,然后单击“保存”两次。如果用户点击“是”,将执行您在 If 活动的 Then 分支中添加的活动。如果用户点击“否”,将执行添加到 Else 分支的活动。
-
-
在“活动”面板中,选择“文件”选项卡,然后将“删除文件夹” 活动拖放到第二个“IF 条件”活动的“Then”分支中。“删除文件夹”活动随即添加到“设计器”面板中。
-
In the Delete Folder activity, click Plus
on the right side of the Folder name field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder.您已指明要删除名称中包含今天日期的现有文件夹 MailAttachments。
-
在“活动”面板中,将“创建文件夹”活动拖放到“删除文件夹”下面第二个“If”活动的 True 分支内。“创建文件夹”活动随即添加到“设计器”面板中。
-
In the Create Folder activity, click Plus
on the right side of the Folder name field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder.您已指明要新建名称中包含今天日期的“MailAttachments”文件夹。
-
在“活动”面板中,将“创建文件夹”活动拖放到第二个“IF 条件”活动的“Else”分支内。“创建文件夹”活动随即添加到“设计器”面板中。
-
在“创建文件夹”活动中,单击加号
单击“文件夹名称”字段右侧的,然后选择“文本” 。在文本生成器中,输入C:\old_MailAttachments,然后单击“保存” 。您已指明要创建一个名为 old_MailAttachments 的新文件夹。
-
在“活动”面板中,将“移动文件夹”活动拖放到“创建文件夹”下方第二个“IF 条件”活动的“Else”分支内。“移动文件夹”活动随即添加到“设计器”面板中。
-
在“移动文件夹”活动中:
-
Click Plus
on the right side of the From field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder. -
单击字段右侧的“加号”
单击“至”字段右侧的,然后选择“文本” 。在文本生成器中,输入C:\old_MailAttachments,然后单击“保存” 。您已指明要将名称中包含今天日期的现有文件夹 MailAttachments 移动到名为 old_MailAttachments 的文件夹中。
-
-
-
步骤 6:保存 Outlook 搜索文件夹中的附件。
-
在“活动”面板中,选择“邮件”选项卡,然后将“使用桌面 Outlook App”活动拖放到第一个“IF 条件”活动下方,作为项目中的最后一个活动。该活动随即添加到“设计器”面板中。
-
在活动中,“帐户”字段中已经选择默认的电子邮件帐户。如果您要使用其他帐户,请从下拉菜单中选择。
在“引用为”字段中,保留默认值
Outlook作为在自动化中引用该帐户时使用的名称。 -
在“遍历电子邮件”活动中,单击加号
,然后选择“Outlook” > “[搜索文件夹]” > “[上一周的附件]” ,以选择在帐户Outlook中创建的搜索文件夹。您的选择在“邮件使用来源”字段中显示为“上一周的附件”。您已指明要遍历搜索文件夹“Last week's attachments”中的电子邮件。
-
在“活动”面板中,将“保存电子邮件附件” 活动拖放到“遍历电子邮件”活动中。
-
在“保存电子邮件附件”活动中:
-
Click Plus
on the right side of the From message field, and then select CurrentMail to indicate that the email whose attachments you want to save is the current email you are iterating through. -
Click Plus
on the right side of the Save to folder field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD. Click Save in the Text Builder.您已指明要将附件保存到名称中包含今天日期的文件夹“MailAttachments”。
-
-
-
步骤 7:创建文本文件,在其中添加有关文件的信息,创建子文件夹,在其中保存文本文件,然后移动附件。
-
在“活动”面板中,选择“文件”选项卡,然后将“创建文件夹”活动拖放到“使用桌面 Outlook App”下面,作为该项目中最后一个活动。“创建文件夹”活动随即添加到“设计器”面板中。
-
In the Create Folder activity, click Plus
on the right side of the Folder name field, and then select Text. In the Text Builder, enter C:\MailAttachments_, then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Output. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Output. Click Save in the Text Builder.您已指明要在 MailAttachments 文件夹中创建一个名为 Output 的子文件夹。
-
在“活动”面板中,将“创建文件”活动拖放到最后一个“创建文件夹”下方。
-
In the Create File activity, click Plus
on the right side of the File location field, and then select Text. In the Text Builder, enter C:\MailAttachments_, then, from the Plus
menu on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Output\AttachmentsDetails.txt. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Output\AttachmentsDetails.txt. Click Save in the Text Builder.您已指明要在 Output 子文件夹中创建一个名为 AttachmentsDetails.txt 的文件。
-
在“活动”面板中,将“写入文本文件”活动拖放到“创建文件”活动下方。“写入文本文件”活动随即添加到“设计器”面板中。
-
在“写入文本文件”活动中:
-
Click Plus
on the right side of the Text field, and then select Text. In the Text Builder, enter Files received in the last week:. Click Save in the Text Builder. -
Click Plus
on the right side of the Write to filename field, and then select Text. In the Text Builder, enter C:\MailAttachments_, then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Output\AttachmentsDetails.txt. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Output\AttachmentsDetails.txt. Click Save in the Text Builder.您已指明要在文件 AttachmentsDetails.txt 中输入文本“上周收到的文件:”。
-
-
在“活动”面板中,将“创建文件夹”活动拖放到“写入文本文件”活动下方。“创建文件夹”活动随即添加到“设计器”面板中。
-
In the Create Folder activity, click Plus
on the right side of the Folder name field, and then select Text. In the Text Builder, enter C:\MailAttachments_, then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Processed. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Processed. Click Save in the Text Builder.您已指明要在“MailAttachments”文件夹中创建一个名为“Processed”的子文件夹。
-
-
步骤 8:遍历文件,将有关每个文件的信息添加到文本文件,然后将每个文件移至“已处理”子文件夹。
Outlook 搜索文件夹中的附件将保存到“邮件附件”文件夹,在“输出”子文件夹中创建一个文本文件,其中包含有关文件的信息,然后将这些文件移动到“已处理”子文件夹中。如果您再次运行该项目,由于该文件夹是在第一次运行时创建的,系统会提示您选择要对现有文件夹执行的操作,然后再执行其他活动。
-
在“活动”面板中,将“遍历文件夹中的文件”活动拖放到最后一个“创建文件夹”活动下方。“遍历文件夹中的文件”活动随即添加到“设计器”面板中。
-
In the For Each File in Folder activity, click Plus
on the right side of the Folder field, and then select Text. In the Text Builder, enter C:\MailAttachments_, and then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell]. The text should look like this: C:\MailAttachments_[Excel] Date!YYYYMMDD\Output. Click Save in the Text Builder.您已指明要迭代访问“MailAttachments”文件夹中的文件。
-
在“活动”面板中,将“附加行”活动拖放到“遍历文件夹中的文件”活动中。“附加行”活动随即添加到“设计器”面板中。
-
在“附加范围”活动中:
-
Click Plus
on the right side of the Text field, and then select Text. In the Text Builder, enter FileName:, then, from the Plus
on the right side of the Text Builder, select CurrentFile > Name, then enter | LastModifiedDate:, then, from the Plus
on the right side of the Text Builder, select CurrentFile > Last Modified Date . The text should look like this: FileName: [CurrentFile] Name | LastModifiedDate: [CurrentFile] LastModifiedDate. Click Save in the Text Builder. -
Click Plus
on the right side of the Write to filename field, and then select Text. In the Text Builder, enter C:\MailAttachments_, then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Output\AttachmentsDetails.txt. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Output\AttachmentsDetails.txt. Click Save in the Text Builder.您已指明要在当前遍历访问的当前文件的 AttachmentsDetails.txt 文件中输入文件名和文件的修改时间。
-
-
在“活动”面板中,将“移动文件”活动拖放到“遍历文件夹中的文件”活动中的“附加行”下方。“移动文件”活动随即添加到“设计器”面板中。
-
在“移动文件”活动中:
-
Click Plus
on the right side of the From field, and then select CurrentFile > Full Path. -
Click Plus
on the right side of the To field, and then select Text, In the Text Builder, enter C:\MailAttachments_, then, from the Plus
on the right side of the Text Builder, select Project Notebook (Notes) > Date [Sheet] > YYYYMMDD [Cell], and then enter \Processed. The text should look like this:C:\MailAttachments_[Excel] Date!YYYYMMDD\Processed. Click Save in the Text Builder.您已指明要将当前遍历访问的文件移动到“Processed”子文件夹中。
-
-
在 StudioX 功能区中单击“保存”,以保存自动化,然后单击“运行”来执行此自动化。
-