Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Send-email/C-sharp/send-email.cs
Normal file
23
Task/Send-email/C-sharp/send-email.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
static void Main(string[] args)
|
||||
{
|
||||
//First of all construct the SMTP client
|
||||
|
||||
SmtpClient SMTP = new SmtpClient("smtp.gmail.com", 587); //I have provided the URI and port for GMail, replace with your providers SMTP details
|
||||
SMTP.EnableSsl = true; //Required for gmail, may not for your provider, if your provider does not require it then use false.
|
||||
SMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
SMTP.Credentials = new NetworkCredential("YourUserName", "YourPassword");
|
||||
MailMessage Mail = new MailMessage("yourEmail@address.com", "theirEmail@address.com");
|
||||
|
||||
|
||||
//Then we construct the message
|
||||
|
||||
Mail.Subject = "Important Message";
|
||||
Mail.Body = "Hello over there"; //The body contains the string for your email
|
||||
//using "Mail.IsBodyHtml = true;" you can put an HTML page in your message body
|
||||
|
||||
//Then we use the SMTP client to send the message
|
||||
|
||||
SMTP.Send(Mail);
|
||||
|
||||
Console.WriteLine("Message Sent");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue