Skip to main content

io_msgraph/v1/rest/users/
messages.rs

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