I have 2 Users that belong to the queue 'Sales' with the Send Email to Members checked.

I have an online app that creates a new lead, and sets various lead fields, but the email is not sent to members of the queue. Code:

Lead l = new Lead();  
l.OwnerId = [Id of Sales Queue];  
Database.DMLOptions dmlOpt = new Database.DMLOptions();  
dmlOpt.EmailHeader.triggerUserEmail = true;  
database.insert(l, dmlOpt);

I am aware that there is another option to use default assignment rules which would reassign the queue and send the email to the queue members, however I do not want assignment rules to be evaluated, I only want to send the email to the member of the queues upon insert.

Why is no email sent?


You can configure a workflow rule on Lead object which will fire during creation only. And in the workflow action, send email to the Lead owner.

This email should go to all the queue members if owner is queue otherwise, it will go the user.

  • 1
    I only want the email sent for leads that are inserted by the app, not all leads that are inserted, any ideas? – ZeeDawg May 10 '18 at 17:34
  • 1
    Create a checkbox in Lead object and mark it true during insert from App. Use that checkbox as selection criteria to send email – Santanu Boral May 10 '18 at 17:35

A solution I found to this problem was:
- insert the lead without specifying the Owner
- subsequently update the owner to the appropriate queue using

database.update(l, dmlOpt);

This resulted in an email being sent to the queue members.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.