1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Power Automate DesktopでGmail送信!

Last updated at Posted at 2023-04-28

Gmailの自動配信の様子

みなさん、こんにちは。
紙、印鑑、手作業に埋もれて業務をしているX世代の会社員です。

Power Automate Desktopでメールの自動化を目指し作成しています。しかし、Outlookでのメール自動送信は、すんなり作成出来ましたが、Gmailだとうまく動きません。業務では、Gmailしか使用していないので、どうしてもGmailで自動送信したいです。

Outlookで自動送信はこちら

参考記事を見つけ、いざ設定!

参考にした記事はこちら

Power Automate Desktopではありませんが、同じRPAツールのUiPathの設定を参考にさせていただきました。

使用するもの

・Power Automate Desktop
・Gmail
・Excel

Excelの準備

Excelシートにデータを貼り付けていきます。
2023-04-23 (3).png

注:必ずデータをテーブルで保存してください。
2023-05-02.png

Power Automate Desktopの設定

2023-04-29 (1).png

フローのソースコード

Gmail自動送信
Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\miyabe.m\\OneDrive\\プロトタイピング2期\\0422_lesson3\\確定回収用割り戻し計算確認書回収チェック表_練習.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
Excel.SetActiveWorksheet.ActivateWorksheetByName Instance: ExcelInstance Name: $'''メール送信本文'''
Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
LOOP FOREACH CurrentItem IN ExcelData
    Email.SendEmail.AuthenticateAndSend SMTPServer: $'''smtp.gmail.com''' Port: 465 EnableSSL: True Username: $'''miyabe.m@ga.mv-tokai.com''' Password: P'AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAZfwg9V/njEmvZ6u7yej+QwQAAAACAAAAAAADZgAAwAAAABAAAAAbgzbpIqI/HWO8YppqEKD3AAAAAASAAACgAAAAEAAAAFHGhS7z0bOlqdKTV//psLgoAAAAB95TsRcdOAtPRMRNEBbCiNSKsECOaAik8cFJBVK/zZFiyUBDK5eQ/RQAAAAMw1g7iLvTiNFlY/bxpPr++8vmRQ==' AcceptUntrustedCertificates: False SendFrom: $'''miyabe.m@gmail.com''' SenderDisplayName: $'''宮部光博''' SendTo: CurrentItem['To'] CC: CurrentItem['Cc'] BCC: CurrentItem['Bcc'] Subject: CurrentItem['件名'] Body: $'''%CurrentItem['本文']%
契約No %CurrentItem['契約No']%
件名 %CurrentItem['件名2']%
期間 %CurrentItem['期間開始']%%CurrentItem['期間終了']%''' IsBodyHtml: False
END

ポイントは、パスワード設定

Googleアカウントのセキュリティで「2段階認証プロセス」を有効にして、「アプリ パスワード」を生成する必要があります。

Googleアカウントのセキュリティはこちら

「メールの送信」アクションの設定

ここのパスワード設定が、Gmailの「ログインパスワード」ではなく、「アプリパスワード」でした。
2023-04-29 (2).png

ちょっとしたことですが、このパスワード設定が、アプリパスワードだとわかるのに苦労しました。
パスワードって色々ありますね~。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?