I am creating an android application using Xamarin on Visual Studio 2017. I am trying to run an automated email feature that sends emails when a user registers an account with my application. I am using the NuGet package MailKit for this.
var mailSender = new MailboxAddress("useremail@gmail.com");
When I use this code, it creates the MailboxAddress perfectly fine and I can send an email to the address I have specified without any errors. However when I use this code:
string email = getEmail.Text;
var mailSender = new MailboxAddress(email);
I am going into break mode with an unhandled exception. The variable email definitely has a value in it which I have inspected whilst debugging.
Any idea as to why it wouldn't let me create this object using a variable instead of a hard coded string?
Thanks