I'm creating an Outlook Add-in that will take the recipients and check to see if they exists in our database.
When the user clicks on a mailto link on a page it will pop up the Outlook compose window and the recipient will be populated
as such.
Running the Add-in will lead to a nothing being returned from the Office.context.mailbox.item.to.getAsync function.
Office.initialize = function () {
$(document).ready(function () {
Office.context.mailbox.item.to.getAsync(getRecipientFromDB);
});
};
However, the recipient will now look like this:
Retrying the Add-in will now work because the Office.context.mailbox.item.to.getAsync function will actually return a result.
My Outlook version is 16.0.11029.20045.
Has anyone ran into this issue before?
to.getAsync will return every resolved recipient in the "to" field. In the first screenshot, test#test.com is not resolved, so to.getAsync will not return anything. If you open the compose window, wait until recipients resolve, and then run the add-in, to.getAsync will return a result.
Related
I have an add-in that opens a dialog box using Office.context.ui.displayDialogAsync() with displayInIframe: true
I compose an email and open the add-in. Using the add-in I select the files I wish to attach to the email. On the desktop Outlook app this works perfectly.
On the web version nothing happens. I can't see any communication between the dialog and host page when using Office.context.ui.messageParent() or Office.Dialog.messageChild()
The frontend in the dialog sends a message with the file blob to the parent function in the functionfile. The functionfile should then call addFileAttachmentFromBase64Async() when it receives this message but on the web version I can't see any evidence of this.
I've read it could be to the urls in the in the manifest.xml. Here is ours:
<AppDomains>
<AppDomain>https://outlook.office.com</AppDomain>
<AppDomain>https://outlook.live.com</AppDomain>
<AppDomain>https://localhost:44312</AppDomain>
<AppDomain>https://*.{company}.cloud</AppDomain>
<AppDomain>https://localhost:3001</AppDomain>
</AppDomains>
And here is the simplified section of code that opens the dialog:
Office.context.ui.displayDialogAsync(url, { height: 60, width: 60, displayInIframe: true }, asyncResult => {
if (handleError(asyncResult)) return;
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
const promises = [];
{working business logic}
Promise.all(promises).then(values => {
{working business logic}
event.completed();
});
});
Other issues we have in the web version that might be releavent:
The 'X' close button in the top right of the dialog box does not work. Neither will calls to Office.context.ui.closeContainer() or Office.Dialog.close()
If we set displayInIframe: false then the add-in will immediately close itself upon opening unless we throttle our internet connect. But even when throttling the attaching email process does not work. If I remove the <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" crossorigin></script> script in the .html then it no longer crashes (but naturally the app needs that)
I have tested this on both Edge and Chrome and they both have this issue. I have not tested on any other browsers
Again, the app works correctly and as expected on the Outlook desktop app. Any help or suggests are appreciated. Thanks.
Just remove the event.completed() call from the callback.
I want to program a simple Outlook add-in that opens a browser and take the user to a specific site.
I've had a look at using Yeoman, but this add-in opens a task pane where I'm just looking to take that single actions.
Is there a simple way to do this?
EDIT:
I managed to get this done, but I not have the following issue: I have a single button (via Yeoman's generator) that when clicked executes the following:
function action(event) {
const message = {
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Window opened.",
icon: "Icon.80x80",
persistent: true,
};
// Show a notification message
window.open("https://myurl.com");
Office.context.mailbox.item.notificationMessages.replaceAsync("action", message);
// Be sure to indicate when the add-in command function is complete
event.completed();
}
I get the following error in Outlook itself:
We deployed the app using the MS 365 admin center, but I'm not sure if there is something additional that I need to do in this case to run the webserver?
There is an Office.js API that will open a browser window:
Office.ui.openBrowserWindow( -- URL string here -- );
This will cause the computers default browser to open to the specified URL. You could have a button in the task pane whose handlers calls this method. Alternatively, you could have a custom button on the ribbon that calls a FunctionFile that calls this method.
If you want to display any web site to the user as a result of the button click or some action on the pane, try doing window.open('https://yoursite.com'). This should work if the domain is whitelisted in your manifest. For example:
function redirectFunction() {
window.open("https://othersite.com")
//window.location.href = "https://othersite.com";
}
We are currently using MAPI to load contact information into a form.
Within a MapiSession we are creating a RDOAddressEntry "recepient" with this bit of code
using (MapiSession session = new MapiSession())
{
//open outlook contact dialog
RDOAddressEntry recipient = session.GetAddressEntryFromID(contact.EntryId);
if (recipient.Type == null)
{
throw new ArgumentException("type not defined");
}
recipient.Details(handle.ToInt32());
}
Our problem seems to be that the dialog that opens with the last line of code creates two different dialogs. One for exchange contacts and another one for SMTP contacts.
In the last version of our application it was always opening the same dialog for both RDOAddressEntry-types and we did NOT change anything in our code...
Can you help me fix this issue so that both SMTP and exchange will bring the same dialogs again?
I am not sure why you were getting the same dialog for both before - the dialog is actually provided by the particular address book provider, so it will be different for the entries from different providers.
Hi I am building an outlook addin, I want to know if there is way to handle the ItemChange event, I know we can use it by pinning the taskpane, isn’t there any other way??
Currently ItemChanged event can only be used in case of pinned add-in. 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.
You need to use the addHandlerAsync(eventType, handler, [options], [callback]) method to subscribe to the ItemChange event. Here is what MSDN states:
Currently the only supported event type is Office.EventType.ItemChanged, which is invoked when the user selects a new item. This event is used by add-ins that implement a pinnable task pane, and allows the add-in to refresh the task pane UI based on the currently selected item.
Office.initialize = function (reason) {
$(document).ready(function () {
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, loadNewItem, function (result) {
if (result.status === Office.AsyncResultStatus.Failed) {
// Handle error.
}
});
});
};
function loadNewItem(eventArgs) {
// Load the properties of the newly selected item.
loadProps(Office.context.mailbox.item);
};
Also, you may find the following discussion helpful - Outlook Add-In API does not fire the ItemChange event consistently on Firefox/Chrome. ItemChange fires when the item actually changes, but not when you simply change the selection.
I want to make a async request to my server every time a user of my plugin starts outlook (or at least before they open an email).
I have a web Add In with a function file. This file is called whenever a user press a button for this addin. The function file is only loaded after a button (of my plugin) press.
Try this:
// This function is called when Office.js is ready to start your Add-in
Office.initialize = function ()
{
$(document).ready(function ()
{
//call your function here
This is not possible with WebAddIns as the Outlook Add-Ins Teams said in the comments under the question.
One solution is to create a VSTO AddIn and make the request there.