From a8a8c9f51a8782b44762d84af129a0e5c37dddfd Mon Sep 17 00:00:00 2001 From: ArifHilmi Date: Tue, 10 Sep 2024 10:45:11 +0800 Subject: [PATCH] Upload files to "/" --- email.cs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 email.cs diff --git a/email.cs b/email.cs new file mode 100644 index 0000000..e922ecf --- /dev/null +++ b/email.cs @@ -0,0 +1,38 @@ +using System; +using System.Net; +using System.Net.Mail; + +class Program +{ + static void Main() + { + try + { + MailMessage mail = new MailMessage + { + From = new MailAddress("arifhilmi007@gmail.com"), + Subject = "Testing Sending Email Using Console", + Body = "Hi.", + IsBodyHtml = false + }; + mail.To.Add("rezuansamirin@gmail.com"); + + SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587) + { + Credentials = new NetworkCredential("arifhilmi007@gmail.com", "ptvh pjtb noed olxw"), // Use the app password here + EnableSsl = true + }; + + smtpClient.Send(mail); + Console.WriteLine("Email sent successfully."); + } + catch (SmtpException smtpEx) + { + Console.WriteLine("SMTP error: " + smtpEx.Message); + } + catch (Exception ex) + { + Console.WriteLine("General error: " + ex.Message); + } + } +} \ No newline at end of file