0

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!

Yoyodin
  • 1
  • 1
  • 1
  • Outlook 2010, or 2013? – Ryan Mann Oct 15 '14 at 14:46
  • 3
    You can use simple link to open outlook as ```mail ``` – ArthurCPPCLI Oct 15 '14 at 14:49
  • 1
    Without developing a browser extension for chrome or firefox etc, or requiring the user to download and run an Exe, this is not possible. – Ryan Mann Oct 15 '14 at 14:56
  • 1
    You can however, send email from the web server. So you could forgo the use of outlook entirely and design a set of forms to represent the email drafts. Then send the emails out from the web server with their from address eet to the right person. – Ryan Mann Oct 15 '14 at 14:57
  • @Ryios that was my first approach, but no, they want Outlook and have the chance to see if the person received and read the email. It's Outlook 2010, by the way. – Yoyodin Oct 15 '14 at 15:06
  • Btw, if your not using exchange with outlook 2010 what are you using, are you connecting to a pop3 service to gmail, live, hotmail etc etc? Are you guys using your own email server via pop3 etc? Basically, what is outlook connecting to and are all the concerned users using outlook and the same email server? If so we can look at an api to talk to the email server. – Ryan Mann Oct 23 '14 at 02:18

3 Answers3

1

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.

Community
  • 1
  • 1
ChrisG
  • 1,403
  • 13
  • 22
  • 1
    It's also possible with outlook online / office 365, just switch to using the web app instead of client side outlook. – Ryan Mann Oct 15 '14 at 14:58
  • 1
    And it's possible with a custom socket tcp/ip protocol, but would require having the clients download an exe that runs in their system tray (like many vpn services do). E.g. the exe connects to a tcp/ip socket server running on the web app server and the web app notifies the socket server to notify the connected client to open outlook and make the draft. – Ryan Mann Oct 15 '14 at 14:59
  • I hadn't considered sending a direct email. It is a viable option, though the OP did specify using the local client Outlook. He may be limited to the version of Outlook. – Jaguir Oct 15 '14 at 15:07
  • I'm not saying direct mail, although now that I think of it, that's a good idea, and really easy. You could just send it to them and let them "reply" to whoever it needs to go to. The EWS solution would actually let them save directly to the drafts folder through exchange, and it would show up in outlook, or any other client that was used. The only problem is that it has to be exchange. – ChrisG Oct 15 '14 at 15:26
  • We don't use Exchange, so I will look into the *.eml or *.msg file solution. Thank you. – Yoyodin Oct 15 '14 at 16:32
0

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://...)

Community
  • 1
  • 1
Jaguir
  • 3,620
  • 1
  • 19
  • 26
0

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.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78