Send mail in asp.net

Posted by Zerotoinfinite on Stack Overflow See other posts from Stack Overflow or by Zerotoinfinite
Published on 2010-05-26T21:11:19Z Indexed on 2010/05/26 21:21 UTC
Read the original article Hit count: 374

Filed under:
|
|
|

Hi Experts,

I am using asp.net 3.5 and C#.

I want to send mail from asp.net, for that I have got some details from my hosting provider

which are these:

  • mail.MySite.net
  • UserName
  • Password

But I am unable to send mail through these details, I have done the following changes in my web.config file:

<system.net>
    <mailSettings>
        <smtp>
            <network
                 host="mail.MySite.net"
                 port="8080"
                 userName="UserName"
                 password="Password" />
        </smtp>
    </mailSettings>
</system.net>

Also, at the code behind I am writing this function:

MailMessage mail = new MailMessage("[email protected]", "[email protected]");
mail.Subject = "Hi";
mail.Body = "Test Mail from ASP.NET";
mail.IsBodyHtml = false;

SmtpClient smp = new SmtpClient();
smp.Send(mail);

but I am getting error message as message sending failed.

Please let me know what I am doing wrong and what I have to do to make it work fine.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET