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 September 24th, 2009, 03:01 PM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow error while sending mesage through CreateUserWizard control

Hello,
Quote:
I was able to send emails while working with the user control, initially there was problem regarding "STARTTLS" that was solved latter by setting the "EnableSsl" property to True. Now the same case is with the "CreateUserWizard". It pops up the following error "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. d6sm267628fga.11". I have gone through the "SendingMail" event of control and checked out the following code as in the "ContactForm.ascx" user control.
Code:
if (Page.IsValid)
        {
 
            string fileName = Server.MapPath("~/App_Data/SignUpConfirmation.txt");
                   
            string mailBody = System.IO.File.ReadAllText(fileName);
            mailBody = mailBody.Replace("##Name##", txtName.Text);
            mailBody = mailBody.Replace("##Email##", txtEmailAddress.Text);
            mailBody = mailBody.Replace("##HomePhone##", txtPhoneHome.Text);
            mailBody = mailBody.Replace("##BusinessPhone##", txtPhoneBusiness.Text);
            mailBody = mailBody.Replace("##Comments##", txtComments.Text);

            MailMessage myMessage = new MailMessage();
            myMessage.Subject = "Response From Web Site";
            myMessage.Body = mailBody;

            myMessage.From = new MailAddress("[email protected]", "Sender Name Here");
            myMessage.To.Add(new MailAddress("[email protected]", "Receiver name here"));

            SmtpClient mySmtpClient = new SmtpClient();
            try
            {
                mySmtpClient.EnableSsl = true;
                mySmtpClient.Send(myMessage);
            }
            catch (Exception ex)
            {
                lblMessage.Text = "An error occurred while sending your e-mail. Please try again.";
            }
            lblMessage.Visible = true;
            FormTable.Visible = false;
     }
Quote:
I know this code will not work in the context of signing up directly, as Sign up page has no the placeholders as mentioned in this code.

I have set appropriate settings in web.config file. as mentioned below
Code:
<system.net>
		<mailSettings>
			<smtp from="name &lt;[email protected]&gt;" deliveryMethod="Network">
				<network host="smtp.yourprovider.com" userName="UserName" password="Password" port="587"/>
			</smtp>
		</mailSettings>
	</system.net>
Quote:
You have suggested about to access "e.Message" of the "SendingMail" event to get access to the message that needs to be sent.
Now I just want to know where to change in code and replace placeholders from the code above for the user control so that it works fine.
Any kind of assistance is appreciated.....
 
Old September 25th, 2009, 03:11 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,

I am not sure what you're asking exactly. You seem to be quoting a lot but not asking a question?

Th CreateUserWizard is sending it's own mail, so as long as you can access e.Message and send that using your SmtpClient you should be fine. If you want to replace things you can do that on e.Message.Body directly.

Before you can replace something, you need to assign your own message body using the MailDefinition item of the CreateUserWizrad.

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 September 25th, 2009, 03:33 AM
Friend of Wrox
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Arrow CreateUserWizard and sending mail

Respected Sir,
Having finished with the CreateUserWizard, I tried to create new account, account is created smoothly but the email is not received instead it throws an error "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. d6sm267628fga.11".
Now I want to know that how I can manage the code in the "sending mail" event. As there is a file in App_Data folder named "SignUpConfirmation.txt" with contents like

Code:
Hi <% UserName %>,

Thank You For Signing Up For A New Account At www.PlanetWrox.com

To Log In To The Site, Use The Following Details:

User Name:      <% UserName %>
Your Password:  <% Password %>

We Look Forward To Your Contributions, So That We May Serve You In More Better Way.
Now if even I write my code as in the chapter 9, then how to change the place holders as in chapter 9 place holders are wrapped in ##place holder##
like
Code:
Name:               ##Name##
E-mail Address:     ##Email##
Home Phone:         ##HomePhone##
Business Phone:     ##BusinessPhone##
Comments:           ##Comments##
Attachment:         ##Attachment##
And also tell me what actually e.Message is and how to use it?

Quote:
Ok one thing not related to this book, does your book "Beginning ASP.NET 2.0 in C# (ISBN: 978-0-470-04258-8 )" deals in E commerce and shopping cart like functionalities
 
Old September 25th, 2009, 03:43 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 here: Chapter Nine: Must issue a STARTTLS

You can set up a handler for the Event using the Events tab of the Properties Grid.

I didn't write that book so I don't know what it's about.... Click Bookstore/Ebooks at the top of this page, search for it and check out its table of contents.

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!

Last edited by Imar; September 27th, 2009 at 06:59 AM..
The Following User Says Thank You to Imar For This Useful Post:
jack_hilary (September 25th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
CreateUserWizard FileIOPermission Error tjmallen BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 April 7th, 2008 11:50 AM
CreateUserWizard Control kulkarnimonica ASP.NET 2.0 Professional 3 July 12th, 2007 04:56 PM
Sending a message to a DataCombo Box control vikramrj Pro VB 6 0 June 3rd, 2006 12:47 PM
ASP.Net 2.0 : CreateUserWizard Control mrinal_pandya ASP.NET 2.0 Basics 2 December 17th, 2005 03:06 AM
Error Mesage problem gsgreene ASP.NET 1.0 and 1.1 Basics 1 December 31st, 2004 09:10 AM





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