LoginSignup
17
10

More than 1 year has passed since last update.

[Tips] Power Automate から Teams に投稿するメッセージに画像を埋め込む

Posted at

Teamsに画像を埋め込んだメッセージを投稿する方法です。
このような感じで画像を埋め込みます。

image.png

方法はいたって簡単。Power Automateの"チャットまたはチャネルでメッセージを投稿する"アクションの Hosted Contentsという詳細オプションを指定するだけです。

image.png

ここに指定するのは特定の形式のJSON配列です。

[
    {
        "@microsoft.graph.temporaryId": "1",
        "contentBytes": "/9j/4SXpRXhpZgAASUkqAAgAAAAOAAABAwABAA....<base64 image>",
        "contentType": "image/jpg"
    },
    {
        "@microsoft.graph.temporaryId": "2",
        "contentBytes": "iVBORw0KGgoAAAAN....",
        "contentType": "image/png"
    }

]

contentBytes部分にはBase64化した画像ファイルを指定します。

メッセージ部分ですが、普通のHTMLで画像を表示するときのようにimgタグを使います。その際、src属性は以下のように指定します。

<img src="../hostedContents/[temporaryId]/$value">

[temporaryId]部分にはHosted Contentsで指定したtemporaryIdを入力します。

たったこれだけで、最大4MBまでの画像ファイルをメッセージに埋め込むことができます。もし画像の幅や高さを指定するのであれば、通常どおりheight="xxx"width="xxx" で指定してください。

References

17
10
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
17
10