SMTP MAIL IN C SHARP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace mailing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage();
message.To.Add("ragava08@ymail.com");
message.Subject = "SUBJECT";
message.From = new MailAddress("ragava08@gmail.com");
message.Body = "BODY PART";
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("ragava08@gmail.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(message);
MessageBox.Show("Message successfully sent");
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace mailing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MailMessage message = new MailMessage();
message.To.Add("ragava08@ymail.com");
message.Subject = "SUBJECT";
message.From = new MailAddress("ragava08@gmail.com");
message.Body = "BODY PART";
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("ragava08@gmail.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(message);
MessageBox.Show("Message successfully sent");
}
}
}
No comments:
Post a Comment