Hi Developers,
How can i send EMail by using my local machine in C#. Using some smtp or gmail default credentials without using any professional credentials.
Kindly suggest me to do this task.
Regards
Paul.S
Hi Developers,
How can i send EMail by using my local machine in C#. Using some smtp or gmail default credentials without using any professional credentials.
Kindly suggest me to do this task.
Regards
Paul.S
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Sep 30, 2022, 3:08 AM EDT
Hi Paul,
Please refer below Article
https://www.c-sharpcorner.com/article/sending-email-using-c-sharp/
https://blog.elmah.io/how-to-send-emails-from-csharp-net-the-definitive-tutorial/
Uttam KumarRank #1,076 · 1.8K reputationPosted Sep 30, 2022, 2:44 PM EDT
You can send it from your local system using some SMTP account only. A better and more convenient way is to use a Gmail account which is also free if you want to do it for testing.
Uday DodiyaRank #239 · 10.3K reputationPosted Oct 1, 2022, 12:17 AM EDT
Hello Paul,
Try Following
using System; using System.Collections.Generic; using System.Text; using System.Net.Mail; using System.Net; class Program { static void Main(string[] args) { Console.WriteLine("Mail To"); MailAddress to = new MailAddress(Console.ReadLine()); Console.WriteLine("Mail From"); MailAddress from = new MailAddress(Console.ReadLine()); MailMessage mail = new MailMessage(from, to); Console.WriteLine("Subject"); mail.Subject = Console.ReadLine(); Console.WriteLine("Your Message"); mail.Body = Console.ReadLine(); SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new NetworkCredential( "[email protected]", "password"); smtp.EnableSsl = true; Console.WriteLine("Sending email..."); smtp.Send(mail); } }Sachin SinghRank #66 · 26.2K reputationPosted Oct 1, 2022, 3:43 AM EDT
Better use sendgrid that microsoft recommends.
https://www.twilio.com/blog/send-emails-using-the-sendgrid-api-with-dotnetnet-6-and-csharp
Nitin SontakkeRank #264 · 9.6K reputationPosted Oct 2, 2022, 12:32 AM EDT
Hello Uday,
If I understand it correctly, gmail no longer allows sending mail the way to you have described.