5

I'm working on a simple mail app and I need to get the body of a message. MSDN says, version 1.1 of JavaScript API for Office has body property for message object and it can be get like this:

Office.context.mailbox.item.body;

but the problem is that I need to access the body in read mode and MSDN states that:

Read mode: The body property is undefined.

Why is the body property undefined in read mode and How can I access it? (if possible)

Philip Rueker
  • 948
  • 5
  • 15
Syed Ali Taqi
  • 4,898
  • 3
  • 34
  • 44
  • Did you ever solve this? I have the same issue. – Sam Stainsby Aug 26 '16 at 06:53
  • 1
    @SamStainsby: sadly, no. – Syed Ali Taqi Aug 26 '16 at 07:50
  • 1
    @SamStainsby and SyedAliTaqi it is depend on minimum mailbox requirement in manifest file .[Link](https://dev.outlook.com/reference/add-ins/1.3/Body.html) otherwise you have to use ews request. – DevÁsith Aug 26 '16 at 09:06
  • @InfoÁsith In https://dev.outlook.com/reference/add-ins/1.3/Office.context.mailbox.item.html is lists the 'body' member as "Minimum mailbox requirement set version 1.1", which we do specify in the manifest. Is that not sufficient? – Sam Stainsby Aug 26 '16 at 22:13
  • @SamStainsby yes not sufficient .if you carefully see, **getAsync()** ,and **setAsync()** functions are not appeared in requirement set version 1.1. this Body property only support few methods when requirement set version is 1.1 – DevÁsith Aug 29 '16 at 04:44
  • @InfoÁsith Yes, but item.body is undefined ... not just missing the getAsync method. – Sam Stainsby Aug 29 '16 at 06:21

2 Answers2

3

message.body or Office.context.mailbox.item.body returns Body type. Try to use this to get body text.

Office.context.mailbox.item.body.getAsync('text', function (async) {console.log(async.value)});
3

Here is getBody function. it has used CoercionType type

function getBody() {
        var _item = Office.context.mailbox.item;
        var body = _item.body;

        // Get the body asynchronous as text
        body.getAsync(Office.CoercionType.Html, function (asyncResult) {
            if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
                // TODO: Handle error
            }
            else {
                // Show data

                console.log('Body', asyncResult.value.trim());
            }
        });
    }

but above function is part of mailbox requirement set 1.3. however this function will not work in outlook mac because it minimum mailbox requirement is 1.1

DevÁsith
  • 1,072
  • 12
  • 38