-
Notifications
You must be signed in to change notification settings - Fork 0
Messages
github-actions[bot] edited this page Jul 25, 2026
·
1 revision
The Messages module connects you directly to the school's communication channels. It handles reading received mail, viewing attachments, sending replies, and organizing drafts.
Let's fetch the list of received messages and read the most recent unread email.
import { getMessages, getMessage } from "linkdirecte";
// Fetch the inbox
const inbox = await getMessages();
const unreadEmails = inbox.messages?.received?.filter(msg => !msg.read) ?? [];
console.log(`You have ${unreadEmails.length} unread message(s).`);
if (unreadEmails.length > 0) {
const firstUnread = unreadEmails[0];
console.log(`Reading: "${firstUnread.subject}" from ${firstUnread.fromName}...`);
// Load full content (EcoleDirecte handles base64-decoded HTML automatically inside the SDK!)
const fullDetail = await getMessage(firstUnread.id);
console.log("\nMessage body:");
console.log(fullDetail.content);
}Retrieves a directory of messages.
function getMessages(options?: GetMessagesOptions): Promise<MessagesResult>-
options(optional):-
folderId(number): Pass a folder ID to retrieve messages from custom archives or folders. -
withContent(boolean): If set totrue, automatically makes individual parallel queries to retrieve the content bodies for all returned messages. Defaults tofalse.
-
Loads the detailed envelope and content body for a single message.
function getMessage(
id: number,
): Promise<MessageEntry>Note: Opening a message with
getMessageautomatically marks it as read on EcoleDirecte's servers.
Composes and sends a new message.
function sendMessage(
data: SendMessageData,
): Promise<{ success: boolean }>import { sendMessage } from "linkdirecte";
const result = await sendMessage({
subject: "Absence Excuse",
content: "Hello, this is to inform you that...",
destinataires: [
{ id: 98765, type: "P" } // Target recipient object
]
});
if (result.success) {
console.log("Message sent successfully!");
}interface MessagesResult {
messages?: {
received?: MessageEntry[];
sent?: MessageEntry[];
drafts?: MessageEntry[];
};
}| Property | Type | Description |
|---|---|---|
id |
number |
Unique ID of the message. |
subject |
string |
Subject header of the email. |
date |
Date |
Date and time the email was received/sent. |
read |
boolean |
true if the message has been read. |
content |
string (optional)
|
Fully decoded HTML or text of the message body (available when fetching via getMessage or withContent: true). |
fromName |
string (optional)
|
Readable name of the sender. |
answered |
boolean (optional)
|
true if this message has already been replied to. |
transferred |
boolean (optional)
|
true if the message was forwarded. |
canAnswer |
boolean (optional)
|
Whether replies are permitted for this message. |
interface SendMessageData {
subject: string;
content: string;
destinataires: Array<{
id: number;
type: string; // e.g. "P" (Teacher), "E" (Student)
[key: string]: any;
}>;
}© 2026 typeof (Scolup) | Licensed under AGPL 3.0