-
Notifications
You must be signed in to change notification settings - Fork 111
/
IImapClient.cs
699 lines (666 loc) · 41.8 KB
/
IImapClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
using System;
using System.IO;
using System.Collections.Generic;
using System.Net.Mail;
namespace S22.Imap {
/// <summary>
/// Enables applications to communicate with a mail server using the Internet Message Access
/// Protocol (IMAP).
/// </summary>
public interface IImapClient : IDisposable {
/// <summary>
/// The default mailbox to operate on.
/// </summary>
/// <exception cref="ArgumentNullException">The property is being set and the value is
/// null.</exception>
/// <exception cref="ArgumentException">The property is being set and the value is the empty
/// string.</exception>
/// <remarks>The default value for this property is "INBOX" which is a special name reserved
/// to mean "the primary mailbox for this user on this server".</remarks>
string DefaultMailbox { get; set; }
/// <summary>
/// Determines whether the client is authenticated with the server.
/// </summary>
bool Authed { get; }
/// <summary>
/// The event that is raised when a new mail message has been received by the server.
/// </summary>
/// <remarks>To probe a server for IMAP IDLE support, the <see cref="Supports"/>
/// method can be used, specifying "IDLE" for the capability parameter.
///
/// Please note that the event handler will be executed on a threadpool thread.
/// </remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="NewMessage"]/*'/>
event EventHandler<IdleMessageEventArgs> NewMessage;
/// <summary>
/// The event that is raised when a message has been deleted on the server.
/// </summary>
/// <remarks>To probe a server for IMAP IDLE support, the <see cref="Supports"/>
/// method can be used, specifying "IDLE" for the capability parameter.
///
/// Please note that the event handler will be executed on a threadpool thread.
/// </remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="MessageDeleted"]/*'/>
event EventHandler<IdleMessageEventArgs> MessageDeleted;
/// <summary>
/// Attempts to establish an authenticated session with the server using the specified
/// credentials.
/// </summary>
/// <param name="username">The username with which to login in to the IMAP server.</param>
/// <param name="password">The password with which to log in to the IMAP server.</param>
/// <param name="method">The requested method of authentication. Can be one of the values
/// of the AuthMethod enumeration.</param>
/// <exception cref="ArgumentNullException">The username parameter or the password parameter
/// is null.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="InvalidCredentialsException">The server rejected the supplied
/// credentials.</exception>
/// <exception cref="NotSupportedException">The specified authentication method is not
/// supported by the server.</exception>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="Login"]/*'/>
void Login(string username, string password, AuthMethod method);
/// <summary>
/// Logs an authenticated client out of the server. After the logout sequence has been completed,
/// the server closes the connection with the client.
/// </summary>
/// <exception cref="BadServerResponseException">An unexpected response has been received from
/// the server during the logout sequence.</exception>
/// <remarks>Calling this method in non-authenticated state has no effect.</remarks>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
void Logout();
/// <summary>
/// Returns an enumerable collection of capabilities the IMAP server supports. All strings in
/// the returned collection are guaranteed to be upper-case.
/// </summary>
/// <exception cref="BadServerResponseException">An unexpected response has been received from
/// the server; The message property of the exception contains the error message returned by
/// the server.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <returns>An enumerable collection of capabilities supported by the server.</returns>
/// <remarks>This method may be called in non-authenticated state.</remarks>
IEnumerable<string> Capabilities();
/// <summary>
/// Determines whether the specified capability is supported by the server.
/// </summary>
/// <param name="capability">The IMAP capability to probe for (for example "IDLE").</param>
/// <exception cref="ArgumentNullException">The capability parameter is null.</exception>
/// <exception cref="BadServerResponseException">An unexpected response has been received from
/// the server; The message property of the exception contains the error message returned by
/// the server.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <returns>true if the specified capability is supported by the server; Otherwise
/// false.</returns>
/// <remarks>This method may be called in non-authenticated state.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="ctor-2"]/*'/>
bool Supports(string capability);
/// <summary>
/// Changes the name of the specified mailbox.
/// </summary>
/// <param name="mailbox">The mailbox to rename.</param>
/// <param name="newName">The new name the mailbox will be renamed to.</param>
/// <exception cref="ArgumentNullException">The mailbox parameter or the
/// newName parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mailbox could not be renamed; The message
/// property of the exception contains the error message returned by the server.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
void RenameMailbox(string mailbox, string newName);
/// <summary>
/// Permanently removes the specified mailbox.
/// </summary>
/// <param name="mailbox">The name of the mailbox to remove.</param>
/// <exception cref="ArgumentNullException">The mailbox parameter is null.</exception>
/// <exception cref="BadServerResponseException">The specified mailbox could not be removed.
/// The message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
void DeleteMailbox(string mailbox);
/// <summary>
/// Creates a new mailbox with the specified name.
/// </summary>
/// <param name="mailbox">The name of the mailbox to create.</param>
/// <exception cref="ArgumentNullException">The mailbox parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mailbox with the specified name could
/// not be created. The message property of the exception contains the error message returned
/// by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
void CreateMailbox(string mailbox);
/// <summary>
/// Retrieves a list of all available and selectable mailboxes on the server.
/// </summary>
/// <returns>An enumerable collection of the names of all available and selectable
/// mailboxes.</returns>
/// <exception cref="BadServerResponseException">The list of mailboxes could not be retrieved.
/// The message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>The mailbox name "INBOX" is a special name reserved to mean "the primary mailbox
/// for this user on this server".</remarks>
IEnumerable<string> ListMailboxes();
/// <summary>
/// Permanently removes all messages that have the \Deleted flag set from the specified mailbox.
/// </summary>
/// <param name="mailbox">The mailbox to remove all messages from that have the \Deleted flag
/// set. If this parameter is omitted, the value of the DefaultMailbox property is used to
/// determine the mailbox to operate on.</param>
/// <exception cref="BadServerResponseException">The expunge operation could not be completed.
/// The message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="DeleteMessage"/>
void Expunge(string mailbox = null);
/// <summary>
/// Retrieves status information (total number of messages, various attributes as well as quota
/// information) for the specified mailbox.</summary>
/// <param name="mailbox">The mailbox to retrieve status information for. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>A MailboxInfo object containing status information for the mailbox.</returns>
/// <exception cref="BadServerResponseException">The operation could not be completed because
/// the server returned an error. The message property of the exception contains the error message
/// returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>Not all IMAP servers support the retrieval of quota information. If it is not
/// possible to retrieve this information, the UsedStorage and FreeStorage properties of the
/// returned MailboxStatus instance are set to 0.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMailboxInfo"]/*'/>
MailboxInfo GetMailboxInfo(string mailbox = null);
/// <summary>
/// Searches the specified mailbox for messages that match the given search criteria.
/// </summary>
/// <param name="criteria">A search criteria expression; Only messages that match this
/// expression will be included in the result set returned by this method.</param>
/// <param name="mailbox">The mailbox that will be searched. If this parameter is omitted, the
/// value of the DefaultMailbox property is used to determine the mailbox to operate on.</param>
/// <exception cref="ArgumentNullException">The criteria parameter is null.</exception>
/// <exception cref="BadServerResponseException">The search could not be completed. The message
/// property of the exception contains the error message returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <exception cref="NotSupportedException">The search values contain characters beyond the
/// ASCII range and the server does not support handling non-ASCII strings.</exception>
/// <returns>An enumerable collection of unique identifiers (UIDs) which can be used with the
/// GetMessage family of methods to download the mail messages.</returns>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="Search"]/*'/>
IEnumerable<uint> Search(SearchCondition criteria, string mailbox = null);
/// <summary>
/// Retrieves the mail message with the specified unique identifier (UID).
/// </summary>
/// <param name="uid">The unique identifier of the mail message to retrieve.</param>
/// <param name="seen">Set this to true to set the \Seen flag for this message on the
/// server.</param>
/// <param name="mailbox">The mailbox the message will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An initialized instance of the MailMessage class representing the fetched mail
/// message.</returns>
/// <exception cref="BadServerResponseException">The mail message could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessage-1"]/*'/>
MailMessage GetMessage(uint uid, bool seen = true, string mailbox = null);
/// <summary>
/// Retrieves the mail message with the specified unique identifier (UID) using the specified
/// fetch-option.
/// </summary>
/// <param name="uid">The unique identifier of the mail message to retrieve.</param>
/// <param name="options">A value from the FetchOptions enumeration which allows
/// for fetching selective parts of a mail message.</param>
/// <param name="seen">Set this to true to set the \Seen flag for this message on the
/// server.</param>
/// <param name="mailbox">The mailbox the message will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An initialized instance of the MailMessage class representing the fetched mail
/// message.</returns>
/// <exception cref="BadServerResponseException">The mail message could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.
/// <para>If you need more fine-grained control over which parts of a mail message to fetch,
/// consider using one of the overloaded GetMessage methods.
/// </para>
/// </remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessage-2"]/*'/>
MailMessage GetMessage(uint uid, FetchOptions options, bool seen = true, string mailbox = null);
/// <summary>
/// Retrieves the mail message with the specified unique identifier (UID) while only fetching
/// those parts of the message that satisfy the condition of the specified delegate.
/// </summary>
/// <param name="uid">The unique identifier of the mail message to retrieve.</param>
/// <param name="callback">A delegate which will be invoked for every MIME body-part of the
/// mail message to determine whether the part should be fetched from the server or
/// skipped.</param>
/// <param name="seen">Set this to true to set the \Seen flag for this message on the
/// server.</param>
/// <param name="mailbox">The mailbox the message will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An initialized instance of the MailMessage class representing the fetched mail
/// message.</returns>
/// <exception cref="ArgumentNullException">The callback parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail message could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessage-3"]/*'/>
MailMessage GetMessage(uint uid, ExaminePartDelegate callback, bool seen = true,
string mailbox = null);
/// <summary>
/// Retrieves the set of mail messages with the specified unique identifiers (UIDs).
/// </summary>
/// <param name="uids">An enumerable collection of unique identifiers of the mail messages to
/// retrieve.</param>
/// <param name="seen">Set this to true to set the \Seen flag for the fetched messages on the
/// server.</param>
/// <param name="mailbox">The mailbox the messages will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An enumerable collection of initialized instances of the MailMessage class
/// representing the fetched mail messages.</returns>
/// <exception cref="ArgumentNullException">The uids parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessages-1"]/*'/>
IEnumerable<MailMessage> GetMessages(IEnumerable<uint> uids, bool seen = true,
string mailbox = null);
/// <summary>
/// Retrieves the set of mail messages with the specified unique identifiers (UIDs) while only
/// fetching those parts of the messages that satisfy the condition of the specified delegate.
/// </summary>
/// <param name="uids">An enumerable collection of unique identifiers of the mail messages to
/// retrieve.</param>
/// <param name="callback">A delegate which will be invoked for every MIME body-part of each
/// mail message to determine whether the part should be fetched from the server or
/// skipped.</param>
/// <param name="seen">Set this to true to set the \Seen flag for the fetched messages on the
/// server.</param>
/// <param name="mailbox">The mailbox the messages will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An enumerable collection of initialized instances of the MailMessage class
/// representing the fetched mail messages.</returns>
/// <exception cref="ArgumentNullException">The uids parameter or the callback parameter is
/// null.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessages-3"]/*'/>
IEnumerable<MailMessage> GetMessages(IEnumerable<uint> uids, ExaminePartDelegate callback,
bool seen = true, string mailbox = null);
/// <summary>
/// Retrieves the set of mail messages with the specified unique identifiers (UIDs) using the
/// specified fetch-option.
/// </summary>
/// <param name="uids">An enumerable collection of unique identifiers of the mail messages to
/// retrieve.</param>
/// <param name="options">A value from the FetchOptions enumeration which allows for fetching
/// selective parts of a mail message.</param>
/// <param name="seen">Set this to true to set the \Seen flag for the fetched messages on the
/// server.</param>
/// <param name="mailbox">The mailbox the messages will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An enumerable collection of initialized instances of the MailMessage class
/// representing the fetched mail messages.</returns>
/// <exception cref="ArgumentNullException">The uids parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be fetched. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="GetMessages-2"]/*'/>
IEnumerable<MailMessage> GetMessages(IEnumerable<uint> uids, FetchOptions options,
bool seen = true, string mailbox = null);
/// <summary>
/// Stores the specified mail message on the IMAP server.
/// </summary>
/// <param name="message">The mail message to store on the server.</param>
/// <param name="seen">Set this to true to set the \Seen flag for the message on the
/// server.</param>
/// <param name="mailbox">The mailbox the message will be stored in. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to store
/// the message in.</param>
/// <returns>The unique identifier (UID) of the stored message.</returns>
/// <exception cref="ArgumentNullException">The message parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail message could not be stored. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <seealso cref="StoreMessages"/>
/// <include file='Examples.xml' path='S22/Imap/ImapClient[@name="StoreMessage"]/*'/>
uint StoreMessage(MailMessage message, bool seen = false, string mailbox = null);
/// <summary>
/// Stores the specified mail messages on the IMAP server.
/// </summary>
/// <param name="messages">An enumerable collection of mail messages to store on the
/// server.</param>
/// <param name="seen">Set this to true to set the \Seen flag for each message on the
/// server.</param>
/// <param name="mailbox">The mailbox the messages will be stored in. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to store
/// the messages in.</param>
/// <returns>An enumerable collection of unique identifiers (UID) representing the stored
/// messages on the server.</returns>
/// <exception cref="ArgumentNullException">The messages parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be stored. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
/// identifies the message within the respective mailbox. No two messages in a mailbox share
/// the same UID.</remarks>
/// <seealso cref="StoreMessage"/>
IEnumerable<uint> StoreMessages(IEnumerable<MailMessage> messages, bool seen = false,
string mailbox = null);
/// <summary>
/// Copies the mail message with the specified UID to the specified destination mailbox.
/// </summary>
/// <param name="uid">The UID of the mail message to copy.</param>
/// <param name="destination">The name of the mailbox to copy the message to.</param>
/// <param name="mailbox">The mailbox the message will be copied from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <exception cref="ArgumentNullException">The destination parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail message could not be copied to the
/// specified destination. The message property of the exception contains the error message
/// returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessage"/>
void CopyMessage(uint uid, string destination, string mailbox = null);
/// <summary>
/// Copies the mail messages with the specified UIDs to the specified destination mailbox.
/// </summary>
/// <param name="uids">An enumerable collection of UIDs of the mail messages to copy.</param>
/// <param name="destination">The name of the mailbox to copy the messages to.</param>
/// <param name="mailbox">The mailbox the message will be copied from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <remarks>When copying many messages, this method is more efficient than calling
/// <see cref="CopyMessage"/> for each individual message.</remarks>
/// <exception cref="ArgumentNullException">The uids parameter or the destination parameter is
/// null.</exception>
/// <exception cref="ArgumentException">The specified collection of UIDs is empty.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be copied to the
/// specified destination. The message property of the exception contains the error message
/// returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessages"/>
void CopyMessages(IEnumerable<uint> uids, string destination, string mailbox = null);
/// <summary>
/// Moves the mail message with the specified UID to the specified destination mailbox.
/// </summary>
/// <param name="uid">The UID of the mail message to move.</param>
/// <param name="destination">The name of the mailbox to move the message into.</param>
/// <param name="mailbox">The mailbox the message will be moved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <exception cref="ArgumentNullException">The destination parameter is null.</exception>
/// <exception cref="BadServerResponseException">The mail message could not be moved to the
/// specified destination. The message property of the exception contains the error message
/// returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="CopyMessage"/>
/// <seealso cref="DeleteMessage"/>
void MoveMessage(uint uid, string destination, string mailbox = null);
/// <summary>
/// Moves the mail messages with the specified UIDs to the specified destination mailbox.
/// </summary>
/// <param name="uids">An enumerable collection of UIDs of the mail messages to move.</param>
/// <param name="destination">The name of the mailbox to move the messages into.</param>
/// <param name="mailbox">The mailbox the messages will be moved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <remarks>When moving many messages, this method is more efficient than calling
/// <see cref="MoveMessage"/> for each individual message.</remarks>
/// <exception cref="ArgumentNullException">The uids parameter or the destination parameter is
/// null.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be moved to the
/// specified destination. The message property of the exception contains the error message
/// returned by the server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="CopyMessages"/>
/// <seealso cref="DeleteMessages"/>
void MoveMessages(IEnumerable<uint> uids, string destination, string mailbox = null);
/// <summary>
/// Deletes the mail message with the specified UID.
/// </summary>
/// <param name="uid">The UID of the mail message to delete.</param>
/// <param name="mailbox">The mailbox the message will be deleted from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <exception cref="BadServerResponseException">The mail message could not be deleted. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessage"/>
void DeleteMessage(uint uid, string mailbox = null);
/// <summary>
/// Deletes the mail messages with the specified UIDs.
/// </summary>
/// <param name="uids">An enumerable collection of UIDs of the mail messages to delete.</param>
/// <param name="mailbox">The mailbox the messages will be deleted from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <remarks>When deleting many messages, this method is more efficient than calling
/// <see cref="DeleteMessage"/> for each individual message.</remarks>
/// <exception cref="ArgumentNullException">The uids parameter is null.</exception>
/// <exception cref="ArgumentException">The specified collection of UIDs is empty.</exception>
/// <exception cref="BadServerResponseException">The mail messages could not be deleted. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="MoveMessages"/>
void DeleteMessages(IEnumerable<uint> uids, string mailbox = null);
/// <summary>
/// Retrieves the IMAP message flag attributes for the mail message with the specified unique
/// identifier (UID).
/// </summary>
/// <param name="uid">The UID of the mail message to retrieve the flag attributes for.</param>
/// <param name="mailbox">The mailbox the message will be retrieved from. If this parameter is
/// omitted, the value of the DefaultMailbox property is used to determine the mailbox to
/// operate on.</param>
/// <returns>An enumerable collection of message flags set for the message with the specified
/// UID.</returns>
/// <exception cref="BadServerResponseException">The mail message flags could not be retrieved.
/// The message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <seealso cref="SetMessageFlags"/>
/// <seealso cref="AddMessageFlags"/>
/// <seealso cref="RemoveMessageFlags"/>
IEnumerable<MessageFlag> GetMessageFlags(uint uid, string mailbox = null);
/// <summary>
/// Sets the IMAP message flag attributes for the mail message with the specified unique
/// identifier (UID).
/// </summary>
/// <param name="uid">The UID of the mail message to set the flag attributes for.</param>
/// <param name="mailbox">The mailbox that contains the mail message. If this parameter is null,
/// the value of the DefaultMailbox property is used to determine the mailbox to operate
/// on.</param>
/// <param name="flags">One or multiple message flags from the MessageFlag enumeration.</param>
/// <exception cref="BadServerResponseException">The mail message flags could not be set. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>This method replaces the current flag attributes of the message with the specified
/// new flags. If you wish to retain the old attributes, use the <see cref="AddMessageFlags"/>
/// method instead.</remarks>
/// <seealso cref="GetMessageFlags"/>
/// <seealso cref="AddMessageFlags"/>
/// <seealso cref="RemoveMessageFlags"/>
void SetMessageFlags(uint uid, string mailbox, params MessageFlag[] flags);
/// <summary>
/// Adds the specified set of IMAP message flags to the existing flag attributes of the mail
/// message with the specified unique identifier (UID).
/// </summary>
/// <param name="uid">The UID of the mail message to add the flag attributes to.</param>
/// <param name="mailbox">The mailbox that contains the mail message. If this parameter is null,
/// the value of the DefaultMailbox property is used to determine the mailbox to operate
/// on.</param>
/// <param name="flags">One or multiple message flags from the MessageFlag enumeration.</param>
/// <exception cref="BadServerResponseException">The mail message flags could not be added. The
/// message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>This method adds the specified set of flags to the existing set of flag attributes
/// of the message. If you wish to replace the old attributes, use the
/// <see cref="SetMessageFlags"/> method instead.</remarks>
/// <seealso cref="GetMessageFlags"/>
/// <seealso cref="SetMessageFlags"/>
/// <seealso cref="RemoveMessageFlags"/>
void AddMessageFlags(uint uid, string mailbox, params MessageFlag[] flags);
/// <summary>
/// Removes the specified set of IMAP message flags from the existing flag attributes of the
/// mail message with the specified unique identifier (UID).
/// </summary>
/// <param name="uid">The UID of the mail message to remove the flag attributes for.</param>
/// <param name="mailbox">The mailbox that contains the mail message. If this parameter is null,
/// the value of the DefaultMailbox property is used to determine the mailbox to operate
/// on.</param>
/// <param name="flags">One or multiple message flags from the MessageFlag enumeration.</param>
/// <exception cref="BadServerResponseException">The mail message flags could not be removed.
/// The message property of the exception contains the error message returned by the
/// server.</exception>
/// <exception cref="ObjectDisposedException">The ImapClient object has been disposed.</exception>
/// <exception cref="IOException">There was a failure writing to or reading from the
/// network.</exception>
/// <exception cref="NotAuthenticatedException">The method was called in non-authenticated
/// state, i.e. before logging in.</exception>
/// <remarks>This method removes the specified set of flags from the existing set of flag
/// attributes of the message. If you wish to replace the old attributes, use the
/// <see cref="SetMessageFlags"/> method instead.</remarks>
/// <seealso cref="GetMessageFlags"/>
/// <seealso cref="SetMessageFlags"/>
/// <seealso cref="AddMessageFlags"/>
void RemoveMessageFlags(uint uid, string mailbox, params MessageFlag[] flags);
}
}