vallab rao

vallab rao

  • 1.7k
  • 14
  • 16.8k

Send email through the proxy server?

Mar 24 2010 6:38 AM
Hi,

I m implementing an tool which sends mail to any id to any id  but i can send the mail through the direct use  SMTP server and username and password. But when it comes to through the proxy then it fails. Don't know what went wrong ?
Here is code i m written:

protected void btnSendMail(object sender, EventArgs e)
    {
     
        MailAddress from = new MailAddress(txtFrom.Text.ToString());
        MailAddress To = new MailAddress(Ttxt.Text.ToString());

        MailMessage mail = new MailMessage(from, To);

       
        mail.Subject = txtSubject.Text.ToString();
        mail.Body = Editor1.Content.ToString();
        mail.IsBodyHtml = true;

        SmtpClient cnt = new SmtpClient();
        cnt.Host = SDomainName.Text.ToString();//domain.com
        cnt.Port = 1080;//port
        cnt.Credentials = new System.Net.NetworkCredential(from.ToString(),txtPass.Text.ToString());       //username,password

        //SmtpMail.Send(mail);
        cnt.EnableSsl = true;

        try
        {
            cnt.Send(mail);
         status.Text = "Mail sent successfully";
        }
        catch (Exception ex)
        {
        status.Text = ex.Message.ToString();
        }
    }

Please help in implementing the code.