Created
January 16, 2016 02:02
-
-
Save claudiohilario/ff9eeddacbe0241704ea to your computer and use it in GitHub Desktop.
Função EnviarEmail C# (ASP.NET)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool EnviarEmail(string destinatario, string assunto, string mensagem) | |
{ | |
try | |
{ | |
var email = "[email protected]"; | |
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