Outlook

Striver

Member
Joined
Feb 7, 2006
Messages
5
Programming Experience
3-5
Hi! Im new here, and since i could not figure out where to post this question, im posting it here.


When cliking a E-Mail on a web browser, Outlook starts. The web browser also sends the E-mail of the intended person to outlook.

I have been tasked with doing a .exe, and to name it Outlook.exe, so that my .exe will start, instead of oulook, when a e-mail is clicked on the web broweser.

So far, no problems. Here is my problem:

I want my .exe to receive the e-mail address of the intended person, in the same way that outlook receives it. Any idea of how i can accomplish this?
 
You are not going to "fool" the browser into using your application just because it's named Outlook. What happens is that the browser just tells the OS to load up your default e-mail client. For many people that's Outlook, but by no means for all. Also, the path to the default e-mail client is stored in the registry. It doesn't just look for an executable named Outlook. You can create an application and add some information to the registry to have it registered as an e-mail client, and even the default e-mail client if you want, but it has to be done the proper way. Note that a .NET application can simulate clicking an e-mail address in a Web page like this:
VB.NET:
Process.Start("mailto:joe.bloggs@somewhere.com")
This will also load up the default e-mail client with a new message addressed to "joe.bloggs@somewhere.com". As far as the OS is concerned it is exactly the same as if it was clicked in a browser.
 
Thank you very much for your quick reply!

That was new information for me, regarding default e-mail clients. I am totaly new to that. I need to know:
1) How do i creat a .exe that "qualifies" as a e-mail client
2) How do i register it as 'a' e-mail client in the registry
3) How do i register it as the default e-mail client?

Thank you also for informing me about how to simulate clicking an e-mail address in a Web page, even though im not sure if it will come in handy right now :)

Also, for my main question, i still dont get how to have my .exe to receive the intended e-mail address. Is that something that the web broweser gives to the registry that in turn gives to the default e-mail client? In that case, how do i creat a .exe that qualifies as a default e-mail clien, and most importantly, receives the e-mail address?

Your help is greatly appreciated!
 
I remember reading something on MSDN about how and where e-mail clients are identified in the registry. I'm afraid I don't have a link and I don't remember exactly where it was. I can only suggest a little judicious searching. As for how your app receives the e-mail address, I would guess that it would be like when double-clicking a file in Windows Explorer. In that case the default application receives the file path as a commandline argument. My guess is that the same thing happens with e-mail addresses. The default e-mail client would receive it as a commandline argument. Note that mailto URLs can include more information then just the destination address, so you would have to be able to handle all possibilites. I suggest that you Google for the specification of the mailto URL.
 
Hi again!

I went to the registry, via "regedit", then to

HKEY_LOCAL_MACHINE/SOFTWARE/Classes/mailto/shell/open/command

I then changed the path to Outlook to the path of notepad.exe

when i then tried to clik on a e-mail (arbetsformedlingen-kundtjanst@ams.amv.se) on my webbrowser, notepad started, and gave me the following error message:

(Message was in my native language, ill give a aproximate english translation)

"Can't find file /mailurl:mailto:arbestförmedlingen-kundtjanst@ams.amv.se.

Do you want to creat a new file?

[yes] [No] [Cancel]"

It seems as it starts notepad with a commandline it does not understand.

So i guess that i need to creat a application that can handle the commandline. Thing is, i have never created a application that can handle a commandline of any sort. So, how do i do that?
 
When you clicked the email it opened notepad as you wanted it to, however it was looking for a "To:" box to place the email address in, as notepad does not have this i guess thats why it has thrown that error, you would have to make an app that has a "to:" textbox with the same name/identifier as email clients. But like someone mentioned earlier don't forget "mailto:" can also contain "Subject:" and "Body:"
 
It was not looking for a "To:" box !

The default email client have one parameter in registry which is "%1", this means the default application is supposed to read the first string from it's commandline arguments. The default behaviour of Notepad is to interpret this parameter as a filename, try to open the file and read it's contents into the editor textbox.

A default email application is initially supposed to do the same thing, read the first argument of it's commandline. This argument must be parsed by the email client and put into appropriate fields of a new mail message dialog.

The specifications of this single string argument is defined by the MailTo Protocol and can be read here: http://support.microsoft.com/kb/q188019/
This string will read exactly the same as coded into an mailto:Url when received by the email client via the MailTo protocol.

There are tools in the .Net Framework to UrlDecode the internet safe charachters: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpserverutilityclassurldecodetopic.asp
 
Back
Top