Comments (2)
GetMessages is only a simple wrapper:
public MailMessage[] GetMessages(uint[] uids, FetchOptions options,
bool seen = true, string mailbox = null) {
List<MailMessage> list = new List<MailMessage>();
foreach (uint uid in uids)
list.Add(GetMessage(uid, options, seen, mailbox));
return list.ToArray();
}
Based on this you could change your code to:
uint[] uids = Client.Search(SearchCondition.All());
Dictionary<uint, MailMessage> messages = new Dictionary<uint, MailMessage>();
foreach (uint uid in uids)
messages.Add(uid, GetMessage(uid, FetchOptions.Normal));
foreach (KeyValuePair<uint, MailMessage> kvmsg in messages)
{
MailMessage msg = kvmsg.Value;
bool delete = false;
// process the message here
if (delete)
Client.DeleteMessage(kvmsg.Key);
}
Or if the work is really done in that loop you will probably want to walk the uids and doing the GetMessage in one loop:
uint[] uids = Client.Search(SearchCondition.All());
foreach (uint uid in uids)
{
MailMessage msg = GetMessage(uid, FetchOptions.Normal);
bool delete = false;
// process the message here
if (delete)
Client.DeleteMessage(uid);
}
Fetching all messages first and doing work when all data is collected might be desired in some cases and in others you would like to do the work when you have the data.
Also remember if you fetch all the messages first they are all stored in memory while you process them.
from s22.imap.
@NiKiZe - thank you very much for the explanation and suggestion. That's exactly what I was looking for!
from s22.imap.
Related Issues (20)
- Error “xm007 bad command argument 11” while marking outlook email as read from Scheduler not at manual run
- How can check the status of Message if is seen or unseen
- Attachments from iPhones don't always populate the Attachments collection HOT 2
- SearchCondition.SentSince seems not working HOT 1
- Low file size attachment is not found
- No type "Mailmessage" in Mono C# .net core linux application HOT 1
- Where are attachments after downloading ?
- Network connection lost while retrieving a mail message HOT 1
- SCRAM-SHA-1-PLUS + SCRAM-SHA-224(-PLUS) + SCRAM-SHA-256(-PLUS) + SCRAM-SHA-384(-PLUS) + SCRAM-SHA-512(-PLUS) + SCRAM-SHA3-512(-PLUS) supports
- Move this project to new dev team?
- inline file
- Intermittent freezing on Search
- DeleteMessage doesn't delete the message
- Documentation is not available - 404 error HOT 1
- xm002 NO SELECT Unsafe Login. Please contact [email protected] for help HOT 1
- Can not login to gmail HOT 1
- Connection doesn't restart after disruption to internet connection
- How to read email with 'Reply-To' position email account
- Is there a save option for the message itself as a *.eml file
- Error getting value from 'ReadTimeout' on 'System.IO.MemoryStream'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s22.imap.