How to find un-Used Workflow Email ALerts?

The details you seek are in the ToolingAPI, but are a little difficult to access.

What you want is the WorkflowRule.Metadata. This contains the actions, which is a WorkflowActionReference collection. Essentially, these relate the WorkflowRule to the WorkflowAlert.

Of course, the problem with doing this via the Tooling API is that you can only query the Metadata field for a single record at a time. So you would need to get each WorkflowRule and slowly build up a complete collection of all the referenced workflow alerts. And then you can compare that to the actual list to find which ones aren't used.


Here is a view of that data from a debugging session against a WorkflowRule.Metadata.

enter image description here.

DFB__Notify_Customer corresponds to the WorkflowAlert NamespacePrefix and DeveloperName fields in my dev org.