I have recently moved my email workflow over to emacs. This consists of an 'Inbox' folder and an 'Archive' folder. I move all emails to 'Archive' after they are dealt with, leaving me with an empty Inbox folder most of the time.
After setting up offlineimap to sync with Outlook, I refiled the entire 'Inbox' to 'Archive'. This initially worked fine, but I then realized that each time the index was re synced, the entire inbox would be re filled, leaving me a duplicate set of emails in the 'Inbox' and 'Archive'.
I closely followed online tutorials and have little experience debugging these kind of issues. Here is the mu4e section of my emacs confg:
(use-package mu4e
:load-path "/usr/local/share/emacs/site-lisp/mu4e/")
(setq mu4e-mu-binary "/usr/local/bin/mu")
(setq mu4e-maildir "~/.maildir")
(setq mu4e-get-mail-command "offlineimap -o")
(setq mu4e-update-interval 300)
;; how often to call it in seconds:
;; or another choice of yours:
(setq mu4e-attachment-dir "~/Downloads")
;; rename files when moving - needed for mbsync:
(setq mu4e-change-filenames-when-moving t)
;; list of your email adresses:
(setq mu4e-user-mail-address-list '("xxx"))
(setq mu4e-maildir-shortcuts
'(("/cambridge/Inbox" . ?i)
("/cambridge/Archive" . ?i)
("/cambridge/Sent" . ?s)))
(setq mu4e-contexts
`(,(make-mu4e-context
:name "cambridge"
:enter-func
(lambda () (mu4e-message "Enter xxx context"))
:leave-func
(lambda () (mu4e-message "Leave xxx context"))
:match-func
(lambda (msg)
(when msg
(mu4e-message-contact-field-matches msg
:to "xxx")))
:vars '((user-mail-address . "xxx" )
(user-full-name . "xxx")
(mu4e-drafts-folder . "/xxx/Drafts")
(mu4e-refile-folder . "/xxx/Archive")
(mu4e-sent-folder . "/xxx/Sent")
(mu4e-trash-folder . "/xxx/Deleted Messages")))))
(defun exchange-mu4e-refile-folder (msg)
"Function for chosing the refile folder for my Exchange email.
MSG is a message p-list from mu4e."
(cond
((string-match "\\[some-mailing-list\\]"
(mu4e-message-field msg :subject))
"/xxx/Archive")
(t "/xxx/Archive")
)
)
(setq mu4e-sent-folder "/.maildir/xxx/Sent"
mu4e-drafts-folder "/.maildir/xxx/Drafts"
user-mail-address "xxx"
smtpmail-default-smtp-server "localhost"
smtpmail-smtp-server "localhost"
smtpmail-smtp-service 1025)
;; mu4e address completion
(add-hook 'mu4e-compose-mode-hook 'company-mode)
(setq org-mu4e-link-query-in-headers-mode nil)
;; don't have to confirm when quitting:
(setq mu4e-confirm-quit nil)
;; number of visible headers in horizontal split view:
(setq mu4e-headers-visible-lines 20)
;; don't show threading by default:
(setq mu4e-headers-show-threads nil)
;; hide annoying "mu4e Retrieving mail..." msg in mini buffer:
(setq mu4e-hide-index-messages t)
;; customize the reply-quote-string:
(setq message-citation-line-format "%N @ %Y-%m-%d %H:%M :\n")
;; M-x find-function RET message-citation-line-format for docs:
(setq message-citation-line-function 'message-insert-formatted-citation-line)
;; by default do not show related emails:
(setq mu4e-headers-include-related nil)
;; by default do not show threads:
(setq mu4e-headers-show-threads nil)
and this is my .offlineimaprc
[general]
accounts = sam
maxsyncaccounts = 1
[Account sam]
localrepository = local-sam
remoterepository = remote-sam
[Repository local-sam]
type = Maildir
localfolders = ~/.maildir/xxx
[Repository remote-sam]
type = IMAP
remotehost = localhost
remoteport = 1143
remoteuser = xxx
remotepass =
ssl = no
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
maxconnections = 1
realdelete = no
folderfilter = lambda foldername: foldername not in ['Trash']