Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 January 25th, 2009, 07:48 PM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter Nine: Must issue a STARTTLS

I cannot configure the email to send in Chapter Nine. I followed the tutorial and get the following error message when I try to send the contact information. I am using gmail and I know that SSL needs to be activated. Is this possible to do or should I configure SMTP from IIS on my computer instead? Which is better?

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. u9sm17500196muf.4

Code:
<smtpdeliveryMethod="Network"from="ME &lt;ME@gmail.com&gt;">
<networkhost="smtp.gmail.com"userName="ME"password="PASSWORD"port="587" />

 
Old January 26th, 2009, 04:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Have you set EnableSsl to true on the SmtpClient like this:

smtpClient.EnableSsl = true;

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 January 26th, 2009, 06:13 AM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Where does that code go?
 
Old January 26th, 2009, 06:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It depends on where you're using it. In the contact page, there's this code where you could add it:

Code:
 
SmtpClient mySmtpClient = new SmtpClient();
try
{
  smtpClient.EnableSsl = true;
  mySmtpClient.Send(myMessage);
}
catch (Exception ex)
{
  lblMessage.Text = "An error occurred while sending your e-mail. Please try again.";
}
Hope this helps,

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 January 26th, 2009, 07:11 AM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked, thank you. I had to take out the catch phrase because it threw an error and I also needed to modify smtpClient.EnableSsl = true to mySmtpClient.EnableSSl = true.

What parameters are necessary for (exception ex) to make catch work. In my code, it told me that it was expecting an end statement.

TRY

CATCH (Exception ex)

lblMessage.Text = "An error occurred while sending your e-mail. Please try again.";

END TRY

I am using VB
 
Old January 26th, 2009, 04:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Sorry, I copied and pasted that from a C# example. Didn't know what language you were using....

In general, a Try Catch block looks like this:

Code:
Try
  ' Code to try here
Catch ex As Exception
  ' Error handling here
Finally
  ' Stuff that always runs after the try and/or catch
End Try
Hope this helps,

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 January 27th, 2009, 08:30 PM
Authorized User
 
Join Date: Jan 2009
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I can't get this to work either. I've received a variety of different error messages. I've checked and rechecked the instructions in the book to no avail. The last error message I received was:

"Mailbox unavailable. The server response was: 5.7.3 Requested action aborted; user not authenticated "

I called my ISP to get the smtp server address (smtp.live.com for an msn address). I assume that in the web.config file, in the <network> element, "userName" is supposed to be my actual username (that which precedes the @ symbol in my email address), and "password" is supposed to be my actual email account access password? I use Outlook for my email.

I enabled Ssl to true in the lines of VB that precede the email send statements.

Any ideas for me?
 
Old January 28th, 2009, 03:05 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 may need to try your entire e-mail address as the user name, including the part after the @ symbol.

Additionally, many ISP's have user names that are different from thr e-mail addresses so you'll need to check that too.

And is Live your ISP? That is, do they provide you the SMTP services? Or does your ISP have their own SMTP servers as well?

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 19th, 2009, 11:43 PM
Registered User
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can't send email

I can't get the Email demo (Email.aspx) to work either. I keep getting the "An error occurred while sending your e-mail." message.

I have a sbcglobal.net account and believe the smtp is smtp.sbcglobal.yahoo.com. I've tried mySmtpClient.EnableSsl to True. I've tried disabling my firewall. I've tried entering the userName and password. Nothing seems to work. Any thoughts?
 
Old September 20th, 2009, 03:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

A few things to check:

1. The port number in web.config. This FAQ http://help.yahoo.com/l/us/yahoo/sma...op/pop-27.html suggests to use port 587.

2. The user name and password in web.config. You probably need to use your full e-mail address, not just your user name.

Your web.config could look like this:

Code:
 
<system.net>
  <mailSettings>
    <smtp deliveryMethod="Network" from="you@yourprovider.com">
      <network host="smtp.sbcglobal.yahoo.com" port="587" 
             userName="you@yourprovider.com" password="password" />
    </smtp>
  </mailSettings>
</system.net>
You can also try setting the port, user name and password programmatically:

Code:
 
Dim mySmtpClient As New SmtpClient("smtp.sbcglobal.yahoo.com")
mySmtpClient.Port = 587
mySmtpClient.Credentials = New NetworkCredential("you@yourprovider.com", " YourPassword")
mySmtpClient.EnableSsl = True
mySmtpClient.Send(myMessage)
If that doesn't help, can you post the full error message you're getting together with its details? You may also need to contact your ISP to see if they even support this, and if so, what information you need to use.

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 16 Viewforum issue EgoGen BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 12th, 2008 04:18 AM
chapter 12 loginin issue marcusth BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 December 27th, 2007 01:11 PM
session_start issue (Chapter 12) preston2003 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 7 April 15th, 2005 03:09 AM





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