Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2008, 10:42 AM
Authorized User
 
Join Date: Aug 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to KamalRaturi Send a message via Yahoo to KamalRaturi
Default mail send error :page cannot be displayed

hi ,

I am using this code for sending mail using localhost(127.0.0.1) and port 25.

 MailMessage Mail = new MailMessage();
        MailAddress ma = new MailAddress(txtFrom.Text, txtName.Text);
        Mail.From = ma;
        Mail.To.Add(txtTo.Text);
        Mail.Subject = txtSubject.Text;
        Mail.Body = txtComment.Text;
        try
        {
            SmtpClient smtpMailObj = new SmtpClient();
            //eg:localhost, 192.168.0.x, replace with your server name
            smtpMailObj.Host = ConfigurationManager.AppSettings["SMTPServer"];
            smtpMailObj.Send(Mail);
            //Response.Write("Your Message has been sent successfully");
        }
        catch (Exception ex)
        {
            //Response.Write("Message Delivery Fails");
        }

___________________________

But I get error "page cannot be displayed " when smtpMailObj.Send(Mail) executes. I have gone through almost all forums but couldnt find solution.


Help me on this topic please.

Thanks
 
Old May 5th, 2008, 10:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there.. are you doing something after this?? (maybe redirecting?)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 5th, 2008, 10:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Take a look at this:

catch (Exception ex)
{
//Response.Write("Message Delivery Fails");
}

What do you think this does?

It swallows any exception that your code might throw which means you can't tell for sure what went wrong. Either write out ex.Message to the browser, or temporarily remove the try/catch block so you can see the real exception.

Using code block like this is the best way to keep yourself in the dark, clueless of the root cause of the problem...

After you find out the error, reintroduce the catch block, but don't catch a generic Exception, but one or more of the specific exceptions that the Send method might throw....


Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Send E-mail from .asp page LiDenning Classic ASP Professional 2 April 28th, 2006 05:42 PM
this page can not be displayed "error" p2ptolu Classic ASP Databases 12 July 8th, 2005 12:04 PM
Unwanted error page displayed patwadd Classic ASP Basics 2 February 8th, 2005 10:07 AM
Terrible error: The page cannot be displayed csun ASP.NET 1.0 and 1.1 Basics 2 November 9th, 2004 10:16 AM
Error Message: The page cannot be displayed BSkelding ASP.NET 1.0 and 1.1 Basics 2 April 23rd, 2004 11:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.