# messages.get()

Canonical URL: https://developers.iagenify.com/sdk/ref/mailbox/messages/get/
Language: en

`mailbox.messages.get(id) → Promise<Message>`

The whole message: text, HTML, copies and attachments — each attachment with a signed link that lasts fifteen minutes.

Status: free · links last 15 minutes · never render sender HTML

```javascript
const message = await box.messages.get(id);

message.from;          // { address, name, avatar, avatarSource }
message.text;
message.attachments;   // [{ id, name, size, mime, inline, contentId, url }]
```

## Never render a sender's HTML {#html}

> **It is someone else's HTML in your page**
>
> Strip it to text, or render it in something that cannot execute. Anyone can send a message, which makes this the most obviously hostile input a product has.

## An attachment link lasts fifteen minutes {#links}

```javascript
// A reader left open must renew
setInterval(() => box.messages.get(openId).then(render), 12 * 60_000);
```

Past that, images break and downloads are refused while the bytes are perfectly safe. Re-read the message every twelve minutes, and when a tab comes back.

## inline alone does not mean « already shown » {#inline}

> **Hide a part only when the body cites its contentId**
>
> Some senders mark every attachment as inline with an identifier, even when the body refers to none of them. A reader that hides on the flag alone hides the photo from the list while the body shows nothing — it disappears twice.

## url can be null {#null-url}

The bytes could not be stored — a full quota, or a part that was too large. The attachment is still described, and an honest page says « not available » rather than offering a dead link. **A message is never lost for it.**

## The sender's picture {#from}

`from.avatar`, with `avatarSource` saying whether it is from your address book or from the sender's domain. Nothing at all when neither exists — keep initials for that.

- [messages.update()](/sdk/ref/mailbox/messages/update): Marking it read.
- [contacts.save()](/sdk/ref/mail/contacts/save): Putting a face on a person.

```python
message = box.messages.get(message_id)

message["from"]          # {"address", "name", "avatar", "avatarSource"}
message["text"]
message["attachments"]   # [{"id", "name", "size", "mime", "inline", "contentId", "url"}]
```

```python
import threading

# A reader left open must renew its signed links
def renew():
    render(box.messages.get(open_id))
    threading.Timer(12 * 60, renew).start()

renew()
```
