For anyone else stumbling over this because Notes.app stopped syncing IMAP based notes in El Capitan 10.11.3, the solution which worked for me is the following:
Firstly, check that the IMAP Path Prefix is correct for the account. This can be done in System Preferences / Internet Accounts / (select your account) / Advanced or in Mail.app / Preferences / Accounts / (select your IMAP account) / Advanced. In my case, this was set correctly to
INBOX, but sometimes requires different values, or no value at all.
Secondly, the solution given above by @rene actually works, but it's in French, so here's a step-by-step approach that worked for me.
- Open Terminal.app to get a command prompt
- Change directory to the following folder:
bash> cd ~/Library/Containers/com.apple.Notes/Data/Library/Notes/
- Make a backup the file NotesV6.storedata so that you can restore it in case something goes wrong
bash> cp NotesV6.storedata NotesV6.storedata.old
NotesV6.storedata with sqlite3
bash> sqlite3 NotesV6.storedata
- A new sqlite prompt will appear - you can always exit by pressing
- (Optional) You can examine the table that we need to fix by entering the followoing command
sqlite> .schema ZACCOUNT
ZACCOUNT table contains all accounts which Notes.app is accessing. However, in my case, the IMAP based account entry was missing information about username (field
ZUSERNAME), hostname (field
ZHOSTNAME) and path prefix (field
ZSERVERPATHPREFIX). This is the information we need to update.
You can dump the whole table by invoking
sqlite> select * from ZACCOUNT
but it's probably easier to select a few relevant fields and identify the
Z_PK id of your account
sqlite> select Z_PK,ZFULLNAME,ZPARENTACACCOUNTIDENTIFIER,ZUSERNAME, ZHOSTNAME, ZSERVERPATHPREFIX from ZACCOUNT;
This produced the following output for me:
As you can see by the field divider lines (
|) at the end of the last line, fields for username, hostname, and prefix are empty for the IMAP account (
Z_PK id 5) which is what needs to be corrected.
- Update the table entry by invoking:
update ZACCOUNT set ZUSERNAMEfirstname.lastname@example.org', ZHOSTNAME='imap.hostname.com',ZSERVERPATHPREFIX='INBOX.' where Z_PK=5;
You will of course need to set the correct field values and also adjust the
Z_PK id with the correct reference, which you identified above.
- As soon as I'd updated the table, Notes.app started magically syncing the notes from my IMAP based accounts.