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 December 13th, 2010, 03:43 PM
Authorized User
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default Sending mail with CreateUserWizard

Hi Imar
I tried sending mail with the CreateUserWizard. My SMTP server needs authentication, which I declared in the web.config.

Here is the code (I removed the password):
<smtp deliveryMethod="Network">
<network host="mail.avidan.co.il" password="XXXXX" userName="myname@avidan.co.il" port="2525" defaultCredentials="true" />
</smtp>

It didn't work, I got an yellow error page (server needs authentication etc etc).

I added then the following code in the CreateUserWizard1_SendingMail prcoedure:

Dim mysmtpclient As SmtpClient = New SmtpClient("mail.avidan.co.il")
mysmtpclient.Port = "2525"
mysmtpclient.Credentials = New System.Net.NetworkCredential("myname@avidan.co.il" , "xxxxx")
mysmtpclient.Send(e.Message)
e.Cancel = True

Now it's working! Why did I have to add the code in the CreateUserWizard1_SendingMail procedure? I thought putting the code in the web.config is enough.

Thanks
Alex
 
Old December 13th, 2010, 06:35 PM
Authorized User
 
Join Date: Oct 2009
Posts: 22
Thanks: 2
Thanked 10 Times in 7 Posts
Default

The problem with your web.config configuration is the addition of this attribute:

defaultCredentials="true"

This attribute makes the SmtpClient object use your windows credentials instead of the username and password that you provide to connect to the server. By default it is set to false, so you can either not include it in the network element OR set it to false.





Similar Threads
Thread Thread Starter Forum Replies Last Post
error while sending mesage through CreateUserWizard control jack_hilary BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 September 25th, 2009 03:43 AM
problems sending mail with java mail gandacuboy J2EE 2 December 20th, 2006 03:05 PM
sending mail anita VB How-To 3 September 30th, 2004 03:48 PM
Sending e-mail to different mail box! Calibus Classic ASP Databases 4 September 3rd, 2004 05:48 PM
Sending both text mail and HTML mail - CDONTS madhukp Classic ASP Basics 1 October 8th, 2003 01:05 AM





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