Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 15th, 2012, 03:13 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #2 (permalink)  
Old July 16th, 2012, 04:52 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #3 (permalink)  
Old July 16th, 2012, 05:17 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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@gmail.com", "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
Reply With Quote
  #4 (permalink)  
Old July 16th, 2012, 05:22 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #5 (permalink)  
Old July 16th, 2012, 05:34 AM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #6 (permalink)  
Old July 16th, 2012, 09:51 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #7 (permalink)  
Old July 23rd, 2012, 10:50 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Location: San Diego, CA
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
Reply With Quote
  #8 (permalink)  
Old July 23rd, 2012, 11:43 PM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Location: San Diego, CA
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.
Reply With Quote
  #9 (permalink)  
Old July 25th, 2012, 05:50 PM
Authorized User
Points: 60, Level: 1
Points: 60, Level: 1 Points: 60, Level: 1 Points: 60, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
  #10 (permalink)  
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?
Reply With Quote Received Infraction
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:30 AM.


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