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