Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get message body using JavaScript API for Office

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)

like image 964
Syed Ali Taqi Avatar asked Jul 09 '15 11:07

Syed Ali Taqi


2 Answers

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)});
like image 155
Danil Selivanov Avatar answered Nov 05 '22 15:11

Danil Selivanov


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

like image 34
InfoÁsith Avatar answered Nov 05 '22 16:11

InfoÁsith