Open prasath-pc opened 2 weeks ago
@prasath-pc Thanks for asking about this.
There's a new version of Outlook on Windows that's currently in preview. It seems like you're not using that version but the classic version that's currently generally available to customers.
For this to work in classic Outlook on Windows, you must include a JavaScript override in the Runtime node. That section of your XML manifest should look something like the following:
<Runtimes>
<!-- HTML file including reference to or inline JavaScript event handlers.
This is used by Outlook on the web and on the new Mac UI, and new Outlook on Windows (preview). -->
<Runtime resid="WebViewRuntime.Url">
<!-- JavaScript file containing event handlers. This is used by classic Outlook on Windows. -->
<Override type="javascript" resid="JSRuntime.Url"/>
</Runtime>
</Runtimes>
Your Resources -> Urls section should contain an associated entry which maps to a .js file that contains all your event handling JavaScript. Maybe your taskpane.js is that file?
<!-- Entry needed for classic Outlook on Windows. -->
<bt:Url id="JSRuntime.Url" DefaultValue="https://demo.peppercloud.com/office365app/launchevent.js" />
If you haven't already seen this, you can learn more about this feature in the following articles.
Let us know whether or not this unblocks you.
Thanks.
Hi @ElizabethSamuel-MSFT The issue solved now. Here is my updated manifest.xml file.
But now I am facing issue in Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
})
error: OSF.DDA.Error code: 9018 message: "An internal error has occurred." name: "GenericTokenError status: "failed" value: undefined
Help me to fix this issue
Actually we have to log out email to the CRM. I am using the below code to call the API
function LogMailToCRM(event) {
let item = Office.context.mailbox.item;
item.saveAsync((res)=>{
item.getItemIdAsync((re)=>{
let it = Office.context.mailbox.item;
let itemId = re.value;
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
var accessToken = result.value;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://outlook.office.com/api/v2.0/me/messages/' + itemId + '/?$select=conversationId', true);
xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
var response = JSON.parse(xhr.responseText);
var conversationId = response.ConversationId;
console.log("Conversation ID: ", conversationId);
onEmailSendHook(conversationId, event);
} else {
event.completed({ allowEvent: true });
}
};
xhr.onerror = function() {
console.error("Request failed");
event.completed({ allowEvent: true });
};
xhr.send();
} else {
console.error("Error getting callback token: ", result.error.message);
}
});
});
})
}
Once I get the token from the getCallbackTokenAsync, I have to call the another api https://outlook.office.com/api/v2.0/me/messages/' + itemId + '/?$select=conversationId', true
Help me solve this issue
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
@prasath-pc It looks like you're trying to call the Outlook REST APIs directly. The REST APIs are being deprecated and we're encouraging developers to call Outlook REST APIs through Microsoft Graph. For more about this, you can start with the following articles.
Let us know how this goes for you.
Thanks.
Thanks @ElizabethSamuel-MSFT . I understand that I have to use the graph API.
But why this function gives me an error ?
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) {
})
I will have to send the bearer token while I making calls to the graph APIs right ? If yes then, in my addin, from where I can get the token ?
Help me on this, Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function(result) { })
I am trying the above function, but got the error.
@prasath-pc The example provided with the Mailbox.getCallbackTokenAsync API documentation may be helpful. (You can view and try out that example in Script Lab.) It looks like you're at least missing the conversion of the itemId from the default EWS ID version to REST ID.
The following are a couple of more comprehensive samples (but note the first 2 are archived) that may be helpful.
Thanks @ElizabethSamuel-MSFT , I am getting the token. I have given my updated manifest file. I am using <LaunchEvent Type="OnMessageSend" FunctionName="LogMailToCRM" />
.
This is working fine in web/Outlook dekstop (new). But not working in Outlook desktop (version 2403) that is comes with Microsoft 365 Personal
What could be the issue ? Same manifest files are working fine in web/Outlook dekstop (new)
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Getting the error like this
@prasath-pc In your .js file containing the event handling code, do you have the required associate
statement mapping the LaunchEvent FunctionName in the manifest with the actual function name in the .js file (even if they're the same)?
For examples, see the following samples.
Additionally, see Handle OnMessageSend and OnAppointmentSend events in your Outlook add-in with Smart Alerts.
Thanks.
@ElizabethSamuel-MSFT I have added these associate and the handler functions in the taskpane.html file itself The thing is it is working fine in all other platforms right ?
It is not working on Microsoft 365 Outlook desktop version only
@prasath-pc Unfortunately, the handler code must be in a .js file for the classic Outlook on Windows to consume it. Same goes for the associate statement. These are requirements for classic Outlook on Windows desktop which looks to the Runtime Override .js location for the event handling code.
@prasath-pc Were you able to move the handler code into a .js file?
Hi all,
I am new to OfficeJS, and I just developed an Outlook plugin with an OnSend feature.
I found that the header of the HTTP request in the OnSend function in the classic desktop Outlook seems different from the web version of Outlook. The header sent by classic desktop Outlook is much larger than the web version causing the request to fail. Is there any explanation for the HTTP request header size is different when using classic desktop Outlook and web Outlook?
Hi all,
I am new to OfficeJS, and I just developed an Outlook plugin with an OnSend feature.
I found that the header of the HTTP request in the OnSend function in the classic desktop Outlook seems different from the web version of Outlook. The header sent by classic desktop Outlook is much larger than the web version causing the request to fail. Is there any explanation for the HTTP request header size is different when using classic desktop Outlook and web Outlook?
@DanielHo4 Can you create a new issue for your question? Then we can track it separately and assign as appropriate.
Thanks.
sure, I just wondering this is one of the reason causing bug
I have noticed that it is because of VersionOverrides. I have tested without LaunchEvent extionType, it worked. But It is not working with LaunchEvent in manifest.xml... I have attached my manifest file, please correct the issue here
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>