[SalesForce] Sending Email to Queue Members On Lead Creation Without Using Assignment Rules

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?

Best Answer

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.