Fcstfan
Fcstfan

Reputation: 23

How to select text in an Outlook mail using the office.js API

I am implementing a Webapp that helps users to find alternatives for specific words.

One way people can access this data should be via Office AddIns (using Office.js) that select critical words on button press, let the users choose an alternative (provided by the API of my Webapp), and replaces the content within the selection upon a second button press. Think of it as a custom spell checker/ mini Grammarly for a specific purpose.

So the first thing is, I need to select a certain text area/range within the document/mail (bacically simulating Ctrl-F). Sadly I haven't found this specific API-call within the documentation for Outlook AddIns. Only Body.getAsync and Body.setAsync but if possible at all, I don't want to replace the whole text.

FYI: The same is easily doable for MS Word via :

      Word.run(function (context) {
        const ranges = context.document.body.search('office.js is stupid')
        const range = ranges.getFirst()
        range.select() 
        const alternative = 'office.js is awesome' //Faked user interaction
        range.insertHtml(alternative, 'Replace')
        })

What would be the equivalent for Outlook?

FYI: I have checked multiple sources but I was most disappointed that I didn't find the answer here: https://learn.microsoft.com/en-us/javascript/api/outlook/office.body?view=outlook-js-preview Also, I take it as a bad sign that Grammarly doesn't provide an Outlook Addin in the Microsoft AppSource O365 Store.

Edit: Well, not looking good.

Edit 2: Maybe not so important, but does someone know why there is no:

window.Outlook.run(async context =>{
    //[...]
    await context.sync()
  }
)

Upvotes: 1

Views: 820

Answers (1)

user7823505
user7823505

Reputation:

This is not possible today. We track Outlook add-in feature requests on our user-voice page.

It looks like the feature you want has been requested by others already. Please upvote the existing request. Feature requests on user-voice are considered when we go through our planning process.

Upvotes: 1

Related Questions