using System; using System.Net; using System.Net.Mail; class Program { static void Main(string[] args) { string smtpHost = "<your-smtp-host>"; int smtpPort = 587; string smtpUsername = "<your-smtp-username>"; string smtpPassword = "<your-smtp-password>"; string fromEmail = "<from-email-address>"; string toEmail = "<to-email-address>"; string subject = "Test Email"; string body = "This is a test email."; using (SmtpClient client = new SmtpClient(smtpHost, smtpPort)) { client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(smtpUsername, smtpPassword); MailMessage message = new MailMessage(fromEmail, toEmail, subject, body); try { client.Send(message); Console.WriteLine("Email sent successfully."); } catch (Exception ex) { Console.WriteLine("Failed to send email: " + ex.Message); } } } }