0
0

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 3 years have passed since last update.

Power Automate Desktopでメール本文取得しExcelに書き込む練習

Posted at

空白を削除

練習用に、以下記載のメールを、Power Automate Desktopで取得しExcelに書き込む処理を設定しました。
メール本文には余分な空白が入ってます。
Excelには、1ワードを1行ごと(タテに)、および列に(ヨコに)配置させます。

作品情報
映画賞
映画 レビュー
試 写会
注目映 画特集
インタビュー
新作映画評 論 

メール本文を取得した状態から記載します。
空白を削除します(置換します)。
「%' '%」を「%''%」に置き換えます。

image.png

空白行を削除

1行空きで取得されることがあります。

image.png

先頭が空白でない行のみ検索、取得します(残すようにします)。
「\S」は「すべての非空白文字」という指定です。

image.png

上記処理後の結果です。

image.png

Excelに書き込み

Excelへの書き込みは、セルの位置を指定しました。

image.png

上記処理で行ごとに書き込めます。

image.png

横並びに書き込む

横並びに書き込む場合、以下のようにしました。
もっと効率にいい方法があるかもしれませんが、今回は「LOOP」で取得した本文リストの行数分だけループさせました。
本文リストは「0」からカウントするので、「%Matches.Count - 1%」をLOOPの終了値としました。

image.png

リストに縦に並んだワードを、列方向に並べる指定をしてExcelに書き込みます。
「%Matches[LoopIndex]%」と指定することで、リスト(Matches)の1行目、2行目・・・(LoopIndex)と順に書き込むことができます。
書き込む方向は「列」に「%LoopIndex + 1%」と指定することで、1列目、2列目・・・と記載箇所が移るように設定しました。

image.png

上記処理の結果です。

image.png

1通のメールをピックアップする場合は上記のフローでできました。
複数メールを取得する場合、別の方法を考えることになります。
今度試す予定です。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?