Console App Email

A

Adam

I need a console application to send me an e-mail....in
the past I have use SQL Server's mail messaging to send my
e-mails for console applications, but often the SQL Server
mail message will not get sent because the SQL Server
times out....In my web pages I use the Web MailMessage
object, and it does very well....Can I use the Web
MailMessage object in a console application, if so how do
I set it up, if not what options are there other than SQL
Server's mail messaging?

Thanks,
Adam
 
J

Jon Skeet [C# MVP]

Adam said:
I need a console application to send me an e-mail....in
the past I have use SQL Server's mail messaging to send my
e-mails for console applications, but often the SQL Server
mail message will not get sent because the SQL Server
times out....In my web pages I use the Web MailMessage
object, and it does very well....Can I use the Web
MailMessage object in a console application, if so how do
I set it up, if not what options are there other than SQL
Server's mail messaging?

Yes, you can use MailMessage in a console app - but because it uses
CDO, there are a few restrictions about platforms it will run on.

You could always use Indy: http://www.indyproject.org
 
W

William Stacey [MVP]

There are also tons of native smtp client examples on sites like
csharp-corner, etc. The Indy is good, but required the library which may be
overkill for your distribution.
 
C

Chad Z. Hower aka Kudzu

William Stacey said:
There are also tons of native smtp client examples on sites like
csharp-corner, etc. The Indy is good, but required the library which

All of these implement only the basics and users will quickly be in trouble
as these "snippets" only implement the base of the protocol. They wont work
wtih all servers because of auth, ESTMP, EHLO, MIME and other reasons. I
would cosnider such snippets of academic use only and not safe for
production.

I understand your point of view, but its a bit like telling a developer not
to use C# because its overkill, but rather use one of the academic languages
for .NET like those found on MSDN.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 
W

William Stacey [MVP]

I understand your point of view, but its a bit like telling a developer
not
to use C# because its overkill, but rather use one of the academic languages
for .NET like those found on MSDN.

Maybe. The snippets also get you to learn a little bit and build your own
classes, which is focus of ng (IMO.) We can and do point people to dll
Libraries as needed, but we could do that for almost every question - that
is a lot of Dlls in your application. Sometimes folks just want to see some
code and as Indy is delphi and this is a c# ng, you can't really look at c#
code (correct if wrong.) That said, I recommend your good library all the
time when someone asks for a library or if I ~think they are really needing
a library as apposed to some good old sample code. Anyway, all is good.
Cheers!
 
C

Chad Z. Hower aka Kudzu

William Stacey said:
Maybe. The snippets also get you to learn a little bit and build your
own classes, which is focus of ng (IMO.) We can and do point people to

Yes, I agree if its for a learning or academic use. Snippets are much better
in that case.
to see some code and as Indy is delphi and this is a c# ng, you can't
really look at c# code (correct if wrong.) That said, I recommend your

But there is tons of code in C# using Indy. The FCL is is a lot of C++, and
C# but that doesnt stop VB developers from using it. Thats the beauty of .NET
- language is irrelevant.
good library all the time when someone asks for a library or if I ~think
they are really needing a library as apposed to some good old sample

Thanks. But its not my library. :)

Indy has a team of 45 core developers on it - Im just the active one in the
..NET groups.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
W

William Stacey [MVP]

But there is tons of code in C# using Indy. The FCL is is a lot of C++,
and

"using Indy" is key, the library itself is c++ or delphi, not c# -
right/wrong?
 
C

Chad Z. Hower aka Kudzu

William Stacey said:
"using Indy" is key, the library itself is c++ or delphi, not c# -
right/wrong?

Its Delphi - but that doesnt matter. .NET assemblies are .NET assemblies. A
C# or VB or Delphi programmer no longer cares what the assembly is written
in.

Do you care what the FCL is in? Or a commerical assembly? No - its .NET and
works in any .NET language, C#, VB or Delphi.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
 
W

William Stacey [MVP]

BTW - in case you are not aware - Delphi is a .NET language now too. Its
not
an unmanaged library with a COM interface on top. Its IL.

Kool. Did not know that. Will need to check it out.
 
W

William Stacey [MVP]

Its Delphi - but that doesnt matter. .NET assemblies are .NET assemblies.

Thanks for clearing that up Chad ;) We both understand this. That was not
the point. The point was I could not open the assembly and look at the code
without Delphi knowlege or Dephi .Net as you said in other post. We both
agree it is good lib. This is probably now OT so I punt. Cheers.
 
C

Chad Z. Hower aka Kudzu

William Stacey said:
Thanks for clearing that up Chad ;) We both understand this. That was
not the point. The point was I could not open the assembly and look at
the code without Delphi knowlege or Dephi .Net as you said in other

Yes you can. Open it in reflector and you can see it as C#, VB, or Delpi.
Reflector even has a Delphi plugin now....

But then again it goes back to does the user want to USE a library, or look
at code acadmically?


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
P

Patrick de Ridder

I have tried the Hower code and get an error at the line

LSMTP.Connect();

The error is "incorrect domain name"
I have checked all the domain names, and there is nothing wrong with them.
Any suggestions?

Patrick.
 
P

Patrick de Ridder

These are the error messages I get.
Any suggestions how to get this thing working properly?
Many thanks,
Patrick.

t Indy.Sockets.IndyReplySMTP.ReplySMTP.RaiseReplyError()
at
Indy.Sockets.IndyTCPConnection.TCPConnection.RaiseExceptionForLastCmdResult(
)
at Indy.Sockets.IndyTCPConnection.TCPConnection.CheckResponse(Int16
AResponse, Int16[] AAllowedResponses)
at Indy.Sockets.IndyTCPConnection.TCPConnection.GetResponse(Int16[]
AAllowedResponses)
at Indy.Sockets.IndyTCPConnection.TCPConnection.SendCmd(String AOut,
Int16[] AResponse)
at Indy.Sockets.IndyTCPConnection.TCPConnection.SendCmd(String AOut,
Int16 AResponse)
at Indy.Sockets.IndySMTPBase.SMTPBase.SendGreeting()
at Indy.Sockets.IndySMTP.SMTP.Connect()
at SendMail.Form1.butnSendMail_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
 

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