Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 September 7th, 2010, 03:36 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Please help me at this

This is related to CHAPTER 9 -Processing Data at the server. I was trying to get some hands-on on the Sending E-mail from the website Try it out.


I tried to use my corporate account which is opened thru Microsoft Outlook and also tried to send the message through Gmail as given in the try it out session but I am unable to do so . I get the following Error message:

No connection could be made because the target machine actively refused it 74.125.155.109:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 74.125.155.109:25

Source Error:


Line 24: //SmtpClient mySmtp = new SmtpClient("10.237.216.90");
Line 25: SmtpClient mySmtp = new SmtpClient();
Line 26: mySmtp.Send(mymessage);
Line 27: }
Line 28: }


Please help me in resolving this
 
Old September 7th, 2010, 03:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And how does your config file look like? Did you try the various port numbers and set enableSsl to true in the config file?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 7th, 2010, 08:33 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question My code files

The <system .net> tag in the web.config file :

Code:
 <system.net>
      <mailSettings>
         <smtp deliveryMethod="Network" from="Sahil Nazir Zargar &lt;[email protected]&gt;">
                 <network host="smtp.gmail.com"  enableSsl="true" userName="[email protected]" password= "******" port="6129" />
         </smtp>
      </mailSettings>      
   </system.net>


The code in the Email.aspx.cs

Code:
 protected void Page_Load(object sender, EventArgs e)
    {
       //creating an instance of the mailmessage class form System.Net.Mail
       MailMessage mymessage = new MailMessage();

       // using the Mailmessage class properties
       mymessage.Subject = "Test Mail";

       mymessage.Body = "This is a test mail sent from Planet Sahil to check the ASP.net System.Net.mail class properties";

    
       mymessage.From = new MailAddress("[email protected]", "Sahil Nazir Zargar");
       mymessage.To.Add(new MailAddress("[email protected]", "Sahil Nazir Zargar"));
       //mymessage.CC.Add (new MailAddress("[email protected]", "Sahil Zargar"));

      //SmtpClient mySmtp = new SmtpClient("10.237.216.90");
      SmtpClient mySmtp = new SmtpClient();
      mySmtp.Send(mymessage);
    }
I have already tried different port numbers such as 6129,578,100

Last edited by sahilzargar; September 7th, 2010 at 08:39 AM..
 
Old September 7th, 2010, 08:40 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You probably need to add a port attribute to the <network /> element. Take a look at the second code snippet on page 318 for an example and at step 4 on page 320.

Cheers,

Imar
---------------------------------------------------------------------------------------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4 : in C# and VB, Beginning ASP.NET 3.5 : in C# and VB and ASP.NET 2.0 Instant Results.
While typing this post, I was listening to: Group Four by Massive Attack (Track 10 from the album: Mezzanine) What's This?









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