LoginSignup
1
3

More than 3 years have passed since last update.

【salesforce】Apexでメールにファイル添付作ってみた

Posted at

前回の機能にちょっと付け加えてみました。

【salesforce】Apexを使ってメールを送信する機能を実装してみた

sample
//添付ファイルの初期化
Messaging.EmailFileAttachment temp = new Messaging.EmailFileAttachment();
//Blob値をセット
temp.setBody(tempFile);
//コンテントタイプを指定
temp.setContentType(cType);
//送信するメールの添付ファイルに作成した添付ファイルをセット
mail.setFileAttachments(new List<Messaging.EmailFileAttachment>{temp});

で送信って感じです。

VF側では

sample
<apex:inputFile value="{!tempFile}" contentType="{!cType}"/>

こんな感じで値を渡しました。

コンテントタイプを指定しないとメールでは見ることができなかったので、
最低限必要なんだろうと思います。

もっと色々できそうですね。

奥が深い。。。

profile

生まれも育ちも大阪の浪速中の浪速っ子が30才未経験からITエンジニアとして生きるブログもやってます。
よかったらみてください:muscle_tone2:

PVアクセスランキング にほんブログ村

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