Topics

Launch applications, links and mails from vb net

This discussion uses System.Diagnostics.Process.Start method for functionality like providing a click-able web link, launching an email client (like outlook, mailto links), or launching another application from vb.net code.

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:

download

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://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 code:

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:email@host.com")

The above code will open a new mail in the default mail client (like Outlook Express) with email@host.com in ‘To’ box.

System.Diagnostics.Process.Start("mailto:email@host.com?subject=Test Subject&body=" & "Hello, how are you?" & "&cc=ccemail@host.com;ccemail2@host.com&bcc=bccemail@host.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).

  • Share/Bookmark

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>