Reputation: 4974
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)
Upvotes: 5
Views: 4926
Reputation: 1224
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
Upvotes: 4
Reputation: 69
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)});
Upvotes: 3