UiPath Documentation
studiox
2024.10
true

StudioX user guide

最終更新日時 2026年4月30日

チュートリアル: 添付ファイルを保存する、名前を変更する、移動する

このチュートリアルでは、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.

  1. コンピューターと Outlook の検索フォルダーに 2 つのフォルダーを作成する

    1. コンピューターの C: ドライブのルートに InOut という名前の 2 つのフォルダーを作成します。
    2. Outlook を開き、[フォルダー] ペインで [検索フォルダー] を右クリックし、[新しい検索フォルダー] を選択します。
    3. [新しい検索フォルダー] ウィンドウで、[カスタム検索フォルダーを作成する] > [選択] を選択します。
    4. [検索フォルダーのカスタマイズ] ウィンドウで、[名前] ボックスに「Last week's attachments」と入力し、[条件] を選択します。
    5. [検索フォルダーの条件] ウィンドウの [メッセージ] タブで、[時間の条件] の横にあるドロップダウン メニューから [受信日時][先週] を選択します。
    6. [詳細設定] タブで、[添付ファイル] を選択し、隣接するドロップダウン メニューから 1 つ以上の添付ファイルを選択します。
    7. [OK] を 3 回クリックしてウィンドウを閉じて、検索フォルダーを保存します。
  2. プロジェクトを設定します。

  3. Outlook アカウントをプロジェクトに追加する

    1. [アクティビティ] パネルで [メール] タブを選択し、[デスクトップ版 Outlook アプリを使用] をダブルクリックします。アクティビティがデザイナー パネルに追加されます。

    2. このアクティビティの [アカウント] フィールドには、あらかじめ既定のメール アカウントが入力されています。別のアカウントを使用する場合は、ドロップダウン メニューから選択します。

      [参照名] フィールドは既定値 Outlook のままとして、オートメーションでアカウントを参照するときは、この名前を使用します。

  4. Outlook の検索フォルダーのメッセージを反復処理する

    1. [アクティビティ] パネルで [繰り返し (各メール)] アクティビティをドラッグし、[デスクトップ版 Outlook アプリを使用] アクティビティ内にドロップします。

    2. 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 フォルダーのメールを反復処理するように指定したことになります。

      ドキュメントの画像

  5. メールの添付ファイルを反復処理する

    1. 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.

    2. In フォルダーを参照して選択し、[OK] をクリックします。

      次の 2 つのアクティビティがプロジェクトに追加されます。

      • Save Email Attachments with CurrentMail selected 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 the C:\In selected in the Save to folder field.

      • [繰り返し (フォルダー内の各ファイル)] では、[フォルダー] フィールドで C:\In が選択されており、このフォルダーにあるファイルを反復処理することを示しています。

        [開始] をクリックすると、オートメーションがすぐに実行され、メールの添付ファイルがダウンロードされて In フォルダーに保存されます。

        ドキュメントの画像

  6. メールの添付ファイルの名前を変更して別のフォルダーに移動する

    1. [アクティビティ] パネルで [Excel] タブを選択し、[Excel ファイルを使用] アクティビティをドラッグして [繰り返し (フォルダー内の各ファイル)] アクティビティ内にドロップします。

    2. Add a Write Cell activity inside the Use Excel File activity.

    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 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.
    4. 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 & "." & FileExtension and save the file. This formula adds the current date at the end of the file name.

    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 Notebook > File [Sheet] > ReformattedFileName [Cell]. The path in the Text Builder should look like this: C:\Out\[Notes] File!ReformattedFileName.
      • [上書き] オプションが選択されていることを確認してください。
    7. テキスト ビルダーで [保存] をクリックします。

      ドキュメントの画像

    8. 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

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得