アクティビティ
最新
バナーの背景画像
生産性を高めるアクティビティ
最終更新日 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 という名前の新しい引数を作成します。[方向] を [出力] に設定し、[型]MailMessage に設定し、[値]mailMessage に設定します。
      注:
      必ず sender@outlook.comreceiver@outlook.com のメール アドレスを望ましいメール アドレスに置き換えてください。

      添付のプロジェクトでは、さまざまなメール アカウントが使用されています。

  4. [コードを呼び出し] アクティビティの下に [メール メッセージを保存] アクティビティをドラッグします。

    • [メール メッセージ] フィールドに変数 mailMessage を追加します。
    • "Output\email.eml"[ファイル パス] フィールドに追加します。
  5. [添付ファイルを保存] アクティビティを、[メール メッセージを保存] アクティビティの下にドラッグします。

    • [メール メッセージ] フィールドに変数 mailMessage を追加します。
    • "Output\Attachments"[フォルダー パス] フィールドに追加します。
    • ワークフローは次のようになります。



  6. プロセスを実行します。メールは、設定した送信者と受信者を使用して、ファイルを添付した状態で作成されます。その後、メールと添付ファイルは指定されたフォルダーに保存されます。

    注: プロジェクトの zip ファイルの出力フォルダーには既に添付ファイルが含まれています。フォルダーは空である必要があります。

Was this page helpful?

サポートを受ける
RPA について学ぶ - オートメーション コース
UiPath コミュニティ フォーラム
UiPath ロゴ (白)
信頼とセキュリティ
© 2005-2024 UiPath. All rights reserved.