The CopyMail function copies all e-mails in to local memory. However when the mailbox is larger than aprox. 14000 e-mails, then it reaches c#'s upper memory limit. What can be done?
The CopyMail method should not be used for extremely large mailboxes. Instead, your application should download emails individually so that it may process each email, discard it, and continue without accumulating all emails in memory at once. In addition, if a failure occurs, your application has more options for resuming rather than re-starting from the very beginning.
Here is an example showing how to download emails by message numbers: