Sending mail in c# using SMTP Client [Resolved]

Posted by Naresh2k3406 under C# on 3/8/2012 | Points: 10 | Views : 8874 | Status : [Member] | Replies : 5
How to send email by using SMTP Client? From Account Credentials also required?




Responses

Posted by: Hmanjarawala on: 3/9/2012 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi have this:


SmtpClient client = new SmtpClient("smtp.mail.yahoo.com", 25);

MailMessage mail_msg = new MailMessage();



MailAddress fromAdd = new MailAddress(tbFrom.Text.Trim()); //hmanjarawala@yahoo.com

mail_msg.From = fromAdd;

mail_msg.To.Add(new MailAddress(tbTo.Text.Trim())); //hmanjarawala@gmail.com

mail_msg.Subject = tbSubject.Text;

mail_msg.IsBodyHtml = true;

mail_msg.Body = "Message From: " + tbFrom.Text.Trim() + "Subject:" + tbSubject.Text.Trim() + "Email: " + tbTo.Text.Trim() + "Content: " + tbContent.Text.Trim();



System.Net.NetworkCredential basicCredential = new System.Net.NetworkCredential("hmanjarawala@yahoo.com", "***********");

client.EnableSsl = false;

client.UseDefaultCredentials = true;

client.Credentials = basicCredential;

client.Send(mail_msg);


Mark this as answer if it helps you......

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Naresh2k3406, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajkatie on: 3/8/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Please refer following links
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

Rajesh Patel
.Net Trainer(MSCD | MCT | MS)
Brainbench (Asp.Net 4.5 and C# 5.0)

Naresh2k3406, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 3/8/2012 [Member] Silver | Points: 25

Up
0
Down
Please refer the following links
http://www.systemnetmail.com/
http://www.codeproject.com/Articles/13690/Sending-SMTP-mail-from-ASP-NET-and-codebehind-as-C

Naresh2k3406, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 3/12/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Please refer this link


http://www.dotnetfunda.com/blogs/susanthampy/1547/sending-email-from-aspnet-webapplication

Regards,
Susan

Naresh2k3406, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Denny on: 3/13/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Naresh

Check this code...
Call this method from where you need.

public void email(string e_id)
{
MailMessage mg = new MailMessage();
mg.From = new MailAddress("bliss.care49@gmail.com"); //create an account in gmail
mg.To.Add(new MailAddress(e_id));
mg.Subject = "products bought from EBliss.com"; //optional
mg.Body = datatb(); //optional code
mg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
NetworkCredential credential=new NetworkCredential("bliss.care49@gmail.com","projectqwerty"); //account id & password
smtp.EnableSsl=true;
smtp.UseDefaultCredentials=false;
smtp.DeliveryMethod=SmtpDeliveryMethod.Network;
smtp.Credentials=credential;
smtp.Send(mg);


}

Regards,
Denny Kurian

Naresh2k3406, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response