Search code examples
javascriptoutlookoutlook-api

Control Outlook Programmatically from a Client-side JS Script


At the click of an HTML button, I want Outlook to open on the client (given that it is installed of course).

More specifically, the New Email dialog should open.

Now the tricky part: I should be able to prefill fields like To, CC, Subject, Body and especially be able to pass PDF files to be attached to the email.

I looked into using mailto links but that does not seem to be viable for attachments.

EDIT: I'm basically wondering if there is any APIs between browser and Outlook other than the traditional mailto?

Just to give you some background: this is for an internal web application - not web accessible.


Solution

  • That just isn't how the web works. Unless mailto links support attachments, it's not possible (which I'm 99% sure it doesn't support attachments). So it's basically not possible.

    You could always have a back end system that sends the email using MailGun or something like that. But it won't be using Outlook or from the users email address.

    At the end of the day you are relying on browsers and Outlook to have APIs that interface with each other, and those just don't exist beyond the mailto which you mentioned in your question.