Last active
December 16, 2022 04:09
-
-
Save maxkoshevoi/5b39370379ec087793fcae41460a44ea to your computer and use it in GitHub Desktop.
Sending Email using .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
using System.Net.Mail; | |
static class Mail | |
{ | |
public static void Send(string to, string subject, string content) | |
{ | |
var mail = new MailMessage("INSERT FROM EMAIL HERE", to) | |
{ | |
Subject = subject, | |
Body = content | |
}; | |
using var client = new SmtpClient("INSERT SMTP SERVER HERE") | |
{ | |
Port = 25, // Port can be different | |
DeliveryMethod = SmtpDeliveryMethod.Network, | |
UseDefaultCredentials = false | |
}; | |
client.Send(mail); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment