How can I send a simple email?

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I have a web application from which I would like to send a simple
email message. By this I mean that I want the application to generate
an email, like an alert when a user comes and completes a form, not a
link that opens a window on the user's browser....

There are a couple of ways that one could go about this, and one seems
infinitely more preferable than the other. I would appreciate any
input on the subject, because I'm a little stuck on this one.

#1 - This would be the most preferable method - My application would
initiate communications with my SMTP server and send out the message.
I know the SMTP service has certain protocols, those EHLO messages,
etc. that are used to communicate with it. My application would need
to authenticate with the server, and then send the message to it, but
how would I go about doing this? Are there already C# classes in the
..NET framework for this? If not, where would I begin to put something
like this together? This is a small application, so I'm not really in
a position to go out and buy and license a big commercial component to
do this little task.

#2 - I understand that if you take a file and put it in the "drop"
folder under c:\inetpub\mailroot\ that SMTP will pick it up and send
it out. Is there a formatter available that will correctly format my
text into a message format the SMTP can send?

Thanks for any input on this. :)

JIM
 
Don't bother with the SMTP protocol, take a look at the System.Web.Mail
namespace.
You will find the APIs that you need.

Bruno.
 
Hi Jim,

Take a look at the SmtpMail class (System.Web.Mail)
Using SmtpMail.Send(MailMessage) you can send a mail from your own
computer (using SmtpServer = localhost) or another SmtpServer of your
choice. I haven't tried another server but using localhost you need to
enable IIS and SMTP.

Happy coding!
Morten
 
Hi Jim,

I do not find this the nicest example (it gives a postback), but to give you
an idea.

It is in VB.net code

Button1.Attributes("onClick") =
"window.location='mailto:[email protected]?subject=Cor demo&body=I hope this
helps?';"

I hope this helps anyway?

Cor
 
Cor,

The mailto:email link will open an e-mail client on the client machine. This
is not what Jim wants, he wants the server to generate an e-mail, and the
easiest way to go is to use the System.Web.Mail namespace.

Bruno.
 
Hi Bruno,

Are you sure of that, I was in doubt also, because this is the top of the
message from the OP.
I have a web application from which I would like to send a simple
email message. By this I mean that I want the application to generate
an email, like an alert when a user comes and completes a form, not a
link that opens a window on the user's browser....

Because of that I was not sure if the answers did fullfill the question.
And if not did the other answers that almost all, although this is also a
very nice link for that.

<http://www.systemwebmail.net/>

Cor
 
Back
Top