Send Email in ASP .net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sugee
    New Member
    • Jan 2007
    • 35

    Send Email in ASP .net

    Hi,
    I need to send email in ASP .net(vb .net) using smtp. i have found that i can use smtpmail.send() to send email.....but the problem is the page doent show any error and the mail is not received in my inbox too.....i have changed some settings in IIS(default virtual server properties). In the access tab->and on connection i have added 127.0.0.1 ip address....but i have a doubt......do i need to add this 127.0.0.1 ip or my mail server ip???? And in the general tab also i have added my system IP in the IP textbox. the following is the code i have added in my sned button click event.
    SmtpMail.SmtpSe rver = ConfigurationSe ttings.AppSetti ngs("SmtpServer ")
    SmtpMail.SmtpSe rver.Insert(0, "127.0.0.1" )
    SmtpMail.Send(" suguna.r@tcs.co m", "suguna.r@tcs.c om", "test", "test")
    Response.Write( "sent")
    If the above code is used, then the page doesnt shows any error....and the mail is also not sent.

    SmtpMail.SmtpSe rver = ConfigurationSe ttings.AppSetti ngs("SmtpServer ")
    SmtpMail.SmtpSe rver = "172.20.33. 126"
    SmtpMail.Send(" suguna.r@tcs.co m", "suguna.r@tcs.c om", "test", "test")
    Response.Write( "sent")
    when the above code is used, 'transport failed to connect to server' error is shown.
    Can anyone tell me whats the problem....wher e i have made the mistake???and what is the difference in both these codes?please help me....
  • sugee
    New Member
    • Jan 2007
    • 35

    #2
    Can anyone suggest me the solution...?ple ase?

    Comment

    • mzmishra
      Recognized Expert Contributor
      • Aug 2007
      • 390

      #3
      Is your SMTP server address is correct.
      Try the below code
      MailMessage m = new MailMessage();
      m.To = sendTo_;
      m.From = from_;
      m.BodyFormat = MailFormat.Html ;
      m.Body = htmlBody_;
      m.Subject = subject_;
      SmtpMail.SmtpSe rver = "your server";
      SmtpMail.Send(m );

      Comment

      • sugee
        New Member
        • Jan 2007
        • 35

        #4
        yes its right.....it is 172.20.33.126
        then what would be the problem??

        Comment

        Working...