Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
961 B
0
Indexable
Never
//using System.Net.Mail;

using MailKit.Net.Smtp;
using MailKit.Security;
using MimeKit;

internal class Program
{
    private static void Main(string[] args)
    {
        MimeMessage message = new MimeMessage();

        message.From.Add(new MailboxAddress("Kaundyk", "orynbassarov22@gmail.com"));
        message.To.Add(new MailboxAddress("Alemkhan", "Alemkhan.ut@gmail.com"));
        message.Subject = "Here is my message's theme";
        message.Body = new TextPart("plain") 
        { 
            Text = "Here is my message's text"    
        };

        using (SmtpClient client = new SmtpClient())
        {
            client.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTls);

            client.Authenticate("orynbassarov22@gmail.com", "");

            client.Send(message);
            Console.WriteLine("Сообщение отправлено");
            client.Disconnect(true);
        }
    }
}
Leave a Comment