I am new to Outlook add-in development. I want to automate a simple process; selecting an e-mail and clicking on a button "Forward" inside my add-in which makes the e-mail enter Forward mode (replicating the functionality of the Forward button in Outlook) and adding a recipient that I specify in my code. The desired function should look like this, but of course this is not working:
export async function forwardMail(){
var item = Office.context.mailbox.item; //=the email
item.Forward();
item.addRecipient("my-email-address#outlook.com");
}
And like mentioned, this function should simply enter the Forward mode in the Outlook application and add my recipient.
Office web add-ins are working under the current item in Outlook only:
I want to automate a simple process; selecting an e-mail and clicking on a button "Forward" inside my add-in which makes the e-mail enter Forward mode
You can do the required modifications using OfficeJS or EWS, Outlook REST API or MS Graph API. For example, once you have a token and the message's id, you call into Microsoft Graph /forward endpoint:
POST https://graph.microsoft.com/v1.0/me/messages/{id}/forward
Content-type: application/json
{
"comment": "",
"toRecipients": [
{
"emailAddress": {
"name": "recipient-name",
"address": "recipient-email"
}
}
]
}
Related
We have a client that requires that an action take place when sending emails with certain Microsoft Information Protection/Azure Information Protection (MSIP/AIP) labels. We have a desktop Outlook add-in that does this perfectly.
Now however the client is requesting this same add-in but using the new modern style Outlook add-ins. We have created an on-send add-in to accomplish this, but we cannot get access to any internet headers in an Office.ComposeMessage. In fact, we cannot get any headers to be returned.
Here is our code:
async function fetchInternetHeaders(mailItem: Office.MessageCompose,
tags: string[]): Promise<string[]> {
return new Promise(function(resolve, reject) {
try {
let myTags: string[] = [
"msip_labels", // This is the value we need
"x-ms-has-attach", // This is for testing
"PR_SUBJECT_W", // This is for testing
"http://schemas.microsoft.com/mapi/proptag/0x0037001F", // test
"http://schemas.microsoft.com/mapi/proptag/0x5D07001F", // test
"http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/msip_labels/0x0000001F", // Another way to get msip_labels
];
mailItem.internetHeaders.getAsync(myTags, function(asyncResult) {
if (asyncResult.status === Office.AsyncResultStatus.Succeeded) {
debug.Log("onSend.fetchInternetHeaders", "Selected headers: " + JSON.stringify(asyncResult.value));
} else {
debug.Log(
"onSend.fetchInternetHeaders",
"Error getting selected headers: " + JSON.stringify(asyncResult.error)
);
}
resolve(["FetchedInternetHeaders"]);
});
} catch (error) {
debug.Log("onSend.fetchInternetHeaders", "Error occurred", error);
reject(error);
}
});
Note: We ignored the parameter "tags" to make everything as simple as possible.
The call succeeds but the returned array is always empty, even for simple properties like the email Subject. What are we doing wrong?
Both COM add-ins and Web add-ins don't provide any internet headers until the message is sent out. You may expect the internet headers set when the message is put to the Sent Items folder, but before that they are not created and stamped by the service/transport provider.
Most probably you need to access user properties, see the UserProperties object in the Outlook object model. But the Office JavaScript API (OfficeJS) doesn't provide anything for that out of the box, you need to use EWS or Graph API to access such properties from web add-ins.
You can specify data specific to an item in the user's mailbox using the CustomProperties object. For example, your mail add-in could categorize certain messages and note the category using a custom property messageCategory. Or, if your mail add-in creates appointments from meeting suggestions in a message, you can use a custom property to track each of these appointments. This ensures that if the user opens the message again, your mail add-in doesn't offer to create the appointment a second time.
Be aware, changes to custom properties are stored on in-memory copies of the properties for the current Outlook session. To make sure these custom properties will be available in the next session, use CustomProperties.saveAsync.
These add-in-specific, item-specific custom properties can only be accessed by using the CustomProperties object. Like I wrote earlier, these properties are different from the custom, MAPI-based UserProperties in the Outlook object model, and extended properties in Exchange Web Services (EWS). You cannot directly access CustomProperties by using the Outlook object model, EWS, or REST. To learn how to access CustomProperties using EWS or REST, see the section Get custom properties using EWS or REST.
You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .
I am working on an adaptive card that is posted to users in Teams using Power Automate. The final thing I would like to add to the adaptive card, is a action button, that the user can click to call a person.
I have tried using both tel and sip in the URL. However nothing happens when the button is clicked.
Is this a limitation of Teams - or am I just doing it wrong?
"actions": [
{
"type": "Action.OpenUrl",
"title": "Call Matt",
"url": "tel:+4599999999",
"id": "callMeId"
}
]
Adaptive Card Designer
BR,
Niels
You need to set the Microsoft Teams as default Apps for Tel Protocol.
You can try putting following in browser: +46890510
it will navigate you to the Microsoft Teams
it will open one pop up for Teams asking to call or not
While using Slack's block kit builder, I created a message that would send a notification as well as a link for the user to click on. I like the way the default button looks, but I get a warning whenever I click it saying my app isn't configured for interactivity.
The link does work, but the warning icon is unsettling. Is there a way to use these buttons without expecting interactivity? The alternative seems to be to just use a markdown link, but I don't think it looks as nice.
My block:
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello here's a notification"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://google.com|View Conversation>"
}
}
]
}
If I send this block straight from the block kit builder there's no warning message. I'm guessing this is because it gets sent as my user as opposed to an app.
As of now, there is no way to set up a block kit button without interactivity. i.e., when someone clicks on the button (with or without a URL), Slack sends a request to the preconfigured URL in your app config. The app needs to acknowledge this request and send an HTTP 200 OK response, in order for the button URL to work without the error sign.
You can read a rather detailed discussion on Slack's GitHub here.
A workaround, for now, would be to set up a webhook URL somewhere on the web (google cloud run could be a good free solution) which returns an acknowledge response. You can then alter your app's config to use this URL for app interactivity.
p.s. When you use block kit builder to send a preview message to Slack, it uses the same user token as the one used by Slack web app. The behavior you noted above can't be replicated when you use any other user token (received from an app's install flow).
I'm working on an Outlook Add-in, using office.js, where users can send secure emails using backend service.
In compose mode, when the user sends the email, using the add-in of course, the add-in will then move the message to "Sent Items" folder using the Outlook API /message/{id}/move and everything goes OK with the exception that the message in question still being marked as "Draft" by Outlook which is really annoying and does confuse the user who just sent the email by telling him that "this message hasn't been sent"
I searched through the API to see if there is a way to mark an email as "SENT" in order to prevent Outlook from showing this RED hint but with no luck so far!
So, My Question Is: Is there any way to overcome this misleading msg by marking the email as it was sent by Outlook?
Thanks in advance.
Finally, I was able to achieve a perfect solution for this challenge.
Based on:
#BrianClink's comment
This answer (Which uses Graph API but Outlook REST API): Microsoft Graph API mail office 365: Is any option create inbox message NOT as Draft?
The approach/steps I followed to mark a mailItem as "SENT" (and not shown as 'draft') and put it in "SentItems" Folder are as follow:
First, Save the mailItem as "draft" using Office.context.mailbox.item.currentMail.saveAsync then retrieve its ID
Clone this draft mailItem properties eg: 'Sender', 'Subject', 'Body', 'ToRecipients'..etc so you get an exact copy of it.
With the newly cloned mailItem, add '[SingleValueExtendedProperties]' property with this value :
[
{
PropertyId: 'Integer 0x0E07',
Value: '1'
}
];
Serialize the new item as JSON and POST it to "sentitems" folder as follows:
xhr.open('POST', restHost + '/v2.0/me/MailFolders/sentitems/messages/');
xhr.send(clonedEmailJson);
On success, with xhr.status=201 [created], Remove the draft mailitem using a [DELETE] request
And you will end up having a new mail item created in your "sentItems" folder which appears as it was sent by Outlook :)
This was a very helpful solution to me because my users are using my add-in to send secure emails (using 3rd party API) and NOT Outlook, So, I wanted them to have the same UX/feeling as when they use Outlook.
Note:
Although the solution worked for me perfectly, it came with a price!
On slow internet connections or in case emails containing large attachments, the process can be remarkably slow, because the addin will first save the draft to the remote Exchange Server, get its ID, then duplicate it and send it again to the server, then remove the draft-ed one.
I'm trying to develop an add-in using Office 365 Javascript API for Outlook. I'm using Microsoft's reference to look for methods that will allow me to forward the currently opened email when I click a button. The issue is that there's not a single method on the reference that can do that, how can I forward an email using Office JS API?
I imagine it should be something like that:
var item = Office.context.mailbox.item; # item represents the currently opened email
item.Forward(email)
There isn't a method for forwarding the current email included in Office.js.
One alternative solution would be to use Microsoft Graph for this. You'll need to register an Application ID using the steps outlined in Authenticate a user with an single-sign-on token in an Outlook add-in.
Once you have a token and the message's id, you call into Microsoft Graph /forward endpoint:
POST https://graph.microsoft.com/v1.0/me/messages/{id}/forward
Content-type: application/json
{
"comment": "",
"toRecipients": [
{
"emailAddress": {
"name": "recipient-name",
"address": "recipient-email"
}
}
]
}
Currently the feature you requested is not part of the product.
However, we track Outlook add-in feature requests on our user-voice page. Please add your request there.
Feature requests on user-voice are considered when we go through our planning process.
[Outlook Add-ins Engineering Team]