How To send an email 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.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace email
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void send_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage("your gmail mail",textTo.Text,textSubject.Text,textmail.Text);
msg.IsBodyHtml = true;
SmtpClient sc = new SmtpClient("smtp.gmail.com",587);
sc.UseDefaultCredentials = false;
NetworkCredential cre = new NetworkCredential("your gmail mail",textpass.Text);//your mail password
sc.Credentials = cre;
sc.EnableSsl = true;
sc.Send(msg);
MessageBox.Show("Mail Send");
}
}
}
////////////////////////////// END
Download Projects Source Code
1 comments:
commentsservice not available, closing trasmission channel. the server response was: cannot connect to SMTP server, either for 587 port or 465 one.
Replyime getting this error, could u suggest a solution please