0

I have an asp.net mvc4 application, in which I have this view:

<form action ="\Home\Index" method="post" >
    <input type="submit" name="mail" value="launch mail" />
</form>

and in the controller:

public ActionResult Index()
{
    return View();
}

I'd like to launch the default mailing software on the pc (i.e outlook, thunderbird, etc.) when I click the submit button.

So how can I modify the action in the controller to automatically launch the mailing software?

Lamloumi Afif
  • 8,941
  • 26
  • 98
  • 191

1 Answers1

4

There's no reliable way to force the launching of any program on a client machine. Imagine: that would be a huge security risk if webpages could just force the running of applications.

You can use mailto, which is basically a shortcut that tells the host PC "hey, launch your e-mail application and put this info in an e-mail; BUT the behavior once it reaches the host PC isn't always consistent.

To put a simple mailto link into your razor syntax:

<a href="mailto:support@YourDomain.com">E-mail support</a>

Or if you wanted to get fancy, if your model has an e-mail address:

<a href="mailto:@Model.EmailAddress">@Model.EmailAddress</a>
User
  • 1,118
  • 7
  • 23