Thanks for that link, very useful. But there seem to be no variables to pull the email address or name from the primary identity.
The loginname gives you the email address with which the user is logged in, not the email address stored with the identity.