hi,
i want to send an email in my project.when i use the SMTPMail.send() method there will be an unhandled exception error will occur.how can i solve this.
Thank you
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Feb 8, 2011, 12:54 AM EST
Guest User48 reputationPosted Feb 8, 2011, 2:04 AM EST
Steps for send a mail .
1). Add this code in your Web.Config file:
Add these code in your email.cs file
2). add this namespace: using System.Net.Mail;
3).MailMessage msg = new MailMessage();
msg.From = new MailAddress("[email protected]");
msg.To.Add([email protected]);
msg.Subject = "This mail from CsharpCorner";
msg.body="Your Text Here ";
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["SMTP"];
smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
smtp.EnableSsl = true;
smtp.Send(msg);
may be this is helpful to u
CrishRank #1,487 · 1.1K reputationPosted Feb 8, 2011, 3:01 AM EST
if you are using localhost for sending mails then it can not send and giving you error. You need to do configure IIS for sending emails in locally or write
client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; before Send() method.
It will send mail using asp.net code.
krithika muthukrishnanRank #8,369 · 223 reputationPosted Feb 9, 2011, 12:02 AM EST
when is send the mail using local host.The page has only one server side form tag error will occur.how can i solve this.
krithika muthukrishnanRank #8,369 · 223 reputationPosted Feb 9, 2011, 7:51 PM EST
when i send a mail in .net using local host.i got the error
error : Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]
i perform the relay operation in iis also,but now the same error will occur,how can i solve this,
thanks