The issue was System.Mail.SmtpException
.
This exception was being thrown since the network was not able to connect or resolve the smtpserver (smtp.gmail.com)
Because of this, the email was not sent and there was still an error.
So I just used
try {
// send the email
} catch (System.Mail.SmtpException e) {
// error message
}