Created
June 24, 2015 07:30
-
-
Save zaki-yama/5808253ab8de1077e315 to your computer and use it in GitHub Desktop.
[Apex]メール送信時に「活動履歴」にも残す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); | |
| // この書き方だと活動履歴には残らない | |
| // String[] toAddresses = new String[] { [Toに指定したいアドレス] }; | |
| // mail.setToAddresses(toAddresses); | |
| Contact to = [SELECT Id FROM Contact WHERE Id = ...]; | |
| mail.setTargetObjectId(c.Id); | |
| List<String> ccAddresses = new List<String> { [Ccに指定したいアドレス] }; | |
| mail.setCcAddresses(ccAddresses); | |
| mail.setSubject('Sample mail'); | |
| mail.setSaveAsActivity(true); // これが重要 | |
| mail.setWhatId( [ケースなどのId] ); // ケースなどのレコードの「活動履歴」にも残す場合 | |
| mail.setPlainTextBody('Hello, world!'); | |
| Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment