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 October 13th, 2009, 06:36 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default Question about email

Hey Imar,

For the life of me I could not get your code to work for sending out an email. I understood the code and it made perfect sense, but for some reason the way it was set up I kept getting errors on both my work PC and home PC which wouldn't allow me to send the email.

To get the code to work, I had to eliminate your instruction to insert code into the web config file and I just added these elements to the user control:

Dim mySmtpClient As New SmtpClient()
mySmtpClient.Host = "smtp.gmail.com"
mySmtpClient.Port = 587
mySmtpClient.Credentials = New System.Net.NetworkCredential("[email protected]", "YourPassword")
mySmtpClient.EnableSsl = True
mySmtpClient.Send(myMessage)

Now I am not sure if I was getting the errors because the code you specified didn't take into account that email requires SSL and a port (I tried adding the port to the webconfig) but it never worked until I deleted the section out of the webconfig and added that bit of extra code to the user control.

Do you think this is a reasonable alternative to your method? Is it any less secure since my email information will be sitting there?

Thanks again
 
Old October 14th, 2009, 03:08 PM
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,

In my book I am referring to this code as well when using a server that requires SSL. Search my book's forum category here at p2p.wrox.com for EnableSsl and you find a few more threads about the topic.

I can't test right now, but could you combine this and web.config? That is, get server and user data from web.config and set the rest through code.

Otherwise, considering wrapping the user name and password values in properties that access the web.config and move them to the <appSettings /> element in web.config. Check out Chapter 18 for more details.

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 October 14th, 2009, 03:39 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

I will test it out at work today and see if I can move most of the sensitive date to the web.config and still get it to work. I'll get back to you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Email question... iceman90289 ASP.NET 3.5 Basics 9 August 29th, 2009 09:44 AM
SMTP Email question snufse ASP.NET 2.0 Basics 2 July 9th, 2009 11:08 AM
Ch. 11 Email setup question amenne20 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 October 1st, 2006 04:04 PM
Ch. 11 Email setup question amenne20 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 October 1st, 2006 04:03 PM
Email Form - Question from a Newbie morgan270 ASP.NET 2.0 Basics 8 September 13th, 2006 03:58 PM





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