Is this for retail users or corporate clients? The answer to this will help
you narrow down the options.
The MailTo ShellExecute (or process.start) will create a message in whatever
default email client they use, just like a mailto link does on a web page.
The message will have all of it's fields filled in but the sending is up to
them (and they can get at the message and alter it manually). Even with
this limitation, this is probably the most quickly useful for retail apps
where you have no control over what the users are running.
Automating Outlook is viable to a point in a retail app. You'll have to
consider how to handle users who don't have Outlook installed (possibly
using the MailTo technique for those users) ... and you have to consider all
of the the intricacies of the various versions of Outlook that might be
installed. In a corporate setting this might be your primary choice because
in a typical corporate environment all users will most likely be on the
same version of Outlook. The downside is still that there will be that
security popup that the user must agree to before the message is added to
their outbox.
Using SMTP (CDO or it's .Net wrapper in the System.Web and System.Web.Mail
namespaces) is also a fine option for corporate deployment because you
usually know that there is a SMTP server somewhere on your internal network
and all you have to do is connect to it. The message in this case doesn't
go to the Outlook outlox and then to their SentItems folder, it gets sent
directly. You say that this is an interesting option but that you don't yet
have much experience using it... look again at the code I posted, that's the
extent of what you need to know to do the job... as long as somewhere on
your network there is a Windows 2000/2003 server running the SMTP service
(or any SMTP Service ... I use that on a project where the SMTP service is
Argosoft Mail Server, not the Windows SMTP Service, and the code that I
showed you works just fine). Additionally, that code can send an email from
outside the intranet if the mail server is accessable to the outside world
(as in most any SMTP mail server). Give that code a test using a valid email
address for the MailServer and let me know if you have any questions at all.
Here's another thought ... you can use the SMTP service without having a
permitted 'MailFrom' account password embedded in the application ... by
making a web service method that accepts the data you want to send, and on
the server the web service does that Sendmail code. Your app now just needs
to hit the web service.
As to what to do if the user isn't connected. If your app detects that it
isn't online or if it's having any difficulty connecting to the web service
you can just save off the data locally and have the app keep checking for
connectivity ... when the connection is available you do the send.
I like automation, and Outlook has a lot of fun things to automate, but if
the real goal is to just send an email and there are possibly differences in
the versions of Outlook that could be installed (or no Outlook at all), then
automating Outlook might not be the most direct path to hitting the goal.
Robert Smith
Kirkland, WA
www.smithvoice.com