Hwo to send SMTP mail???

J

Jim

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 waht'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
 
M

Marc Scheuner [MVP ADSI]

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:

I've switched to using the Waldorf pix.mail component for SMTP - .NET
component, totally free, and a lot easier to use and more complete
than the System.Web.Mail stuff:

http://www.dnzone.com/ShowDetail.asp?NewsId=294

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
M

Morten Wennevik

Hi Jim,

Have you enabled SMTP in you IIS settings on your computer?
If it isn't enabled you typically get the "Could not access 'CDO.Message'"
error.

Go to Add/Remove Programs->Install windows components and make sure
Internet Information Services (IIS) is checked and check the details of
IIS to make sure SMTP is also checked. You might want to uncheck
everything you won't be using.

Happy coding!
Morten
 
C

Cor

Hi Morton,

That helps only in a testing situation. For customers it needs to be a
working SMTP server either from the Internet provider or the company SMTP
server or the company Exchange server. (And I thought that then there where
some simple changed needed, but I have them not at hand now)

When the customer has only one computer and it is an XP pro, than it can be
as you describe.

Cor
 
C

Cor

Hi Jim,

Why you are all the time talking about "the simplest of email messages" and
take a solution which is not difficult, but can be complicated in some
situation if you do not know all ins and outs?

Cor
 
M

Morten Wennevik

True, I was referring to the use of localhost as SMTP server (not
specifying server).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top