By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

Send email via external SMTP Server

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.