Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

sending an email in .NET

We are currently using Delphi 8 for .Net (Windows Form Application) and trying to send an email.

We have seen examples of using the System.Web.Mail.SmtpMail object with the MailMessage and MailAttachement objects.  BUT, we don’t want to ask the user for a SMTPServer each time (or at all).  Using blank or ‘localhost’ is not an option as the user must have the SMTP Service setup on there machine.

We would like to keep to pure .NET and stay away from the Borland VCL.

Is there another way?


Wednesday, September 22, 2004

Why ask more than once. All email clients need pointed at a server or three somewhere. Most use a setup/configuration dialog box that allows the user to point it at a server, and then saves it off somewhere.

Why not store the server in a config file, and only ask the user when you don't have a server already named in the config file? Once they give you the server, store it to the config file so you don't have to ask for it again. Read it from the config file next time (and from then on).

This is not .NET specific, and has nothing to do with System.Web.Mail.SmtpMail. It has to do with how do you persist user configurable settings. There are a number of ways you can save a user's settings (like their smtp server): You can store it in a config file, in an XML file, in an .ini file, you can store it in the registry, you can store it in a database, ...

The whole idea is to have the user specify the server once, store that value and never ask for it again -- but give them a way to change the server if they want to.

This is application programming 101. Is this really that difficult?

Sgt. Sausage
Wednesday, September 22, 2004

Just to add a little to Sgt. Sausage's reply:

If all of your users have a well defined common environment with an e-mail client then you could use the e-mail server connection details stored in there. For example, if everyone has Outlook then you could pick up the server connection and logon credentials from the Outlook e-mail account record(s).

In fact, if you can assume that Outlook is always available then you could integrate your application with Outlook and send e-mail via that route.

Thursday, September 23, 2004

*  Recent Topics

*  Fog Creek Home