Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using System.Net.Mail;
- namespace WindowsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- MailMessage mail = new MailMessage();
- SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
- mail.To.Add("to_address");
- mail.Subject = "Test Mail";
- mail.Body = "This is for testing SMTP mail from GMAIL";
- SmtpServer.Port = 587;
- SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
- SmtpServer.EnableSsl = true;
- SmtpServer.Send(mail);
- MessageBox.Show("mail Send");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement