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