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 July 15th, 2012, 03:13 AM
Authorized User
 
Join Date: May 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 9 Email Question

Hi Imar, I just completed chapter 9 on sending email in your Beginning Asp.Net 4.0 book focused on VB. I have set it up and was able to receive the message via gmail with no problems or issues. I had a couple of questions for you...

1. Is it possible to have the answers that are received in the email that are received to be lined up, not sure if we can insert a table or how to have the answers line up.

2. Currently we have the from email address hard coded into the ContactForm.ascx code behind, is it possible that rather to have the from address be hard coded, could we use the data that is input into the email field in the ContactForm. This way when you reply to the message you are replying to the sender of the email message and not to the static email address that is coded in the code behind file.

I also wanted to verify that the web.config file is not able to be downloaded or the source be viewed in the browser or are we going to be able to have this data encrypted before we deploy the web site files to a live server.

Thank You
 
Old July 16th, 2012, 04:52 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,

1) Yes, you can. You can use HTML in the mail template so you could create a table with the labels in one column and the values in another. Then set IsBodyHtml to true on the MailMessage object.In your mail template, only include HTML you would normally put within the body tags. E.g. you can omit elements like <head> and <body>.

2) Yes, you could set the From address based on a text field. E.g.

myMessage.From = new MailAddress(FromAddress.Text);

where FromAddress is a text box that holds an e-mail address. However, this may cause problems if the FromAddress is not correct. Instead you could the ReplyToList property instead as described here:
http://msdn.microsoft.com/en-us/libr...plytolist.aspx

3) You can't download web.config files as by default IIS / ASP.NET blocks you from doing so. Try this to see what I mean: http://imar.spaanjaars.com/web.config

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 July 16th, 2012, 05:17 AM
Authorized User
 
Join Date: May 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar, thanks for the reply! Where would I put the reply address or code that you previously mentioned.
myMessage.From = new MailAddress(FromAddress.Text); would this go in the ContactForm.ascx.vb and would it replace the current code of
myMessage.From = New MailAddress("[email protected]", "Sender Name").

As you recommend not inserting the email from the form into the from address field as you said that the email address that is inputted, may not always be correct. Instead you recommend using the ReplyToList and I took a look at the page that you recommended, but I did not really understand. Could you explain in more detail or provide an example how I would use this with the existing contact form that is in your book. I did go ahead and test your web.config link I received a 404 page error, so I see what you mean. Also are the validation controls and validation summary enough these days to block spam from spamming your form or would you recommend using a captcha service like google's recaptcha or other alternative??

Thank you
 
Old July 16th, 2012, 05:22 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, it would replace that line if you want to change the From address.

For the ReplyToList, leave the From address as it is now, and just add to the reply list like this:

myMessage.ReplyToList.Add(new MailAddress(FromAddress.Text));

Validation controls don't block spam; they just make sure the submitted content matches what you expect. A Captcha or similar technique might indeed be a good idea.

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 July 16th, 2012, 05:34 AM
Authorized User
 
Join Date: May 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,

for this would I use
myMessage.ReplyToList.Add(new MailAddress(FromAddress.Text));
or would I use
myMessage.ReplyToList.Add(new MailAddress(EmailAddress.Text));
as I do not see FromAddress.text in the codebehind file.

Thanks
 
Old July 16th, 2012, 09:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

As hinted in my previous post, "FromAddress is a text box that holds an e-mail address". I just used that as an example. If your text box is called EmailAddres, you should indeed use that.

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 July 23rd, 2012, 10:50 PM
Registered User
 
Join Date: Jun 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Pdesignz View Post
Hi Imar, I just completed chapter 9 on sending email in your Beginning Asp.Net 4.0 book focused on VB. I have set it up and was able to receive the message via gmail with no problems or issues. I had a couple of questions for you...
Hello Pdesign, you mentioned that you were able to recieve the email you sent via gmail, did you sent this through the VS Dev web server or are you using a live hosting account. I am using the built in Dev server and I am getting "The SMTP server requires a secure connection" error. I am sure I am using the correct gmail login creditials and I have specified port 587 and 465 and neither worked?

Thanks
 
Old July 23rd, 2012, 11:43 PM
Registered User
 
Join Date: Jun 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Never mind, I got it to work, for reason the enableSSL was set to false. Moving on.
 
Old July 25th, 2012, 05:50 PM
Authorized User
 
Join Date: May 2010
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar, I missed part of your previous reply...

When I go to add go to add a table in the mail template, would I need to code this as it says that there are no useable controls for a txt file. Also shen you mention the MailMessage object is that in the ContactForm.ascx file or would that be in the ContactForm,ascx.vb file? I looked in the code behind and am not sure where I would add the IsBodyHtml to true...

thanks!

Quote:
Originally Posted by Imar View Post
Hi there,

1) Yes, you can. You can use HTML in the mail template so you could create a table with the labels in one column and the values in another. Then set IsBodyHtml to true on the MailMessage object.In your mail template, only include HTML you would normally put within the body tags. E.g. you can omit elements like <head> and <body>.

2) Yes, you could set the From address based on a text field. E.g.

myMessage.From = new MailAddress(FromAddress.Text);

where FromAddress is a text box that holds an e-mail address. However, this may cause problems if the FromAddress is not correct. Instead you could the ReplyToList property instead as described here:
http://msdn.microsoft.com/en-us/libr...plytolist.aspx

3) You can't download web.config files as by default IIS / ASP.NET blocks you from doing so. Try this to see what I mean: http://imar.spaanjaars.com/web.config

Hope this helps,

Imar
 
Old July 26th, 2012, 12:58 AM
easyusemobile
Guest
 
Posts: n/a
Default Big Button Mobile Phones

What do you feel good for your parents when they use mobiles phone with difficulties? do you not wish to buy a big button mobiles Phones for them?
Received Infraction





Similar Threads
Thread Thread Starter Forum Replies Last Post
Email Question: Chp 9 nanonerd BOOK: Beginning ASP.NET 4 : in C# and VB 1 March 12th, 2012 03:34 AM
Question regarding automatic email SpellingBee Access VBA 0 April 27th, 2010 10:19 AM
Question about email digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 October 14th, 2009 03:39 PM
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





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