-1
I have a problem sending the email when I run:
objClientSmtp.Send(mensagem_email)
On the button +, "Non-public Members", there shows the property ClientSmtp.ServerSupportsEai
with an Exception: "Undefined object reference for an object instance".
Where I define this object ?
Someone knows a solution ?
My code is 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);
}