Yoyodin
Yoyodin

Reputation: 1

ASP.NET How can I open user's Outlook from a web app?

I'm currently working on a web application using C#. In the original application, one of the functionalities is to open Outlook and create a draft with an attached file to it -it was a desktop app-. Now, they want the same function in the new web application.

So that's my question. I've been reading and as far as I've seen it's not possible to do it from the server, but maybe I missed something?

And, if it's not possible, what would be the best alternative for this?

Thank you very much!

Upvotes: 0

Views: 3140

Answers (3)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66286

You can either

  1. use mailto protocol on the client side

  2. If your user is using IE (other browsers do not support COM) and your app is trusted, you can create an instance of the Outlook.Application COM object and create a new message programmatically in your Java script.

Upvotes: 0

Jaguir
Jaguir

Reputation: 3690

There isn't a way to do this directly from a web app. The closest you are going to get is the mailto link protocol. That will allow you to specify the recipient, subject, and a text body. No attachment though. And there is no guarantee that Outlook is what will handle the link.

That being said, if you have control of the client computers, it is possible to create a client app that registers its own protocol for you to use instead of mailto. This would allow you to control Outlook in the same was as your original application. Here is a related question that explains this approach: how do I create my own URL protocol? (e.g. so://...)

Upvotes: 0

ChrisG
ChrisG

Reputation: 1403

This is actually possible, as long as you are using Exchange, and own the user's mailbox/can pass their credentials.

The EWS Managed API will let you create an email message and save a draft with attachments, so that shouldn't be a problem. See EWS Managed API - Save Draft with inline Images.

If you're not using exchange/can't get that level of permission, you might have to come up with a different solution. Perhaps saving the draft as a .eml file? How to save MailMessage object to disk as *.eml or *.msg file.

Upvotes: 1

Related Questions