Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a mailto link in windows forms application

I want to know how to create something similar to a mailto: link (like on HTML pages) to a Windows Form. So that on clicking it, the users default mail program should open a new blank email with the given email address in the To: field.

like image 251
gary Avatar asked Jan 08 '10 20:01

gary


People also ask

How do I create a mailto link in HTML?

You can create an HTML mailto link by using an anchor tag with the href attribute and inserting the “mailto” parameter after it. If you want to send an email to more than one address, separate your email address with a comma.

How do I add a subject to a mailto link?

If you want to add a subject to that e-mail add ? subject=<subject> to the mailto tag. For example, the complete tag would look similar to the example below. You can also add body text by adding &body=body to the end of the tag, as shown in the example below.


1 Answers

If this is a .NET application then you can use a LinkLabel control. Just set the text property to the actual email address and then respond to the LinkClicked event handler like this:

System.Diagnostics.Process.Start("mailto:" & LinkLabel1.Text);

You'll want to do some sanity checking on the email address and add some error trapping, but that should do the trick.

like image 166
BenR Avatar answered Sep 21 '22 16:09

BenR