Changing Email sensitivity via Outlook Web Add-ins - outlook

I'm trying to create an Outlook Web Add-in that will alter the sensitivity of the email itself.
Going through the documentation, I see that there is an "AlterSensitivity" method that is available on the Office.context.mailbox.item object, but I cannot figure out how to make it work.
Basically, I just want the user to click the toggle button which will change the sensitivity from confidential to normal, or normal to confidential. I know I'm not really posting any code, but I'm not sure what value that would provide.
Here is a pseudo-code mock-up:
User Clicks button
code checks message sensitivity
if sensitivity is normal, change to confidential and toggle the button to be pressed
If sensitivity is confidential, change to normal, and toggle the button to not be pressed.
Hopefully that makes sense, thanks for all your help!

There is no API that exists today in the Web Add-in model to change the sensitivity of an item. AlterSensitivity is not an API we support. In order to change the sensitivity of an item, you would need to use EWS or REST.

Related

Add information message when reading email

I would like to display an information message for the user when he read a specific email (i.e the email is tagged as external). The message should be displayed in the same way as outlook categories.
I know that I can use Exchange transport rule to achieve that but my client don't want to modify the message itself. He prefers displaying a message in the UI without changing the email body. The other option is to use the Office.context.mailbox.item.notificationMessages interface but as I told, I don't want to modify the email item if possible.
Do you think it is doable with outlook JS addins ?
My need is similar to this one for VSTO addin: How can my Outlook VSTO Add-in modify the read email form?
The Office.context.mailbox.item.notificationMessages interface provides the addAsync method which accepts the JSONMessage parameter which represents a JSON object that contains the notification message to be added to the item. It contains a NotificationMessageDetails object. Among properties you can find the persistent property which specifies if the message should be persistent. Only applicable when type is InformationalMessage. If true, the message remains until removed by this add-in or dismissed by the user. If false, it is removed when the user navigates to a different item. For error notifications, the message persists until the user sees it once. Specifying this parameter for an unsupported type throws an exception.
In case of categories, the message will be modified.
Do you know if it's possible to execute the function as soon as the read form is opened without having to click on an action button ?
Web add-ins are run under the context of currently selected item only. You can pin a task pane, then you'll be able to register an event handler to get notified of the change. The event handler should accept a single parameter, which is an object literal. The type property of this object will be set to Office.EventType.ItemChanged. When the event is called, the Office.context.mailbox.item object is already updated to reflect the currently selected item.
Office.initialize = function (reason) {
$(document).ready(function () {
// Set up ItemChanged event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, itemChanged);
});
};
function itemChanged(eventArgs) {
// Update on the new current item
}
Currently the event-based activation of add-in in Read mode is not supported. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered when we go through our planning process.
Currently, Event-based of activation of add-ins is only supported for Compose mode. You can explore more here- Configure your Outlook add-in for event-based activation - Office Add-ins | Microsoft Docs

OfficeJS: listen for an email selection

I am looking for a way to add a notification banner when the user selects an email in Outlook.
I've written a basic task pane OfficeJS admin but this requires the user to click an add-on button and keep the taskpane visible.
Is there a way to listen for such an event without requiring user (admin) interaction?
Thanks!
There is no way to get a task pane visible automatically for a selected item.
You can vote for such feature or suggest a new one at http://aka.ms/M365dev-suggestions.
Currently the feature of event based activation of add-ins in read mode is not a part of the product. Please check answer on similar post for more details.

Outlook Addin - Wait for a response

I have an Outlook Addin that creates a contact on a webpage by making an API call to that webpage. When the Addin runs (via the click of a button), the API call is made and the user is taken to that webpage to fill in the contact information. After the user has filled in the information and clicks on submit, I would like to catch that event in Outlook and get the user back to Outlook to carry out further actions. Any possible ways of getting this done? I've been looking online but haven't found any solution as such.
Try to display the web page in a modal dialog in your own form. When the form is closed, you can take whatever action is necessary.
You may find the ItemSend event of the Application class helpful. It is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program.
Also you may consider repurposing ribbon controls. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.

Track button views and clicks as events in google analytics

I am trying to place a button that will be inside email and I want to track button views and clicks (Google Analytics events). Can you tell me if that is possible and how to do that?
You can't technically track a button click from an email, but what you can do is control where the button links to.
If you set the button's URL to point to your servers, you can intercept the link, send a hit to Google Analytics using the Measurement Protocol, and then redirect the user to where the button was originally pointing.
Alternatively, you could append custom campaign parameters to the end of the URL (utm_medium, utm_source, etc.). This would allow you to know what source the hit came from. Here's some information on custom campaigns:https://support.google.com/analytics/answer/1033863?hl=en
This is able to track button views by using Measurement protocol, and using UTM tagging to track sessions come from this button (but not actual clicks).

How do I set the default sending email account in mail.app using AppleScript?

I'd like to use Control Plane to change the default sending account in mail.app (preferences->composing->send new messages from) when I switch from a work to a home environment. Control Plane doesn't have an option to do this, and I can't find anything in the mail.app AppleScript dictionary that might work … except, perhaps, "default email account", but that is r/o. Any ideas on ways to do this? I know I can do this message by message, but I want to change the default.
To set the default sending address, you can change the value of the Send new messages from: dropdown list in the Mail.app preferences window under the 'Composing' tab.
If you want to use AppleScript to change the sender once you're composing a message, that can be done using AppleScript as described in this question and answer.
In the Composing tab, you can choose to send new messages from the account of the selected mail box. You'll find out that this is sufficient in most cases. There is no way to automate this with AS afaik, except perhaps with GUI scripting.
(I agree that this question doesn't really belong on Stackoverflow).

Resources