2

I'm currently working on an internal project that uses AngularJS on the frontend and queries a C# Web API for data on the backend. Using this setup, I can get most functionality that I'm looking for, but I'd like to add a feature that I believe requires C#, and it isn't really an API call:

When a user clicks a button, I'd like to pop up a new Outlook message with pre-populated recipient and subject fields. I'd also like to be able to pre-include attachments.

I've done this before in C# following steps similar to these, but I'm new to AngularJS and the SPA architecture. Is there a way to implement this feature? Where does the C# code go in the solution, and how do I connect it to the Angular?

Since this is an internal non-customer-facing app, you can assume that all users will have Outlook installed.

4
  • Does a mailto link work? I think that's typically how those are implemented. Commented Dec 20, 2016 at 17:56
  • @BradleyDotNET I think that will work for simple emails, but in the future, we may want to have attachments added as well. I'll add that part to the question. Commented Dec 20, 2016 at 18:01
  • The real trick is that any C# code will run on the server and so cannot just interact with an instance of Outlook (this is true for any web application, not just Angular). What you are asking for may not be possible. Commented Dec 20, 2016 at 18:03
  • @BradleyDotNET Hmm, now that I think about it, the previous time I did something like this it was in a desktop application, not a web application. We might just have to scrap the feature. I'll leave the question up just in case anyone can suggest an alternative solution. Commented Dec 20, 2016 at 18:06

2 Answers 2

3

Given that native code executes on the server in a web application (not just angular), I don't believe that doing what you are asking is directly possible.

Web applications are heavily sandboxed, directly interacting with a native application is intentionally very difficult. For basic applications I would use mailto links as they will open in the users default mail application (presumably Outlook).

If that isn't enough, consider having a form on your page that can be submitted to the server and then send the email on their behalf.

Sign up to request clarification or add additional context in comments.

Comments

0

Inspired by BradleyDotNET's answer, I've decided to go to with a mailto link, which will allow me to fill the subject and recipient fields. But to handle attachments, I found the suggestion here to host the attachments on the site and just put a link to a download in the body of the mailto. For PDFs, I can create a view with the PDF embedded.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.