Skip to content

Instantly share code, notes, and snippets.

@claudiohilario
Created January 16, 2016 02:02
Show Gist options
  • Save claudiohilario/ff9eeddacbe0241704ea to your computer and use it in GitHub Desktop.
Save claudiohilario/ff9eeddacbe0241704ea to your computer and use it in GitHub Desktop.
Função EnviarEmail C# (ASP.NET)
public bool EnviarEmail(string destinatario, string assunto, string mensagem)
{
try
{
var email = "xxxxxxxxxxxxx@xxx.xx";
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "xxxxx.xxxxx.xxx"; //Servidor SMTP
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(email, "password");
smtp.Timeout = 20000;
}
smtp.Send(email, para, assunto, mensagem);
return true;
}
catch
{
//Erro
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment