473,407 Members | 2,359 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,407 software developers and data experts.

Send email via external SMTP Server

I am working with three computers, my developing computer, a Web Server and a
Mail Server (Exchange).

I am trying to send a email from the Web Server via the Mail Server to a
valid email address with this code:

MailMessage msgMail = new MailMessage();
msgMail.To = "te**@address.com";
msgMail.From = "fr**@address.com";
msgMail.Subject = "Mail Example Subject";
msgMail.Body = "MAIL EXAMPLE BODY";
SmtpMail.SmtpServer = "[Server Name]";
SmtpMail.Send(msgMail);

Which does not work.

My biggest problem is that everything works perfectly on my developing
computer when I try to send mail via the Mail Server with the same code.

Why can't I send mail from the Web Server?
Nov 19 '05 #1
5 8764
System.Web.Mail use CDO. The CDO dll (cdo.dll, cdont.dll or cdoex.dll, I can't remember which one .NET use) is probably installed on you dev box, but not on the web server.

If this does not work catch the exception and check the InnerException for a more detailed message why it failed.

Willie

nntp://news.microsoft.com/microsoft.public.dotnet.framework.aspnet/<AB**********************************@microsoft.co m>

I am working with three computers, my developing computer, a Web Server and a
Mail Server (Exchange).

I am trying to send a email from the Web Server via the Mail Server to a
valid email address with this code:

MailMessage msgMail = new MailMessage();
msgMail.To = "te**@address.com";
msgMail.From = "fr**@address.com";
msgMail.Subject = "Mail Example Subject";
msgMail.Body = "MAIL EXAMPLE BODY";
SmtpMail.SmtpServer = "[Server Name]";
SmtpMail.Send(msgMail);

Which does not work.

My biggest problem is that everything works perfectly on my developing
computer when I try to send mail via the Mail Server with the same code.

Why can't I send mail from the Web Server?
[microsoft.public.dotnet.framework.aspnet]
Nov 19 '05 #2
On Fri, 14 Jan 2005 02:23:01 -0800, "Andreas"
<An*****@discussions.microsoft.com> wrote:
I am working with three computers, my developing computer, a Web Server and a
Mail Server (Exchange).

I am trying to send a email from the Web Server via the Mail Server to a
valid email address with this code:

MailMessage msgMail = new MailMessage();
msgMail.To = "te**@address.com";
msgMail.From = "fr**@address.com";
msgMail.Subject = "Mail Example Subject";
msgMail.Body = "MAIL EXAMPLE BODY";
SmtpMail.SmtpServer = "[Server Name]";
SmtpMail.Send(msgMail);

Which does not work.
exception? no mail in queue? something else?

I've had trouble with SMTP and my local machine firewall - symptom was mail
sitting in the queue...

J

My biggest problem is that everything works perfectly on my developing
computer when I try to send mail via the Mail Server with the same code.

Why can't I send mail from the Web Server?


Nov 19 '05 #3
Thanks for the reply!

I still have the same problem and I have found out that I have these DLL's
installed:

I have on the win2003 Web Server:
cdosys.dll
mapi32.dll

I do NOT have on the win2003 Web Server
cdonts.dll
cdo.dll
cdoex.dll

---------------------------------------

I have in my XP dev. computer:
cdo.dll
cdosys.dll
mapi32.dll

I do NOT have in my XP dev. computer:
cdonts.dll
cdoex.dll

I an trying to catch the expection but nothing is being thrown...

/ Andreas
Nov 19 '05 #4
Thank you very much!

Everything works perfectly now!

/Andreas
"Juan T. Llibre" wrote:
Hi, Andreas.

Windows 2003 doesn't use CDONTS.

It uses System.Web.Mail ( which uses cdosys )
for .Net apps.

See
http://support.microsoft.com/default...1&PA=1&SD=HSCH

You might want to test your capacity to send email
using the CDO Object in W2K3 ( CDOSYS )
by modifying the attached .vbs script and running it.

The script is available online at Microsoft at
http://support.microsoft.com/kb/286431?FR=1

You can download it from there, or use the attached file.
They're the same file.

I added a .txt extension in case the .vbs extension
is blocked by your client email program or ISP.

You'll need to erase the ".txt" part of
the filename so it can run as a .vbs script.

You can edit it by highlighting the .vbs file
right-clicking it, and selecting "Edit" from the menu.

Then, all you need to change is the name of the remote smtp
server's name, the "To:" address and the "From:" address.

Place the modified file in any directory ( I used the "temp" dir )
and double-click the vbs file from within Windows Explorer.

If your system is configured correctly, the CDOSYS mail
will be sent and you should receive in a very short time.

There's several reasons why you might not
be being allowed to send CDOSYS mail.

The most common one is that the remote smtp server
requires authentication. i.e., that you might not have
sufficient permissions to send mail through that server.

Many companies require authentication because if they
ran open relay smtp servers, they'd be liable for all SPAM
mail sent through their smtp server, not to mention that the
bandwidht consumed would cost a small fortune
( maybe even a large fortune ) when spammers find out
that they can send mail through an open relay smtp server.

Another very common situation is that your ISP
is blocking packets on the port you need to send mail.

( Again, Many ISPs don't want the possibility of their clients
unwittingly serving as relay servers for spammers. )

Running this test will at least enable you to know
whether your system is configured to send email
using CDOSYS, and whether your ISP's configuration
allows mail to be sent through their smtp server.

Then we could look for the reasons why
it's not working from your ASP.NET app.

Let us know how it goes.

Juan T. Llibre
ASP.NET MVP
===========
"Andreas" <An*****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
Thanks for the reply!

I still have the same problem and I have found out that I have these DLL's
installed:

I have on the win2003 Web Server:
cdosys.dll
mapi32.dll

I do NOT have on the win2003 Web Server
cdonts.dll
cdo.dll
cdoex.dll

---------------------------------------

I have in my XP dev. computer:
cdo.dll
cdosys.dll
mapi32.dll

I do NOT have in my XP dev. computer:
cdonts.dll
cdoex.dll

I an trying to catch the expection but nothing is being thrown...

/ Andreas


Nov 19 '05 #5
Glad that got you on the right track, Andreas.

Juan T. Llibre
ASP.NET MVP
===========
"Andreas" <An*****@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
Thank you very much!

Everything works perfectly now!

/Andreas
"Juan T. Llibre" wrote:
Hi, Andreas.

Windows 2003 doesn't use CDONTS.

It uses System.Web.Mail ( which uses cdosys )
for .Net apps.

See
http://support.microsoft.com/default...1&PA=1&SD=HSCH

You might want to test your capacity to send email
using the CDO Object in W2K3 ( CDOSYS )
by modifying the attached .vbs script and running it.

The script is available online at Microsoft at
http://support.microsoft.com/kb/286431?FR=1

You can download it from there, or use the attached file.
They're the same file.

I added a .txt extension in case the .vbs extension
is blocked by your client email program or ISP.

You'll need to erase the ".txt" part of
the filename so it can run as a .vbs script.

You can edit it by highlighting the .vbs file
right-clicking it, and selecting "Edit" from the menu.

Then, all you need to change is the name of the remote smtp
server's name, the "To:" address and the "From:" address.

Place the modified file in any directory ( I used the "temp" dir )
and double-click the vbs file from within Windows Explorer.

If your system is configured correctly, the CDOSYS mail
will be sent and you should receive in a very short time.

There's several reasons why you might not
be being allowed to send CDOSYS mail.

The most common one is that the remote smtp server
requires authentication. i.e., that you might not have
sufficient permissions to send mail through that server.

Many companies require authentication because if they
ran open relay smtp servers, they'd be liable for all SPAM
mail sent through their smtp server, not to mention that the
bandwidht consumed would cost a small fortune
( maybe even a large fortune ) when spammers find out
that they can send mail through an open relay smtp server.

Another very common situation is that your ISP
is blocking packets on the port you need to send mail.

( Again, Many ISPs don't want the possibility of their clients
unwittingly serving as relay servers for spammers. )

Running this test will at least enable you to know
whether your system is configured to send email
using CDOSYS, and whether your ISP's configuration
allows mail to be sent through their smtp server.

Then we could look for the reasons why
it's not working from your ASP.NET app.

Let us know how it goes.

Juan T. Llibre
ASP.NET MVP
===========
"Andreas" <An*****@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
> Thanks for the reply!
>
> I still have the same problem and I have found out that I have these
> DLL's
> installed:
>
> I have on the win2003 Web Server:
> cdosys.dll
> mapi32.dll
>
> I do NOT have on the win2003 Web Server
> cdonts.dll
> cdo.dll
> cdoex.dll
>
> ---------------------------------------
>
> I have in my XP dev. computer:
> cdo.dll
> cdosys.dll
> mapi32.dll
>
> I do NOT have in my XP dev. computer:
> cdonts.dll
> cdoex.dll
>
> I an trying to catch the expection but nothing is being thrown...
>
> / Andreas


Nov 19 '05 #6

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

Similar topics

6
by: Owen | last post by:
I am sending email using CDO but it only seems to work when the "To" address is within the same domain as mine. When I send to an outside domain (eg. yahoo.com) the mail simply does not reach...
1
by: StevenBarnes | last post by:
I need to have some .Net code be able to send Email using my ISP's SMTP server. I found some articles on how to use the MAIL FROM: and RCPT TO: commands that you can stream to a tcp connection on...
6
by: erdem kemer | last post by:
i cant send mail to yahoo mail or hotmail while i can send my other mail accounts (pop3) is it becouse yahoo and hotmail is web-based mail here is the code MailMessage mailMsg = new...
14
by: supz | last post by:
Hi, I use the standard code given below to send an email from an ASP.NET web form. The code executes fine but no Email is sent. All emails get queued in the Inetpub mail queue. I'm using my...
9
by: Peter | last post by:
I have created a small windows app that gathers some user entered data, then prints it to a designated printer. A specific person then collects the prints from the printer and processes the info...
11
by: fdu.xiaojf | last post by:
Hi, I just want to send a very simple email from within python. I think the standard module of smtpd in python can do this, but I haven't found documents about how to use it after googleing....
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
7
by: Ron Hinds | last post by:
Our webserver is currently Windows 2000 Server. Many of our pages send mail using the CDONTS object library. It is simple and very straightforward. We have built a new webserver using Windows...
3
by: IanReardon | last post by:
Is it possible to configure an external SMTP server to route all of your outgoing mail through on Linux? I know in php.ini there is a parameter, but it says its only for windows? Can I do this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.