.NET equivalent of html 'mailto ?

  • Thread starter Thread starter Bill Woodruff
  • Start date Start date
B

Bill Woodruff

I have a small light-weight winform app (C# .NET 2.0) that does some
web-scraping and, under certain conditions, needs to send a plain-text
e-mail.

This is simple for mail servers that don't require authentication, but my
own mail server (GoDaddy) does, and I want it to work with such servers.

What I want is for the application to invoke the default mail handler on the
user's machine exactly as using the 'mailto facility in HTML will.

And I don't want to have to build in username/password entry fields that
will add a real security burden.

I've looked at all the smtpmail and mailmessage code on CodeProject, hunted
through the MS newsgroups, and I am assuming right now this cannot be done
for security reasons.

But I wonder if some kind of "hack" like putting a WebBrowser control in and
trying to use 'mailto on a composed link in its hidden HTML might work.

Outlook automation would be another avenue of approach, but I'd like to stay
away from being locked into that application being present.

Appreciate any suggestions !

Bill
 
I should have noted that the solution I am looking for is not exactly like
invoking 'mailto from HTML.

You can, indeed, easily invoke 'mailto on a linklabel in .NET by using

// mailToURL : string in typical mailto HTML format
System.Diagnostics.Process.Start(mailToURL);

And this will fire up your default mail client with a structured message.

But it won't send the message which means unattended use is out.

I need something that will send the message from the default e-mail client,
as well as invoking it.

thanks, Bill
 
Bill,
unfortunately, this is not as easy as it may seem, since some machines may
have Outlook, and others only Outlook Express, which does not expose a
programmable COM interface.
Your best bet is to use the System.Net.Mail namespace.
Peter
 
You can always use launch the default mail client via the registry -
the MAPI setting is stored in the registry:

HKCU\SOFTWARE\Clients\Mail\

Holds all the mail clients

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\mailto\shell\open\command

holds the default client in the (Default) key
 
Back
Top