In the below sample code "lstPortalUser" is a list of partner users.Now I need to sent them an email with different body.
- List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
- for(User portalUser :lstPortalUser)
- {
- Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
- string body = 'Hi '+ portalUser.LastName;
- mail.setSubject('Test Subject');
- mail.setTargetObjectId(portalUser.Id);
- mail.setSaveAsActivity(false);
- mail.setHtmlBody(body);
- mails.add(mail);
- }
- Messaging.sendEmail(mails);
No comments:
Post a Comment