Sending e-mail via SMTP gmail using C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsFormsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("sender_email_add@gmail.com");
mail.To.Add("receiver_email_address@gmail.com");
mail.Subject = "Subject of the mail";
mail.Body = "Body Text/message to show will add here";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("your_mail@gmail.com", "Password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsFormsApplication14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("sender_email_add@gmail.com");
mail.To.Add("receiver_email_address@gmail.com");
mail.Subject = "Subject of the mail";
mail.Body = "Body Text/message to show will add here";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("your_mail@gmail.com", "Password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
I think this is one of the most vital information for me.
ReplyDeleteAnd i am glad reading your article. But want to remark oon few general things, The site style is perfect, the articles
is really nice : D. Good job, cheers
Feel free to suf to my homepage meet new people online
Ӏ enjoy what you guys tenԁ to be up too. This ѕort off
ReplyDeleteclever work аnd eхposure! Keep up the great workѕ guys I'ѵe included you guys to my blοgroll.
Feel free to visit my website: ѕeo fort lauderdale ()
These are actually impressive ideas in on the topic of blogging.
ReplyDeleteYou have touched some pleasant points here.
Any way keep up wrinting.
Also visit my website - Mike Burns
This article is actually a good one it helps new internet people, who are wishing in favor of blogging.
ReplyDeletemy weblog; Mike B