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.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : 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 April 9th, 2013, 09:43 AM
Authorized User
Points: 100, Level: 1
Points: 100, Level: 1 Points: 100, Level: 1 Points: 100, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default Send e-mail on error

Hi Imar,
I wonder if you can help me.
I have set up a contact page and I have it so that it sends the results to an e-mail address that is located in web.config file.
This uses the Global.asax to send the e-mail.
I was wondering if you could tell me how I can set it up so that the contact form sends an e-mail to address 1 whilst the error reports go to email2.

I tried adding a key in web.config called"ErrorAddress" and changing the information in global.asax so that it says:
Code:
Dim myMessage As MailMessage = New MailMessage(AppConfiguration.FromAddress, AppConfiguration.ErrorAddress, mailSubject, message)
but this didn't work.

Could you help please?
Thank you
Reply With Quote
  #2 (permalink)  
Old April 9th, 2013, 09:52 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

>> I tried adding a key in web.config called"ErrorAddress" and changing the information in global.asax so that it says:

Did you also add the property to the AppConfiguration class that reads the web.config file? You need one for each value you want to read from the web.config, and you need to add it manually (there's no magic to make that work).

You could bypass AppConfiguration and access AppSettings directly, but I would not recommend that.

>> This uses the Global.asax to send the e-mail.

Not sure I get that. In the Planet Wrox website, Global.asax is only used for error messages, not for the contact form.

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
  #3 (permalink)  
Old April 9th, 2013, 10:06 AM
Authorized User
Points: 100, Level: 1
Points: 100, Level: 1 Points: 100, Level: 1 Points: 100, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar,
Sorry for the confusion. Please ignore what I said about global.asax sending the e-mail. I meant the error email not the contact one.
I'm sure I tried what you are describing, but just to clarify should I change AppConfiguration.ToAddress within the AppCofiguration class to AppConfiguration.ErrorAddress and then go into we.config and add the Key within <AppSettings> called ErrorAddress and set the value to the correct e-mail address?
Reply With Quote
  #4 (permalink)  
Old April 9th, 2013, 10:14 AM
Authorized User
Points: 100, Level: 1
Points: 100, Level: 1 Points: 100, Level: 1 Points: 100, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default

Actually I've sorted it now,
Thank you Imar, I had forgotten to add it to the AppConfiguration.vb file.
I am going between two projects at the same time, so I get a little confused :p
Reply With Quote
  #5 (permalink)  
Old April 9th, 2013, 10:30 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Glad you figured it out.

>> just to clarify should I change AppConfiguration.ToAddress within the AppCofiguration class to AppConfiguration.ErrorAddress and then go into we.config and add the Key within <AppSettings> called ErrorAddress and set the value to the correct e-mail address?

And yes, that's the way to do it. The AppConfiguration class has been introduced to wrap the settings in web.config in smarter, type-safe properties. You don't have to do it and you could access web.config directly, but I find it a lot easier to have a property in AppConfiguration for each of my appSettings elements in web.config.

Hope this clarifies things even further.

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
  #6 (permalink)  
Old April 9th, 2013, 10:32 AM
Authorized User
Points: 100, Level: 1
Points: 100, Level: 1 Points: 100, Level: 1 Points: 100, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 26
Thanks: 0
Thanked 1 Time in 1 Post
Default

it does, thank you ^_^
Reply With Quote
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
Send mail and attachments with PHP mail function Lofa Beginning PHP 1 June 2nd, 2008 03:24 PM
mail send error :page cannot be displayed KamalRaturi ASP.NET 2.0 Professional 2 May 5th, 2008 10:59 AM
error in send mail in arabic langauge boda2005 Classic ASP Professional 0 February 15th, 2008 07:08 PM
Mail.send error (attachement > 100KB) max_manu Classic ASP Basics 0 June 27th, 2006 12:57 PM
Error on mail object .send blaabil Classic ASP Basics 6 January 16th, 2006 10:49 PM



All times are GMT -4. The time now is 11:05 AM.


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