using System;using MimeKit;using MailKit.Net.Smtp;using MailKit.Security;// This code example uses MailKit (MIT License: https://github.com/jstedfast/MailKit)class Program{static void Main(){try{// Sender address created in the consolestring fromEmail = "test@example.com";// SMTP password set in the consolestring password = "your password";string toEmail = "to@example.com";string smtpHost = "sg-smtp.qcloudmail.com";int smtpPort = 465;var message = new MimeMessage();message.From.Add(new MailboxAddress("", fromEmail));message.To.Add(new MailboxAddress("", toEmail));message.Subject = "Test Email with HTML Content";message.Body = new TextPart("html"){Text = @"<html><body><h1 style='color:blue;'>Hello!</h1><p>This is a <b>HTML test email</b> from <i>Tencent Cloud SES</i>.</p><p>Visit <a href='https://www.tencentcloud.com/'>this link</a> for more info.</p></body></html>"};using (var client = new SmtpClient()){client.Connect(smtpHost, smtpPort, SecureSocketOptions.SslOnConnect);client.Authenticate(fromEmail, password);client.Send(message);client.Disconnect(true);}Console.WriteLine("Email sent successfully.");}catch (Exception ex){Console.WriteLine($"Error: {ex.Message}");}}}
Feedback