This won't work: $usermail = $null | ConvertTo-Json
The variable "$usermail" is assigned a value of $null. Then $usermail is (supposed to be) passed into the pipe. But a $null value is never passed into a pipe. Because there's nothing in the pipe the "ConvertTo-Json" is never executed.
Does this produce what you were expecting?
[PSCustomObject]@{usermail=$null} | ConvertTo-Json
{
"usermail": null
}