How to access workflow variables within email task

I am wondering how I get the ProcessInstanceId to send in an email task.
I have tried:
{ProcessInstanceId} {ProcessInstanceId[‘pid’]}
#{ProcessInstanceId.pid}
#{ProcessInstanceId[‘pid’]}

And about a million other combinations.
If anyone is able to help direct me as to how to access workflow runtime variables in things like httptask or emailtask, I would greatly appreciate it.

#{processVariables[‘accountNumber’]}
was an example given in the docs about injected variables. Another thing I am unclear on is when to use $ and when to use #?

Thank you!

Hi @Jared

You can use this:

${execution.getProcessInstanceId()}