Activity Forums Salesforce® Discussions How can I test Messaging.MassEmailMessage with checking targetobjectids in Salesforce?

  • Nikita

    Member
    December 10, 2019 at 6:49 am

    Hi,

    ou are using "List" just add your email address to the list so you will also get one copy of that mail.
    Please check below code (below skeleton for your reference):

    Messaging.MassEmailMessage massEmail = new Messaging.MassEmailMessage();
    massEmail.setTargetObjectIds(userIds);
    massEmail.setSaveAsActivity(false);
    massEmail.setTemplateId(templateId);
    List<Messaging.Email> emails = new List<Messaging.Email>{massEmail};
    emails.add('your email id');
    Messaging.SendEmailResult[] results = Messaging.sendEmail(emails, false);

    You can change user emailid and you can provide your email id. But your user will get notification about emailid change

  • Deepak

    Member
    December 10, 2019 at 1:59 pm

    Messaging.MassEmailMessage massEmail = new Messaging.MassEmailMessage();
    massEmail.setTargetObjectIds(userIds);
    massEmail.setSaveAsActivity(false);
    massEmail.setTemplateId(templateId);
    List<Messaging.Email> emails = new List<Messaging.Email>{massEmail};
    emails.add(‘your email id’);
    Messaging.SendEmailResult[] results = Messaging.sendEmail(emails, false);

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos