Apex Send Mail の注意点

例:

Messaging.sendEmail(emails, false);

メール送信すると、送信失敗しました、 エラー:Messaging.SendEmailResult[getErrors=(Messaging.SendEmailError[getTargetObjectId=null;]);isSuccess=false;]

Debugするため、 Messaging.sendEmail(emails, true);
に変更して、 原因は、コードに setTargetObjectId methodを使いましたので
エラーが発生しました
 setTargetObjectIdは Contact/Lead/User だけ使えます、使うと、該当標準メール項目利用して、送信可能

説明:
Required if using a template, optional otherwise. The ID of the contact, lead, or user to which the email will be sent. The ID you specify sets the context and ensures that merge fields in the template contain the correct data

コメントを残す

メールアドレスが公開されることはありません。