Add groupproject
This commit is contained in:
commit
339c67500b
38
email.cs
Normal file
38
email.cs
Normal file
@ -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 = "Hiiii.",
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user