Created
October 14, 2022 22:37
-
-
Save fernandezja/a9697867882fc8a6199f5af6d6aabfd4 to your computer and use it in GitHub Desktop.
Send email with MimeKit + MailKit C# NET
This file contains 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
Console.WriteLine("Send email with MimeKit + MailKit!"); | |
var from = new MailboxAddress(name: "Demo From", address: "...@outlook.com"); | |
var to = new MailboxAddress(name: "Demo To", address: "...@gmail.com"); | |
var msj = new MimeMessage(); | |
msj.From.Add(from); | |
msj.To.Add(to); | |
msj.Subject = "Episode IV"; | |
msj.Body = new TextPart(TextFormat.Html) | |
{ | |
Text = "Starwars!" | |
}; | |
var client = new MailKit.Net.Smtp.SmtpClient(); | |
client.Connect(host: "smtp.office365.com", | |
port: 587, | |
options: MailKit.Security.SecureSocketOptions.StartTls); | |
//https://support.microsoft.com/es-es/account-billing/uso-de-contrase%C3%B1as-de-la-aplicaci%C3%B3n-con-aplicaciones-que-no-admiten-la-verificaci%C3%B3n-en-dos-pasos-5896ed9b-4263-e681-128a-a6f2979a7944 | |
client.Authenticate("....@outlook.com", "!#$%&"); | |
client.Send(msj); | |
client.Disconnect(true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment