Sending SMTP mail

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posed the question the other day, that I am having trouble trying to send an email message from my .NET application. I was using System.Web.Mail.SmtpMail, and it was suggested that I try Waldorf PixMail instead. I did this, and I'm still having the same issues..

1. My SMPT server IS correctly configured and IS running; I can send mail from any application (like Outlook) on my network, and I have no problems

2. My SMTP server currently has no restrictions for relaying, and allow annonymous access

3. I have even tried this using my ISP's email server, and I get the same results

When I try to send mail, it always says something about that it cannot contact the SMTP server, or "Server respnose unavailable" (That's the one I get when I try to use System.Web.SmtpMail.SendMail(). ) The nearest thing I have found to an answer is that this "MIGHT" have something to do with "CDO not being correctly configured....", of course, common sense would say that if you're going to say this is a possible error, you'd also include a link to how to fix it... but not... ::sigh:: Is there "somethinig" that needs to be, perhaps, in my "app.confgi" or "web.comfig" file to make all this work? I don't see any mention of this, but I cannot get this to work. Again, I even tried it with my ISP's server, just in case for some reason the thing didn't like my DNS names... or whatever... I opened the DMZ on my firewall, and used my ISP's DNS and their mail server... .and still no luck. None of thee mail servers require authenticaion. It's like the thing can't find the server for some reason, but that doesn't make any sense, because everything else seems to find it! Can anyone offer any suggestions? Thanks

JIM
 
Here is the entire ORIGINAL post of this... Again, I know the server is set up correctly... Interestingly enough, I found a very old discussion thread on the web that discusses this EXACT issue. A concsie explanation of what happened and what fixed it was never really given and, in my case, changing the server settings around didn't have any effect anyway, as I've changed just about everything I can imagine to try and make this work. Below is my original post, and here is a link to that article I found today (as I said, it didn't turn out to give me any answers, but at least maybe it will help ring a bell in someone's mind as to what might be wrong here.) That article / thread is

http://www.dotnet247.com/247reference/msgs/14/71327.asp

Please note that I HAVE ALREADY TRIED setting the host to "localhost", and enabling SMTP on my local machine. I have also tried just leaving it blank. There is "SOME REASON" why this thing (and, for that matter, also the Waldorf PixMail SMTP cmoponent) isn't seeing my server or talking to it correctly... Could I need something in that XML "app.config" or "web.config" file???

And finally, here is the original post, including the error and exception dump

I posted a query about this yesterday, and got a lot of helpful an
useful information back... but it still won't work. For the moment
I want to send the simplest of email messages, using th
System.Web.Mail.SmtpMail class.... So, here's what't in in my littl
ol' console app

System.Web.Mail.SmtpMail.SmtpServer="smtp.myplace.com"
System.Web.Mail.SmtpMail.Send
"(e-mail address removed)", "(e-mail address removed)", "test", "This is a tes
message!")

According to the docs, if I do not set the SmtpServer property at all
the mail will be sent with the machine's local SMTP server. It run
with no errors, but nothing ever happens. I have an SMTP serve
running on the local netowrk, which we'll call "myplace.com". When
set the value of the server, as you see above, my application blows u
with an error... I've disabled all the security on the server an
allowed relaying and all that, just to make sure it easn't SOMETHIN
the server was doing... All my email programs work fine... but I can'
make this go no matter WHAT I do!!!! I don't understand this erro
message... What am I doing WRONG??? Why won't the MS docs just tel
you what's wrong? LOL Here is the exception dump that I get

Unhandled Exception: System.Web.HttpException: Could not acces
'CDO.Message' o
ject. ---> System.Reflection.TargetInvocationException: Exception ha
been thro
n by the target of an invocation. ---
System.Runtime.InteropServices.COMExcept
on (0x80040211): The message could not be sent to the SMTP server. Th
transpor
error code was 0x80040217. The server response was not availabl

--- End of inner exception stack trace --
at System.RuntimeType.InvokeDispMethod(String name, BindingFlag
invokeAttr
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture
String[
namedParameters
at System.RuntimeType.InvokeMember(String name, BindingFlag
invokeAttr, Bin
er binder, Object target, Object[] args, ParameterModifier[
modifiers, Culture
nfo culture, String[] namedParameters
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj
String metho
Name, Object[] args
--- End of inner exception stack trace --
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj
String metho
Name, Object[] args
at System.Web.Mail.CdoSysHelper.Send(MailMessage message
at System.Web.Mail.SmtpMail.Send(String from, String to, Strin
subject, Str
ng messageText
at SMTTestContainer.Class1.Main(String[] args) in d:\m
documents\visual stu
io projects\teststuff\smttestcontainer\class1.cs:line 2

Any suggestions? Thanks

JI

FOOTNOTE - From the looks of this, it looks like something is wrong with that CDO thing... Is this a DLL that I'm missing? Is there some service that needs to be enabled, installed, or otherwise configured?
 
Hi Jim,

The error message you are getting is just a generic error so it doesn't give
many pointers to the exact problem. It seems that your SMTP server is
getting the mail but is rejecting it for some reason.

I put SMTP emailing capabilities into an app I built not too long ago and
initially I was getting the exact same error message. It took me a while to
track down the problem but turned out to be that the 'From' email address I
was supplying was not in a valid email address format. Yours looks to be in
a valid format but one thing I will suggest is that the SMTP Service on your
server may be configured for reverse DNS lookup which means it will check
that the 'From' email address is from a valid source. If 'yeahright.net' is
not a valid domain name then it may be rejecting the email for this reason.
If you haven't already done this then try sending the email with your own
company email address in both the 'From' and 'To' parameters.

Gary


Jim said:
Here is the entire ORIGINAL post of this... Again, I know the server is
set up correctly... Interestingly enough, I found a very old discussion
thread on the web that discusses this EXACT issue. A concsie explanation of
what happened and what fixed it was never really given and, in my case,
changing the server settings around didn't have any effect anyway, as I've
changed just about everything I can imagine to try and make this work.
Below is my original post, and here is a link to that article I found today
(as I said, it didn't turn out to give me any answers, but at least maybe it
will help ring a bell in someone's mind as to what might be wrong here.)
That article / thread is:
http://www.dotnet247.com/247reference/msgs/14/71327.aspx

Please note that I HAVE ALREADY TRIED setting the host to "localhost", and
enabling SMTP on my local machine. I have also tried just leaving it blank.
There is "SOME REASON" why this thing (and, for that matter, also the
Waldorf PixMail SMTP cmoponent) isn't seeing my server or talking to it
correctly... Could I need something in that XML "app.config" or
"web.config" file????
And finally, here is the original post, including the error and exception dump:

I posted a query about this yesterday, and got a lot of helpful and
useful information back... but it still won't work. For the moment,
I want to send the simplest of email messages, using the
System.Web.Mail.SmtpMail class.... So, here's what't in in my little
ol' console app:


System.Web.Mail.SmtpMail.SmtpServer="smtp.myplace.com";
System.Web.Mail.SmtpMail.Send(
"(e-mail address removed)", "(e-mail address removed)", "test", "This is a test
message!");

According to the docs, if I do not set the SmtpServer property at all,
the mail will be sent with the machine's local SMTP server. It runs
with no errors, but nothing ever happens. I have an SMTP server
running on the local netowrk, which we'll call "myplace.com". When I
set the value of the server, as you see above, my application blows up
with an error... I've disabled all the security on the server and
allowed relaying and all that, just to make sure it easn't SOMETHING
the server was doing... All my email programs work fine... but I can't
make this go no matter WHAT I do!!!! I don't understand this error
message... What am I doing WRONG??? Why won't the MS docs just tell
you what's wrong? LOL Here is the exception dump that I get:

Unhandled Exception: System.Web.HttpException: Could not access
'CDO.Message' ob
ject. ---> System.Reflection.TargetInvocationException: Exception has
been throw
n by the target of an invocation. --->
System.Runtime.InteropServices.COMExcepti
on (0x80040211): The message could not be sent to the SMTP server. The
transport
error code was 0x80040217. The server response was not available

--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[]
namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Bind
er binder, Object target, Object[] args, ParameterModifier[]
modifiers, CultureI
nfo culture, String[] namedParameters)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
String method
Name, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj,
String method
Name, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(String from, String to, String
subject, Stri
ng messageText)
at SMTTestContainer.Class1.Main(String[] args) in d:\my
documents\visual stud
io projects\teststuff\smttestcontainer\class1.cs:line 24


Any suggestions? Thanks.

JIM

FOOTNOTE - From the looks of this, it looks like something is wrong with
that CDO thing... Is this a DLL that I'm missing? Is there some service
that needs to be enabled, installed, or otherwise configured?
 
Gary

Thanks... Actually, I did just that. The only reason for the phoney addresses / domains here is that I don't want the spammers scooping my email address out of the newsgroups

I'm thinknig now that maybe I just need to put a share on the machine hosting the SMTP server, and then properly format my message and save it into the sever's "drop" folder. I need to get this darn thing done, or I'm not gonna get paid. LOL

JIM
 
Jim,

Just a thought but have you tried knocking up a quick app that sends an
email and running executable on the SMTP server itself (as an
administrator)? This might help to eliminate/pinpoint any issues with your
internal network routing/security when running the app from your development
machine.

Gary

Jim said:
Gary,

Thanks... Actually, I did just that. The only reason for the phoney
addresses / domains here is that I don't want the spammers scooping my email
address out of the newsgroups.
I'm thinknig now that maybe I just need to put a share on the machine
hosting the SMTP server, and then properly format my message and save it
into the sever's "drop" folder. I need to get this darn thing done, or I'm
not gonna get paid. LOL
 
Gary,

I'm actually about half a chapter ahead of you... LOL that is
PRECISELY what I was doing when I got your message... I think I have
it working... uhm... sort of... LOL This is REALLY INTERESTING.....

The program fails to find the SMTP server on my build machine.
However, if I run the assembly ON my server, it DOES find the server,
whether I leave the SmtpServer property blank (to default to
localhost) or actually specify the DNS name of the server. I know it
is reading that property though, because if I misspell the server
name, it will fail (as it should)... BUT, Gary, here's what I think is
REALLY interesting...

If I go over to the server and run the program from over the network
(like going to Explorer and typing
\\buildmach\c$\VSProjects\SmtpTest\Bin\Debug\ and then clicking
SmstpTest.exe), the thing fails. Copy the EXE file though (and the
dll that supports it), over onto a local directory on the server (like
My Dcouments), and click it, and it runs fine. In both instances, the
thing is executing in the context of local machine environment; the
only difference is the path over which it gets the initial EXE and
initializes the dll. The only thing I can come up with at this point,
is that some kind of request is sent off to the SMTP service to tell
it, "Hey, I have something for you." The server comes back and says,
"Oh yeah, well initialize this dll....." and the server tries to
initialize a dll that is on the remote machine sending the mail, and
for some reason, that fails. That sounds stupid and almost completely
baeless, but I can't think of any other reason why the program would
run from one location, and not another, especially on the same
machine. Interestingly enough, if I do just the opposite... That is,
go back to the build machine, and try ot run the program outside of
the VS environment, it still blows up. If I try to run it remotely
off of the server, it still blows up, so that blows a hole in my
previous theory..... This is making me nuts!!! LOL How am I supposed
to troubleshoot something like this? :(

Any feedback?

Jim
 
Jim,

Don't forget that running the EXE from a network location may introduce
other issues because unless you have specifically configured the machine to
allow it to run .NET programs from the network, the security model of the
..NET Framework will no allow this by default.

It definitely sounds like your server isn't allowing SMTP access from an
external source. Have you checked that the port 25 is open on the server?
It might be worth trying to Telnet into port 25 on the server and see what
response you get...

http://www.activexperts.com/activemail/telnet/

It may also be worth doing a search to see if there are any SMTP diagnostic
tools that might help track down the problem. Another thing that might be
worthwhile doing is to set up the SMTP service up on another server and try
sending via that.

I'm afraid I won't be able to respond again until later on tomorrow as it is
the early hours of the morning here in the UK and it is time I got my head
down.

Gary
 
What OS are you running on? IIRC, .NET SMTP mail is a wrapper around CDO mail,
which is what your trace indicates. Sending mail from Outlook proves nothing
because it probably uses the MAPI mail provider, not SMTP

CDO is installed on Server OS-s, perhaps not by default on workstation systems.
Is CDOSYS.DLL on your system? Does this VBScript work?? Is there a
CDONTS.NewMail in HKCR?

Set objMail = CreateObject("CDONTS.Newmail")
objMail.Send "(e-mail address removed)", (e-mail address removed), "Bad news", "You owe me
$20"
Set objMail = Nothing

--
Phil Wilson [MVP Windows Installer]
----
Jim said:
I posed the question the other day, that I am having trouble trying to send an
email message from my .NET application. I was using System.Web.Mail.SmtpMail,
and it was suggested that I try Waldorf PixMail instead. I did this, and I'm
still having the same issues...
1. My SMPT server IS correctly configured and IS running; I can send mail
from any application (like Outlook) on my network, and I have no problems;
2. My SMTP server currently has no restrictions for relaying, and allow annonymous access;

3. I have even tried this using my ISP's email server, and I get the same results.

When I try to send mail, it always says something about that it cannot contact
the SMTP server, or "Server respnose unavailable" (That's the one I get when I
try to use System.Web.SmtpMail.SendMail(). ) The nearest thing I have found to
an answer is that this "MIGHT" have something to do with "CDO not being
correctly configured....", of course, common sense would say that if you're
going to say this is a possible error, you'd also include a link to how to fix
it... but not... ::sigh:: Is there "somethinig" that needs to be, perhaps, in
my "app.confgi" or "web.comfig" file to make all this work? I don't see any
mention of this, but I cannot get this to work. Again, I even tried it with my
ISP's server, just in case for some reason the thing didn't like my DNS names...
or whatever... I opened the DMZ on my firewall, and used my ISP's DNS and their
mail server... .and still no luck. None of thee mail servers require
authenticaion. It's like the thing can't find the server for some reason, but
that doesn't make any sense, because everything else seems to find it! Can
anyone offer any suggestions? Thanks.
 
I don't know whats going on with your SMTP box - but I can tell you that its probably not down to CDO being installed correctly. Waldorf.pixmail works by opening a socket connection directly to your SMTP server and sends the mail that way - it doesn't use any other messaging layer.

Maybe its worth telneting to your smtp box to see if you get a response? From a command line (sorry if this is 'teaching you to suck eggs' ;-)

telnet smtp-box-ip-address 25

If you get a response at least it eliminates that possibility.

Cheers,
Andy Pickering

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Back
Top