tags:

views:

2418

answers:

4

I have a .Net application. I want this application to send an email to me. How do I implement this without installing an SMTP server?

+1  A: 

Why don't you contact the smtp service of your mail provider?

soulmerge
It is generally not possible to connect to the SMTP service outside of the provider's network. A GMail account could be used though.
kgiannakakis
Ummm, you mean all other providers receive mail by magic?
soulmerge
+4  A: 

You can't send email without the services of a SMTP server, there is of course no need for you to install one, just point your code at your ISPs SMTP server or your companies Exchange server (or what ever they use).

AnthonyWJones
+3  A: 

This article by Peter Bromberg on eggheadcafe.com

C# SMTP Mail without SMTP Service or CDO

explains how to send email without relying on an SMTP service:

Sending email via TCP using the native SMTP RFC commands "HELO", "MAIL From", RCPT TO", etc. is no big deal. That's one of the first tricks we learn with Telnet. Finding or writing managed code that will do so reliably is another story. The code in the class that follows is not my original code - I've cobbled it together from three different sample sources, fixing namespaces, error handling, and other minor items, changing console code to class library code, and providing a complete Winforms - based test harness front end that illustrates its correct usage.

I've also included sample code to correctly process and add a mail attachment via an OpenFileDialog here. This code MIME encodes and transmits the attachment(s) according to the specification.

splattne
This still relies on there being an SMTP server on the other end; I'm not sure what benefit you're getting not using SmtpClient and MailMessage...
Daniel LeCheminant
Ehm, there always MUST be an SMTP server on the other side. This example shows you sending mail using the SMTP protocol explicitly in your code.
splattne
@splattne: Okay ... I guess it could be interesting/fun to implement the protocol yourself ;]
Daniel LeCheminant
+7  A: 

Using an SmtpClient to send a MailMessage does not require you to have a server on your local machine.

Your e-mail service provider is the one with the server (e.g. smtp.gmail.com), and your SmtpClient talks to it.

Daniel LeCheminant