Reading message

First of all, let’s retrieve messages metadata from the blockchain:
const messages = await reader.retrieveMessageHistoryByBounds(account.address);
Now, we have all the metadata: date, sender, recipient, key for decryption. But we hadn’t loaded message content from the blockchain yet. So, let’s do this:
const message = messages[0];
const content = await reader.retrieveAndVerifyMessageContent(message);
if (!content || content.corrupted) { // check content integrity
throw new Error('Content not found or corrupted');
}
Now, let’s unpack and decrypt the container in which content of the message is stored:
const decodedContent = await ylide.decryptMessageContent(
account, // recipient account
message, // message header
content, // message content
);
Finally, we can easily access the content of the message:
alert(decodedContent.subject + '\n\n' + decodedContent.content);

Whoohoo!