Get user email using gmail imap

I am looping through unread email messages. But I am trying to get the sender’s email address. I have used the following;

mail.Sender.Address.ToString and store it in an assign block.

But I keep getting an error like so;

Source: Assign

Message: Object reference not set to an instance of an object. This error usually occurs when using a variable with no set value (not intialised).

Exception Type: NullReferenceException

I looked at the following answers but they did not help;