Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Sending email from webpage

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 26 Mar 2008 16:33 GMT
Hey

.net 3.5

In my webproject I got a CreateUserWizard which contain this code for
sending confirmation email to the registered user:

<MailDefinition From="xxxx@yyyyy.zzz"  BodyFileName="~/MailFile.txt"
Subject="Confirmation">
</MailDefinition>

This sends email. But I don't like this solution. Here the senders email
address is hard coded into the source code. I want to be able to have
senders email address in web.config, so it easily can me modified without
the need to recompile the entire project...   I'm not sure what is the best
tag in web.config for storing the email address... I assume when using
web.config, I must skip the MailDefinition tag and instead send email via
the behind code...

any suggestions?
Eliyahu Goldin - 26 Mar 2008 16:58 GMT
<MailDefinition From=<%= ConfigurationManager.AppSettings["EmailAddress"] %>
BodyFileName="~/MailFile.txt" Subject="Confirmation">
</MailDefinition>

and in the web.config:
<appSettings>
   <add key="EmailAddress" value="xxxx@yyyyy.zzz" />
</appSettings>

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Hey
>
[quoted text clipped - 16 lines]
>
> any suggestions?
Jeff - 26 Mar 2008 18:04 GMT
the code you posted gives me several warnings and errors:

from the code you posted I removed a '=' from =<%=
ConfigurationManager.AppSettings
so I get =<% ConfigurationManager.AppSettings instead... I get fewer errors
then, the errors (some are warnings) I get then are listed below:

- Code blocks are not supported in this context
- Attribute values must be enclosed in quotation marks
- Content ('<MailDefinition From=') does not match any properties within a
'System.Web.UI.WebControls.CreateUserWizard', make sure it is well-formed.

any suggestions?

> <MailDefinition From=<%= ConfigurationManager.AppSettings["EmailAddress"]
> %> BodyFileName="~/MailFile.txt" Subject="Confirmation">
[quoted text clipped - 25 lines]
>>
>> any suggestions?
Eliyahu Goldin - 26 Mar 2008 19:38 GMT
Oops, I copied it from a different context. The correct syntax for your case
is

<MailDefinition From="<%$ AppSettings:  EmailAddress %>" ...

The <appSettings> section in the web.config is correct.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin

> the code you posted gives me several warnings and errors:
>
[quoted text clipped - 39 lines]
>>>
>>> any suggestions?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.