473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

adding smtpClient to web.config

Using VisualStudio 2005, asp.net 2.0:

What do I put in my Web.Config to avoid hard coding the: myserveraddress.com?

The following shows how I have hard coded it without having the value in the
we.config, and it works. However, I would like to place it in my web.config
file, and then just get the value from the web.config?

Can someone tell me what I need to add to the web.config

//send the message
System.Net.Mail.SmtpClient smtp = new
System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
smtp.Send(mail);
Apr 20 '06 #1
6 10470
check my blog:
http://spaces.msn.com/sholliday/ 2/8/2006 entry

I wrote a very nice (if I do say so my self) for having lots of flexibility
with smtp server settings.

There is a 2.0 and 1.1 example.


"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Using VisualStudio 2005, asp.net 2.0:

What do I put in my Web.Config to avoid hard coding the: myserveraddress.com?
The following shows how I have hard coded it without having the value in the we.config, and it works. However, I would like to place it in my web.config file, and then just get the value from the web.config?

Can someone tell me what I need to add to the web.config

//send the message
System.Net.Mail.SmtpClient smtp = new
System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
smtp.Send(mail);

Apr 20 '06 #2
The solution offered is more than I need.

Can someone simply provide a sample of the lines that I need to add to the
web.config for asp.net 2.0.

"sloan" wrote:
check my blog:
http://spaces.msn.com/sholliday/ 2/8/2006 entry

I wrote a very nice (if I do say so my self) for having lots of flexibility
with smtp server settings.

There is a 2.0 and 1.1 example.


"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
Using VisualStudio 2005, asp.net 2.0:

What do I put in my Web.Config to avoid hard coding the:

myserveraddress.com?

The following shows how I have hard coded it without having the value in

the
we.config, and it works. However, I would like to place it in my

web.config
file, and then just get the value from the web.config?

Can someone tell me what I need to add to the web.config

//send the message
System.Net.Mail.SmtpClient smtp = new
System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
smtp.Send(mail);


Apr 20 '06 #3
Add the <mailSettings> block in <system.net> block in the web.config file.
for e.g.
<system.net>
<mailSettings>
<smtp from="fr**@test.com">
<network host="127.0.0.1"
password="" userName="" />
</smtp>
</mailSettings>
</system.net>
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
The solution offered is more than I need.

Can someone simply provide a sample of the lines that I need to add to the
web.config for asp.net 2.0.

"sloan" wrote:
check my blog:
http://spaces.msn.com/sholliday/ 2/8/2006 entry

I wrote a very nice (if I do say so my self) for having lots of
flexibility
with smtp server settings.

There is a 2.0 and 1.1 example.


"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
> Using VisualStudio 2005, asp.net 2.0:
>
> What do I put in my Web.Config to avoid hard coding the:

myserveraddress.com?
>
> The following shows how I have hard coded it without having the value
> in

the
> we.config, and it works. However, I would like to place it in my

web.config
> file, and then just get the value from the web.config?
>
> Can someone tell me what I need to add to the web.config
>
> //send the message
> System.Net.Mail.SmtpClient smtp = new
> System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
> smtp.Send(mail);


Apr 20 '06 #4
Yes, thank you.
Using the web.config setting, what change needs to be made to the following
code.

//send the message
> System.Net.Mail.SmtpClient smtp = new
> System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
> smtp.Send(mail);


"Swanand Mokashi" wrote:
Add the <mailSettings> block in <system.net> block in the web.config file.
for e.g.
<system.net>
<mailSettings>
<smtp from="fr**@test.com">
<network host="127.0.0.1"
password="" userName="" />
</smtp>
</mailSettings>
</system.net>
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
The solution offered is more than I need.

Can someone simply provide a sample of the lines that I need to add to the
web.config for asp.net 2.0.

"sloan" wrote:
check my blog:
http://spaces.msn.com/sholliday/ 2/8/2006 entry

I wrote a very nice (if I do say so my self) for having lots of
flexibility
with smtp server settings.

There is a 2.0 and 1.1 example.


"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
> Using VisualStudio 2005, asp.net 2.0:
>
> What do I put in my Web.Config to avoid hard coding the:
myserveraddress.com?
>
> The following shows how I have hard coded it without having the value
> in
the
> we.config, and it works. However, I would like to place it in my
web.config
> file, and then just get the value from the web.config?
>
> Can someone tell me what I need to add to the web.config
>
> //send the message
> System.Net.Mail.SmtpClient smtp = new
> System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
> smtp.Send(mail);


Apr 20 '06 #5
Comment the first line where you are setting the smtpClient
and replace it by just

SmtpClient client = new SmtpClient();

System.Net.Mail reads SMTP configuration data out of the standard .NET
configuration system (so for ASP.NET applications you'd configure this in
your application's web.config file)

Check Scott Guthrie's post here :
http://weblogs.asp.net/scottgu/archi...10/432854.aspx
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com...
Yes, thank you.
Using the web.config setting, what change needs to be made to the
following
code.

//send the message
>> > System.Net.Mail.SmtpClient smtp = new
>> > System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
>> > smtp.Send(mail);

"Swanand Mokashi" wrote:
Add the <mailSettings> block in <system.net> block in the web.config
file.
for e.g.
<system.net>
<mailSettings>
<smtp from="fr**@test.com">
<network host="127.0.0.1"
password="" userName="" />
</smtp>
</mailSettings>
</system.net>
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> The solution offered is more than I need.
>
> Can someone simply provide a sample of the lines that I need to add to
> the
> web.config for asp.net 2.0.
>
> "sloan" wrote:
>
>> check my blog:
>> http://spaces.msn.com/sholliday/ 2/8/2006 entry
>>
>> I wrote a very nice (if I do say so my self) for having lots of
>> flexibility
>> with smtp server settings.
>>
>> There is a 2.0 and 1.1 example.
>>
>>
>>
>>
>> "theWizard1" <th********@discussions.microsoft.com> wrote in message
>> news:64**********************************@microsof t.com...
>> > Using VisualStudio 2005, asp.net 2.0:
>> >
>> > What do I put in my Web.Config to avoid hard coding the:
>> myserveraddress.com?
>> >
>> > The following shows how I have hard coded it without having the
>> > value
>> > in
>> the
>> > we.config, and it works. However, I would like to place it in my
>> web.config
>> > file, and then just get the value from the web.config?
>> >
>> > Can someone tell me what I need to add to the web.config
>> >
>> > //send the message
>> > System.Net.Mail.SmtpClient smtp = new
>> > System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
>> > smtp.Send(mail);
>>
>>
>>


Apr 20 '06 #6
Thank you. It all works. You made it so simple.

"Swanand Mokashi" wrote:
Comment the first line where you are setting the smtpClient
and replace it by just

SmtpClient client = new SmtpClient();

System.Net.Mail reads SMTP configuration data out of the standard .NET
configuration system (so for ASP.NET applications you'd configure this in
your application's web.config file)

Check Scott Guthrie's post here :
http://weblogs.asp.net/scottgu/archi...10/432854.aspx
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:18**********************************@microsof t.com...
Yes, thank you.
Using the web.config setting, what change needs to be made to the
following
code.

//send the message
>> > System.Net.Mail.SmtpClient smtp = new
>> > System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
>> > smtp.Send(mail);

"Swanand Mokashi" wrote:
Add the <mailSettings> block in <system.net> block in the web.config
file.
for e.g.
<system.net>
<mailSettings>
<smtp from="fr**@test.com">
<network host="127.0.0.1"
password="" userName="" />
</smtp>
</mailSettings>
</system.net>
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"theWizard1" <th********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
> The solution offered is more than I need.
>
> Can someone simply provide a sample of the lines that I need to add to
> the
> web.config for asp.net 2.0.
>
> "sloan" wrote:
>
>> check my blog:
>> http://spaces.msn.com/sholliday/ 2/8/2006 entry
>>
>> I wrote a very nice (if I do say so my self) for having lots of
>> flexibility
>> with smtp server settings.
>>
>> There is a 2.0 and 1.1 example.
>>
>>
>>
>>
>> "theWizard1" <th********@discussions.microsoft.com> wrote in message
>> news:64**********************************@microsof t.com...
>> > Using VisualStudio 2005, asp.net 2.0:
>> >
>> > What do I put in my Web.Config to avoid hard coding the:
>> myserveraddress.com?
>> >
>> > The following shows how I have hard coded it without having the
>> > value
>> > in
>> the
>> > we.config, and it works. However, I would like to place it in my
>> web.config
>> > file, and then just get the value from the web.config?
>> >
>> > Can someone tell me what I need to add to the web.config
>> >
>> > //send the message
>> > System.Net.Mail.SmtpClient smtp = new
>> > System.Net.Mail.SmtpClient("smtp.myserveraddress.c om");
>> > smtp.Send(mail);
>>
>>
>>


Apr 20 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rajesh Abraham | last post by:
I have an assembly, which is reading some values from the App.Config file. It works fine when used with a Win Forms project. Now I am trying to use the same assembly in a Windows Service...
2
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web>...
5
by: feng | last post by:
Hi, We just converted our VB.Net Windows exe project from VS.Net 2002 to VS.Net 2003 and ran into a problem. the MyApp.exe.config file that we use for our customized configuration settings is...
10
by: David Thole | last post by:
Hey all, I'm still very new at all this, but am going through the ASP.net 2.0 unleashed book, first chapter and trying to program my own little form emailer for fun. I tried following the code...
0
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that...
1
by: Sammy | last post by:
I am using the following code on a company that hosts our web site. I have noticed lately that their mail server/smtp is unavailable several times a minute for a second or two. This is causing my...
6
by: Peted | last post by:
Hi, im wanting to store some custom text strings in the app.config file of a c# app, to be retreived and updated when the app runs. using c# 2005 express in my testing i am using the code...
6
by: =?Utf-8?B?VG9yc3Rlbg==?= | last post by:
Hi, I have a problem sending mails with the SmtpClient class. It's strange - after I boot the pc and start the program I can send mails many times. After I close the program and start it again...
5
by: BigDave | last post by:
Hi, I'm having problems with SmtpClient. I have the following set in my web.config: <configuration> <system.net> <mailSettings> <smtp> <network host="mysmtp" port="25" userName="myuser"
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.