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