Setting is_read in Exchange without reading the whole objectHow to retrieve an element from a set without removing it?Is there a built-in function to print all the current properties and values of an object?Extracting Embedded Images From Outlook Emailreading file without newlines in Python“Large data” work flows using pandasExim filter pipe script only working on last email - not currentThunderbird (python, Mac):Fill out email, subject, body, attach fileReceive mail from ERP software, change subject and forwardExchangelib Python extracting emails as HTML but I want plain textPython - How to send an email with attachment without loading the whole file into memory at once?
How do you say "to hell with everything" in French?
What makes an ending "happy"?
Professor refuses to write a recommendation letter to students who haven't written a research paper with him
Fantasy Military Arms and Armor: the Dwarven Grand Armory
Leaving the USA
Why can't some airports handle heavy aircraft while others do it easily (same runway length)?
How do draw effects during the discard phase work?
Why does the seven segment display have decimal point at the right?
Explanation of switch statement constraints on variably modified types in C standard
How should Thaumaturgy's "three times as loud as normal" be interpreted?
Do 643,000 Americans go bankrupt every year due to medical bills?
How could a planet have one hemisphere way warmer than the other without the planet being tidally locked?
Relationship between speed and cadence?
Draw the ☣ (Biohazard Symbol)
Entering the US with dual citizenship but US passport is long expired?
Infinitely many primes
Is mountain bike good for long distances?
Word for something that used to be popular but not anymore
What's this inadvertent thing?
Supervisor wants me to support a diploma-thesis SW tool after I graduated
First Number to Contain Each Letter
Friend is very nit picky about side comments I don't intend to be taken too seriously
Is it right to use the ideas of non-winning designers in a design contest?
Statistical closeness implies computational indistinguishability
Setting is_read in Exchange without reading the whole object
How to retrieve an element from a set without removing it?Is there a built-in function to print all the current properties and values of an object?Extracting Embedded Images From Outlook Emailreading file without newlines in Python“Large data” work flows using pandasExim filter pipe script only working on last email - not currentThunderbird (python, Mac):Fill out email, subject, body, attach fileReceive mail from ERP software, change subject and forwardExchangelib Python extracting emails as HTML but I want plain textPython - How to send an email with attachment without loading the whole file into memory at once?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to read some info from a bunch of emails quickly without pulling the whole object and set the mail item as read. Especially so, since most of the emails have large attachments I do not want to pull them. For this I try something as follows:
mail_filter = acct.inbox.filter(message_id__in=email_id_list).values_list("subject", "body", "datetime_received", "sender")
mail_filter.page_size = 2
for item in mail_filter.iterator():
do_something_with_the_tuple_in_item()
# Now I want to set is_read = True. Something like below:
acct.inbox.filter(message_id__in=email_id_list).update(is_read=True)
While with values_list I could avoid getting the whole mail item (which otherwise seems to consume lots of memory especially for emails with attachments), I find there is no update() support on the filter. So in order for me to set an email to be is_read, I meed to pull the object (at the cost of memory) and set is_read = True, then save() back. Basically, it fails the purpose to save memory usage by using values_list. Any other idea exists? Anything I am missing?
python exchangelib
add a comment |
I am trying to read some info from a bunch of emails quickly without pulling the whole object and set the mail item as read. Especially so, since most of the emails have large attachments I do not want to pull them. For this I try something as follows:
mail_filter = acct.inbox.filter(message_id__in=email_id_list).values_list("subject", "body", "datetime_received", "sender")
mail_filter.page_size = 2
for item in mail_filter.iterator():
do_something_with_the_tuple_in_item()
# Now I want to set is_read = True. Something like below:
acct.inbox.filter(message_id__in=email_id_list).update(is_read=True)
While with values_list I could avoid getting the whole mail item (which otherwise seems to consume lots of memory especially for emails with attachments), I find there is no update() support on the filter. So in order for me to set an email to be is_read, I meed to pull the object (at the cost of memory) and set is_read = True, then save() back. Basically, it fails the purpose to save memory usage by using values_list. Any other idea exists? Anything I am missing?
python exchangelib
add a comment |
I am trying to read some info from a bunch of emails quickly without pulling the whole object and set the mail item as read. Especially so, since most of the emails have large attachments I do not want to pull them. For this I try something as follows:
mail_filter = acct.inbox.filter(message_id__in=email_id_list).values_list("subject", "body", "datetime_received", "sender")
mail_filter.page_size = 2
for item in mail_filter.iterator():
do_something_with_the_tuple_in_item()
# Now I want to set is_read = True. Something like below:
acct.inbox.filter(message_id__in=email_id_list).update(is_read=True)
While with values_list I could avoid getting the whole mail item (which otherwise seems to consume lots of memory especially for emails with attachments), I find there is no update() support on the filter. So in order for me to set an email to be is_read, I meed to pull the object (at the cost of memory) and set is_read = True, then save() back. Basically, it fails the purpose to save memory usage by using values_list. Any other idea exists? Anything I am missing?
python exchangelib
I am trying to read some info from a bunch of emails quickly without pulling the whole object and set the mail item as read. Especially so, since most of the emails have large attachments I do not want to pull them. For this I try something as follows:
mail_filter = acct.inbox.filter(message_id__in=email_id_list).values_list("subject", "body", "datetime_received", "sender")
mail_filter.page_size = 2
for item in mail_filter.iterator():
do_something_with_the_tuple_in_item()
# Now I want to set is_read = True. Something like below:
acct.inbox.filter(message_id__in=email_id_list).update(is_read=True)
While with values_list I could avoid getting the whole mail item (which otherwise seems to consume lots of memory especially for emails with attachments), I find there is no update() support on the filter. So in order for me to set an email to be is_read, I meed to pull the object (at the cost of memory) and set is_read = True, then save() back. Basically, it fails the purpose to save memory usage by using values_list. Any other idea exists? Anything I am missing?
python exchangelib
python exchangelib
edited Mar 28 at 6:57
Erik Cederstrand
4,2513 gold badges23 silver badges48 bronze badges
4,2513 gold badges23 silver badges48 bronze badges
asked Mar 28 at 5:58
SoundaRSoundaR
1651 silver badge8 bronze badges
1651 silver badge8 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can tell exchangelib to only fetch some field values, and to only update the is_read
field. Also, if you only want to process unread emails, you can add a filter on the is_read
value:
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
item.save(update_fields=['is_read'])
To put even less load on the server, you can batch update your items:
update_tuples = []
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
# bulk_update() expects a list of (Item, fieldnames) tuples
items_to_update.append((item, ['is_read']))
account.bulk_update(update_tuples)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391017%2fsetting-is-read-in-exchange-without-reading-the-whole-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can tell exchangelib to only fetch some field values, and to only update the is_read
field. Also, if you only want to process unread emails, you can add a filter on the is_read
value:
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
item.save(update_fields=['is_read'])
To put even less load on the server, you can batch update your items:
update_tuples = []
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
# bulk_update() expects a list of (Item, fieldnames) tuples
items_to_update.append((item, ['is_read']))
account.bulk_update(update_tuples)
add a comment |
You can tell exchangelib to only fetch some field values, and to only update the is_read
field. Also, if you only want to process unread emails, you can add a filter on the is_read
value:
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
item.save(update_fields=['is_read'])
To put even less load on the server, you can batch update your items:
update_tuples = []
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
# bulk_update() expects a list of (Item, fieldnames) tuples
items_to_update.append((item, ['is_read']))
account.bulk_update(update_tuples)
add a comment |
You can tell exchangelib to only fetch some field values, and to only update the is_read
field. Also, if you only want to process unread emails, you can add a filter on the is_read
value:
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
item.save(update_fields=['is_read'])
To put even less load on the server, you can batch update your items:
update_tuples = []
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
# bulk_update() expects a list of (Item, fieldnames) tuples
items_to_update.append((item, ['is_read']))
account.bulk_update(update_tuples)
You can tell exchangelib to only fetch some field values, and to only update the is_read
field. Also, if you only want to process unread emails, you can add a filter on the is_read
value:
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
item.save(update_fields=['is_read'])
To put even less load on the server, you can batch update your items:
update_tuples = []
for item in f.filter(is_read=False).only('is_read', 'subject', 'body', ...):
item.is_read = True
# bulk_update() expects a list of (Item, fieldnames) tuples
items_to_update.append((item, ['is_read']))
account.bulk_update(update_tuples)
answered Mar 28 at 6:41
Erik CederstrandErik Cederstrand
4,2513 gold badges23 silver badges48 bronze badges
4,2513 gold badges23 silver badges48 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391017%2fsetting-is-read-in-exchange-without-reading-the-whole-object%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown