Come back to home page

Launch Applications, Links and Mails (Process, VB.NET)Download

Have you ever wished to provide a clickable web link in your application? Or have you ever wished to launch a pre-filled email client (like outlook express)? Or have you ever wised to open another application from your .NET program? If yes, this is the tutorial addressing these issues.

What is common in all the three scenarios above?

In all of the cases we are trying to start another process from the current process (our application). This can be done by the Process class provided by .NET framework. To start the process we use the Start method.

... Starting another application ...

To start an application from our code, we can use the Start method. Following piece of code starts calculator:

System.Diagnostics.Process.Start("calc.exe")

If you want to pass any arguments to the application, you may use following syntax:

System.Diagnostics.Process.Start("application name","argument list")

Example:

System.Diagnostics.Process.Start("iexplore","http://www.coder000.com")

The above code will call iexplore with the web link as parameter. Result. The given link will open in Internet Explorer.

... Opening Links ...

We can use the code given above to launch web sites in Internet Explorer. What if we want to open a link in the system's default browser? We can simply use the following technique:

System.Diagnostics.Process.Start("http://www.coder000.com")

... Mails ...

To open the default mail client with specified email, use the following code:

System.Diagnostics.Process.Start("mailto:rv0312003@yahoo.com")

The above code will open a new mail in the default mail client (like Outlook Express) with rv0312003@yahoo.com in 'To' box.

System.Diagnostics.Process.Start("mailto:rv0312003@yahoo.com?subject=Test Subject&body=" & "Hello, how are you?" & "&cc=cc@domain.com;cc2@domain.com&bcc=bcc@domain.com")

The above code will open a new mail with subject, to, cc, bcc, etc. filled.

To know more about mailto, you may check the mailto protocol specification (RFC2368).

Please send your feedback at rahul@coder000.com

Don't forget to come back to http://www.coder000.com