gmail API to send an email in ASP?
The documentation is so bad when it comes to c# SDK.
I want to know, how to authorize the account, use the credentials, and send the email.
I created the OAuth creds in GCloud platform. I just need the coding steps.
I want this cause SMTP is obsolete. I can use app password with 2FA enabled, but I want to do it 'the right way'
https://mailtrap.io/blog/csharp-send-email/#:~:text=Well%2C%20according%20to%20Microsoft%20and,classes%20is%20a%20better%20alternative.
I read that, not what I'm looking for. If I want to use a SaaS, I'd use SendGrid instead.
in this sample i don't see anything other than how to use gmail to send mail with c#. using System; using MailKit.Net.Smtp; using MailKit; using MimeKit; namespace TestClient { class Program { public static void Main (string[] args) { var email = new MimeMessage(); email.From.Add(new MailboxAddress("Sender Name", "sender@email.com")); email.To.Add(new MailboxAddress("Receiver Name", "receiver@email.com")); email.Subject = "Testing out email sending"; email.Body = new TextPart(MimeKit.Text.TextFormat.Html) { Text = "<b>Hello all the way from the land of C#</b>" }; using (var smtp = new SmtpClient()) { smtp.Connect("smtp.server.address", 587, false); // Note: only needed if the SMTP server requires authentication smtp.Authenticate("smtp_username", "smtp_password"); smtp.Send(email); smtp.Disconnect(true); } } } }
It's using smtp, not Google sdk
smtp from their own library not from microsoft that is obsolute using MailKit.Net.Smtp;
Обсуждают сегодня