## 14 IMAP Server Folders ¶

This chapter covers the additional features of IMAP server folders, i.e., folders on an IMAP server that you access using VM. See IMAP Folders. Do not use these features if you just download mail from IMAP mail boxes into local folders.

The command `vm-imap-synchronize` can be used to perform full synchronization between a VM folder and the corresponding folder on the IMAP server. (Recall that `vm-get-new-mail` and `vm-save-folder` do half-synchronization in one direction each.)

The variable `vm-imap-connection-mode` allows you to work while disconnected from the network. If it is set to `online`, which is the default, VM communicates with the server during `vm-get-new-mail`, `vm-save-folder` and `vm-imap-synchronize` operations. In order to work while disconnected from the network, set the variable to `offline`. In this mode, `vm-save-folder` writes any changes made to the folder to the local copy on disk (the “cache” folder); `vm-visit-imap-folder` likewise visits the cache folder.

You can set `vm-imap-connection-mode` to `autoconnect` if you have intermittent problems with the network. In this mode, doing `vm-get-new-mail` attempts to connect to the network. If it succeeds then `vm-imap-connection-mode` turns into `online`.

When the IMAP server is connected again, you should run `C-u M-x vm-imap-synchronize`, i.e., call it with a prefix argument. This causes all the message attributes and labels to be written to the server, since it may not be known which of them have actually changed during the offline operation. Similarly, all the messages that may have been expunged in the cache folder are expunged on the server.

### UIDVALIDITY ¶

Messages on an IMAP server have unique id numbers called UID’s. In addition, a second id number called UIDVALIDITY allows the server to renumber messages when the id numbers within a particular UIDVALIDITY are exhausted. All the messages on the server at any given time have the same UIDVALIDITY value. When the server needs to renumber the messages, it changes the UIDVALIDITY value and issues new UID numbers for all the messages with new UIDVALIDITY. This happens but rarely because there are over two billion UID’s within each UIDVALIDITY.

When the UIDVALIDITY changes on the IMAP server, VM has no easy way to identify the new UID’s for the messages in its cache. So, it marks all the messages in the cache as invalid and refreshes the cache with new copies of messages from the server. This is a time-consuming operation but it happens only rarely. VM warns you before it refreshes the cache and asks for confirmation. You can abort the operation if you cannot spare the time, but note that it is not possible to perform any changes to the IMAP folder until the cache is refreshed. You might consider setting the `vm-enable-external-messages` flag to `(imap)` before you refresh the cache so that it will be quicker. see External Messages.

#### Operations for the IMAP server ¶

The command `vm-list-imap-folders` lists the folders available on the IMAP server, along with the total number of messages and recent (new) messages in each of them. If you run it with a prefix argument, it lists only those folders that have new messages.

Use the command `vm-create-imap-folder` for creating a new folder on the IMAP server and `vm-delete-imap-folder` for deleting an existing folder. You can rename a folder using `vm-rename-imap-folder`.