Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
hello,
I want to send email. What i have already done is this
C#
/////////////////////////////////////////

System.Web.Mail.MailMessage obj = new System.Web.Mail.MailMessage();
obj.To = this.txtTo.Text.Trim();
obj.From = this.txtFrom.Text.Trim();
obj.Bcc = this.txtBcc.Text.Trim();
obj.Subject = this.txtSubject.Text.Trim();
obj.Body = this.txtMessage.Text.Trim();
System.Web.Mail.SmtpMail.SmtpServer = this.txtEmailServer.Text.Trim();
System.Web.Mail.SmtpMail.Send(obj);
MessageBox.Show("mailed successfully", "Message");

/////////////////////////////////////

This works well. But i want to send email through server that asks for authentication. I do not know how to do it.
Please help me.
Posted
Updated 10-Feb-10 22:14pm
v2

Try this
 
Share this answer
 
Try this:
C#
MailMessage m = new MailMessage("sender", "reciver", "hi", "how are u");
SmtpClient sm = new SmtpClient("smtp.gmail.com", 587);
sm.DeliveryMethod = SmtpDeliveryMethod.Network;
sm.UseDefaultCredentials = false;
sm.EnableSsl = true;
sm.Credentials = new System.Net.NetworkCredential("your user id@gmail.com", "your password");            
sm.Send(m);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900