I have a problem sending the email when I run:
objClientSmtp.Send(mensagem_email)
In the + , "Non-public members" button, there shows the ClientSmtp.ServerSupportsEai
property with an exception: "Object reference not set to an instance of an object."
Where do I define this object?
Does anyone know a solution?
My code looks like this:
string emailBody = "";
string SmtpHost, SmtpPort, SmtpUser, SmtpPass, SmtpEmail;
SmtpHost = System.Configuration.ConfigurationSettings.AppSettings["SMTP_Host"].ToString();
SmtpPort = System.Configuration.ConfigurationSettings.AppSettings["SMTP_Port"].ToString();
SmtpUser = System.Configuration.ConfigurationSettings.AppSettings["SMTP_User"].ToString();
SmtpPass = System.Configuration.ConfigurationSettings.AppSettings["SMTP_Password"].ToString();
SmtpEmail = System.Configuration.ConfigurationSettings.AppSettings["SMTP_Email"].ToString();
PrjBureauVeritasIntranet.Classes.ClsLogin login = new PrjBureauVeritasIntranet.Classes.ClsLogin();
login.USUARIO = usuario;
PrjBureauVeritasIntranet.Classes.ClsSalas reserva = new PrjBureauVeritasIntranet.Classes.ClsSalas();
if (login.getEmailUsuario(usuario) != "Sem email")
{
System.Net.Mail.MailMessage email = new System.Net.Mail.MailMessage();
SmtpClient ClienteSmtp = new SmtpClient();
ClienteSmtp.Host = SmtpHost;
ClienteSmtp.Port = Convert.ToInt32(SmtpPort);
ClienteSmtp.Credentials = new NetworkCredential(SmtpUser, SmtpPass);
if (Request.QueryString["ssl"] != null)
{
ClienteSmtp.EnableSsl = true;
}
email.To.Add(login.getEmailUsuario(usuario));
email.From = new MailAddress(SmtpEmail);
email.Subject = "Confirmação de Reserva de Sala";
email.IsBodyHtml = true;
emailBody = login.getNomeUsuario(usuario);
emailBody += reserva.getMsgUltimaSalaReservada(usuario);
email.Body = emailBody;
ClienteSmtp.Send(email);
}