Skip to main content

io_msgraph/v1/rest/users/
messages.rs

1//! Microsoft Graph messages (`users.messages`): list, get (JSON and raw
2//! MIME), create draft (JSON and raw MIME), update, delete, move, copy,
3//! send and the nested attachments collection.
4//!
5//! <https://learn.microsoft.com/en-us/graph/api/resources/message>
6
7use alloc::{string::String, vec::Vec};
8
9use serde::{Deserialize, Serialize};
10
11pub mod attachments;
12pub mod copy;
13pub mod create;
14pub mod create_mime;
15pub mod delete;
16pub mod get;
17pub mod get_raw;
18pub mod list;
19pub mod r#move;
20pub mod send;
21pub mod update;
22
23/// A message in a mail folder. Doubles as the create/update body, where
24/// only the set (non-empty) fields are serialized.
25#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
26#[serde(rename_all = "camelCase")]
27pub struct MsgraphMessage {
28    /// The unique identifier of the message.
29    #[serde(default, skip_serializing_if = "String::is_empty")]
30    pub id: String,
31    /// The subject of the message.
32    #[serde(default, skip_serializing_if = "Option::is_none")]
33    pub subject: Option<String>,
34    /// The first bytes of the body, in text format.
35    #[serde(default, skip_serializing_if = "Option::is_none")]
36    pub body_preview: Option<String>,
37    /// The body of the message, in text or HTML format.
38    #[serde(default, skip_serializing_if = "Option::is_none")]
39    pub body: Option<MsgraphItemBody>,
40    /// The mailbox owner displayed as the author.
41    #[serde(default, skip_serializing_if = "Option::is_none")]
42    pub from: Option<MsgraphRecipient>,
43    /// The account actually used to send the message.
44    #[serde(default, skip_serializing_if = "Option::is_none")]
45    pub sender: Option<MsgraphRecipient>,
46    /// The To recipients of the message.
47    #[serde(default, skip_serializing_if = "Vec::is_empty")]
48    pub to_recipients: Vec<MsgraphRecipient>,
49    /// The Cc recipients of the message.
50    #[serde(default, skip_serializing_if = "Vec::is_empty")]
51    pub cc_recipients: Vec<MsgraphRecipient>,
52    /// The Bcc recipients of the message.
53    #[serde(default, skip_serializing_if = "Vec::is_empty")]
54    pub bcc_recipients: Vec<MsgraphRecipient>,
55    /// The addresses replies should be sent to.
56    #[serde(default, skip_serializing_if = "Vec::is_empty")]
57    pub reply_to: Vec<MsgraphRecipient>,
58    /// The reception date, as an ISO 8601 date-time.
59    #[serde(default, skip_serializing_if = "Option::is_none")]
60    pub received_date_time: Option<String>,
61    /// The send date, as an ISO 8601 date-time.
62    #[serde(default, skip_serializing_if = "Option::is_none")]
63    pub sent_date_time: Option<String>,
64    /// Whether the message has been read.
65    #[serde(default, skip_serializing_if = "Option::is_none")]
66    pub is_read: Option<bool>,
67    /// Whether the message is a draft.
68    #[serde(default, skip_serializing_if = "Option::is_none")]
69    pub is_draft: Option<bool>,
70    /// Whether the message carries attachments.
71    #[serde(default, skip_serializing_if = "Option::is_none")]
72    pub has_attachments: Option<bool>,
73    /// The RFC 5322 Message-ID header of the message.
74    #[serde(default, skip_serializing_if = "Option::is_none")]
75    pub internet_message_id: Option<String>,
76    /// The importance of the message.
77    #[serde(default, skip_serializing_if = "Option::is_none")]
78    pub importance: Option<MsgraphImportance>,
79    /// The follow-up flag set on the message.
80    #[serde(default, skip_serializing_if = "Option::is_none")]
81    pub flag: Option<MsgraphFollowupFlag>,
82    /// The categories associated with the message.
83    #[serde(default, skip_serializing_if = "Vec::is_empty")]
84    pub categories: Vec<String>,
85    /// The identifier of the containing mail folder.
86    #[serde(default, skip_serializing_if = "Option::is_none")]
87    pub parent_folder_id: Option<String>,
88    /// The identifier of the conversation the message belongs to.
89    #[serde(default, skip_serializing_if = "Option::is_none")]
90    pub conversation_id: Option<String>,
91}
92
93/// A message recipient, wrapping an email address.
94#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
95#[serde(rename_all = "camelCase")]
96pub struct MsgraphRecipient {
97    /// The email address of the recipient.
98    pub email_address: MsgraphEmailAddress,
99}
100
101/// A named email address (`recipient.emailAddress`).
102#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
103#[serde(rename_all = "camelCase")]
104pub struct MsgraphEmailAddress {
105    /// The display name paired with the address.
106    #[serde(default, skip_serializing_if = "Option::is_none")]
107    pub name: Option<String>,
108    /// The email address itself.
109    #[serde(default, skip_serializing_if = "Option::is_none")]
110    pub address: Option<String>,
111}
112
113/// The body of a message, in text or HTML format.
114#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
115#[serde(rename_all = "camelCase")]
116pub struct MsgraphItemBody {
117    /// The format of the body content.
118    #[serde(default, skip_serializing_if = "Option::is_none")]
119    pub content_type: Option<MsgraphBodyType>,
120    /// The body content itself.
121    #[serde(default, skip_serializing_if = "Option::is_none")]
122    pub content: Option<String>,
123}
124
125/// Follow-up flag set on a message.
126#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
127#[serde(rename_all = "camelCase")]
128pub struct MsgraphFollowupFlag {
129    /// The status of the follow-up flag.
130    #[serde(default, skip_serializing_if = "Option::is_none")]
131    pub flag_status: Option<MsgraphFlagStatus>,
132}
133
134/// Format of a message body.
135#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
136#[serde(rename_all = "lowercase")]
137pub enum MsgraphBodyType {
138    /// Plain text body.
139    Text,
140    /// HTML body.
141    Html,
142}
143
144/// Status of a follow-up flag.
145#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
146#[serde(rename_all = "camelCase")]
147pub enum MsgraphFlagStatus {
148    /// The message is not flagged.
149    NotFlagged,
150    /// The follow-up is completed.
151    Complete,
152    /// The message is flagged for follow-up.
153    Flagged,
154}
155
156/// Importance of a message.
157#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
158#[serde(rename_all = "lowercase")]
159pub enum MsgraphImportance {
160    /// Low importance.
161    Low,
162    /// Normal importance, the default.
163    Normal,
164    /// High importance.
165    High,
166}