function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SatyaPrustySatyaPrusty 

MassEmail to Users

My requirement is to send emails to multiple users. My apex works for contact and Lead object, but not for user object.sendEmail method executed successfully, but users are not reveing mails. Can anyone help why it is working for Contact/Lead but not for user

PranatiPranati

I am also facing the same issue. This particular problem is happening only for user objects in case of Massemail. I am pasting the required code.

 

public void SendEmail(List<Id> userids)

{

Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();

List<Id> userids = new List<Id> ();

userids.add('0053000000102UqAAI); // for userid

mail.setTargetObjectIds(userids); mail.setTemplateId('00XQ0000000HvBNMA0');

mail.setSaveAsActivity(false);

Messaging.SendEmailResult[] sendEmailResults = Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });

 

for (Messaging.SendEmailResult sendEmailResult : sendEmailResults) {

if(sendEmailResult.isSuccess()){ System.debug('success');

}

else{ System.debug(

'error');

}

}

}

 

The message is showing as success but actually I am not receving any email. But the same code base is working perfectly and I am receiving the email ( for same email address), if I am considering Leda/ Contact instead of user object. As per Massemail rule it should work fine for Lead, User and Contact objects.

 

Can anyone help me on this.

pon-de-lionpon-de-lion

Hey guys,

 

    No answers? any updates? is it a bug from SF??

 

thanks