IMAP Sync marking as Read

IMAP sync marks emails as Read that the user has not yet read in their native email client. I think this drive salespeople mad. Is it possible to modify this behaviour? Ideally the sync would leave the Unread flag as it is, and after sync apply a label to the original email eg “Synced to ERPNext”. Users could optionally set up rules in their email clients to move/archive/delete these.

Jumping in here too.

Can we do what JNJH is asking. Marking email Read everywhere is frustrating.

I was also searching for a solution on exactly the same thing.

When syncing via IMAP my emails are alle marked as read in all other email clients.
This lead to me missing out emails already.

Is there any way to change, edit or influence this behavoir?

You can use the Sync-Mode “ALL”, with that, the fetched emails won’t be marked as read.

Switching to Sync-Mode “ALL” sadly did not change anything.
Mails are still marked as read on the IMAP server and therefore in all other connected Email-Clients.

Any other idea?

@tehn What versions of Frappe/ERPNext are you running? This was bothering me for a long time until I reverted back to version-13 on Docker.

See this github issue: Why email_sync_option is set to UNSEEN when we choose ALL ? · Issue #18168 · frappe/frappe · GitHub

And as I look at the commit history, it looks like there is a refactoring of the retrieve_message function in receive.py, which is where the problem might lie. I can’t tell if this will fix it or not once it gets merged into version-14. But it might.

Hi @trustedcomputer,
thank you very much for your great input.

I am on a pretty updated docker compose:

ERPNext: v14.21.0
Frappe Framework: v14.31.0

I used the single_server_example.md from frappe_docker.
The architecture with using TRAEFIK as laodbalancer and reverse proxy is very neat.

Downgrading might be a hustle… I do not have experience in updating this setup yet. Shouldn’t be to hard though.
I will be watching the refactoring coming into the releases closely and check out the functionality then.

I have provided a PR that will solve the issues, https://github.com/frappe/frappe/pull/20860
Right now, this PR is under review.

2 Likes

Thanks, Patrick.

While you’re looking at the email code…I also posted these 2 issues but got no response at the time.

I think the most user friendly option would actually be to allow the user to specify a starting date for initial ingestion (rather than a count of emails), for example when migrating from another system.

Similarly I think when migrating from another system, constructing an historical timeline would be beneficial.

Yes, thank you @Patrick.St ! This has been needed for quite some time but sadly hadn’t got any attention from anyone who understands the IMAP receive code well enough before.

Hi @JNJH ,
I agree that this should be improved, too. As a first step, you could create two issues at frappe github, as the issues discussed here will be missed “easier”.

I have added the fix for your first issue as part of my PR, so that we fetch only the 100/250 most recent emails, fyi.