using windows form you can send your email or sms
page:
after click on Send button:
private void button1_Click(object sender, EventArgs e)
{
string mailBody = txtBody.Text;
//From:abc@gmail.com
MailMessage message = new MailMessage("abc@gmail.com", txtTo.Text.Trim(), "Test Mail", mailBody);
AlternateView htmlMail = AlternateView.CreateAlternateViewFromString(mailBody, null, "text/html");
// Set ContentId property. Value of ContentId property must be the same as
// the src attribute of image tag in email body.
message.AlternateViews.Add(htmlMail);
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("your GMAIL ID", "Your Gmail Passowrd");
smtp.EnableSsl = true;
smtp.Send(message);
message = null;
}
page:
after click on Send button:
private void button1_Click(object sender, EventArgs e)
{
string mailBody = txtBody.Text;
//From:abc@gmail.com
MailMessage message = new MailMessage("abc@gmail.com", txtTo.Text.Trim(), "Test Mail", mailBody);
AlternateView htmlMail = AlternateView.CreateAlternateViewFromString(mailBody, null, "text/html");
// Set ContentId property. Value of ContentId property must be the same as
// the src attribute of image tag in email body.
message.AlternateViews.Add(htmlMail);
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("your GMAIL ID", "Your Gmail Passowrd");
smtp.EnableSsl = true;
smtp.Send(message);
message = null;
}

No comments:
Post a Comment