Discussion:
[VM] Finding IMAP mailboxes that have new/unread mail
Konrad Hinsen
2011-12-18 16:21:36 UTC
Permalink
Hi everyone,

I am trying to use VM for my daily e-mail handling, which mostly involves
an IMAP account with > 100 mailboxes. Messages are sorted into those
mailboxes by the server, so any mailbox is likely to contain new mail at
any time. Is there any way to make VM tell me which mailboxes have new
messages? It would also be nice, though less important, to be able to scan
for mailboxes with unread messages.

Thanks in advance,
Konrad.
Uday S Reddy
2011-12-18 16:59:50 UTC
Permalink
Post by Konrad Hinsen
I am trying to use VM for my daily e-mail handling, which mostly involves
an IMAP account with > 100 mailboxes. Messages are sorted into those
mailboxes by the server, so any mailbox is likely to contain new mail at
any time. Is there any way to make VM tell me which mailboxes have new
messages? It would also be nice, though less important, to be able to scan
for mailboxes with unread messages.
That seems to be a very useful piece of functionality. I will put it on the
wish list.

At the moment, what you can do is to use VM's virtual folder functionality
to combine all those mailboxes (or some selection, take your pick) into a
single virtual folder. Here is what I do to combine three IMAP mail boxes
"2011-3", "2011-4" and "INBOX" into a single virtual folder.

(defun mailhost-folder (name)
(format "imap:MAILHOST:143:%s:login:MYLOGIN:*" name))

(defun mailhost-folders (&rest names)
(mapcar 'mailhost-folder names))

(setq vm-virtual-folder-alist
`(
("current"
(,(mailhost-folders "2011-3" "2011-4" "INBOX")
(any)))
))

If you want to see only the new messages instead of all messages, replace
`any' in the last definition by `new'. (These are VM's virtual folder
selectors. You can use other selectors too, if you wish.)

Then, if you type V V current <RET>, you get to see a virtual folder called
`current' with all the messages.

Please let me know if it works for you.

Cheers,
Uday
Konrad Hinsen
2011-12-18 20:29:45 UTC
Permalink
Post by Uday S Reddy
That seems to be a very useful piece of functionality. I will put it on the
wish list.
At the moment, what you can do is to use VM's virtual folder functionality
to combine all those mailboxes (or some selection, take your pick) into a
single virtual folder. Here is what I do to combine three IMAP mail boxes
"2011-3", "2011-4" and "INBOX" into a single virtual folder.
That sounds like a very good solution for me, because it would allow
me to group my folders into more and less important ones.
Post by Uday S Reddy
Please let me know if it works for you.
Not yet, the virtual folder remains empty, even though I selected
"any" and incuded three well-filled mailboxes. But I guess I just got
the format for the alist wrong - I'll look at that tomorrow.

Is there a way to get the list of all IMAP folders in an account from
VM? Ideally, I'd like to build a virtual folder by selecting all
mailboxes from my account that match a given pattern.

Thanks,
Konrad.
Konrad Hinsen
2011-12-18 20:59:42 UTC
Permalink
Post by Konrad Hinsen
Not yet, the virtual folder remains empty, even though I selected
"any" and incuded three well-filled mailboxes. But I guess I just got
the format for the alist wrong - I'll look at that tomorrow.
Well, I am already lost. I tried the following:

(setq vm-virtual-folder-alist
`(
("virtual-inbox"
((,vm-primary-inbox)
(any)))
))

My understanding is that this should create a virtual folder with
exactly the same messages as my inbox (which is on an imap-ssl
account). It does create a virtual folder, but a folder that is always
empty.

If I use V-C from inside VM, I can create such a virtual folder and it
works. So the problem seems to be in the definition of
vm-virtual-folder-alist.

What am I doing wrong?

Konrad.
Uday S Reddy
2011-12-19 00:33:27 UTC
Permalink
Post by Konrad Hinsen
That sounds like a very good solution for me, because it would allow
me to group my folders into more and less important ones.
Excellent. Virtual folders are very powerful, but not everybody thought
about how it can help them.
Post by Konrad Hinsen
(setq vm-virtual-folder-alist
`(
("virtual-inbox"
((,vm-primary-inbox)
(any)))
))
My understanding is that this should create a virtual folder with
exactly the same messages as my inbox (which is on an imap-ssl
account). It does create a virtual folder, but a folder that is always
empty.
I tried this definition and it worked ok.

I was going to ask which version of VM you are using. This should work in
the latest release of VM, which is 8.2.0a. (It might also work in 8.1.93a,
according to the NEWS file, but not in older versions.)

Actually, since you are going to be the latest additions, it is best to get
the development version (the "trunk"). The README file gives you
instructions for setting up a bazaar sync, so that you can easily get the
latest updates. You will need bazaar, autoconf, configure and make tools to
download and compile this version. If you can't do that, you should
download 8.2.0a from the Launchpad web site.
Post by Konrad Hinsen
If I use V-C from inside VM, I can create such a virtual folder and it
works. So the problem seems to be in the definition of
vm-virtual-folder-alist.
The original virtual folder system didn't handle IMAP folders. I suspect
that is the problem you are facing.
Post by Konrad Hinsen
Is there a way to get the list of all IMAP folders in an account from
VM? Ideally, I'd like to build a virtual folder by selecting all
mailboxes from my account that match a given pattern.
M-x vm-imap-list-folders.

Another option is to set up the account on Thunderbird, and use its
facilities for listing folders. You can use VM and Thunderbird side by side
with IMAP folders and nothing ever goes wrong. (The only thing to keep in
mind is that Thunderbird updates the server almost immediately, whereas VM
updates it only when you do a save. So, the two views can be slightly
different.)

Cheers,
Uday
Konrad Hinsen
2011-12-20 07:57:07 UTC
Permalink
Post by Uday S Reddy
I was going to ask which version of VM you are using. This should work in
the latest release of VM, which is 8.2.0a. (It might also work in 8.1.93a,
according to the NEWS file, but not in older versions.)
Good catch, I was using 8.1.1. I just updated to 8.2.0a, and now my
virtual folders based on IMAP folders work fine. Thanks!

I discovered one inconvenient aspect though: opening a virtual folder
based on three IMAP folders first opens the three IMAP folders
individually. I end up having three frames on my screen that I need to
close one by one. I was planning to have a virtual folder regrouping
all new messages from about 20 mailing lists, but I don't think that's
a good idea.
Post by Uday S Reddy
Actually, since you are going to be the latest additions, it is best to get
the development version (the "trunk"). The README file gives you
instructions for setting up a bazaar sync, so that you can easily get the
latest updates. You will need bazaar, autoconf, configure and make tools to
download and compile this version. If you can't do that, you should
download 8.2.0a from the Launchpad web site.
For now it's 8.2, but I will look into the development branch later!
Post by Uday S Reddy
The original virtual folder system didn't handle IMAP folders. I suspect
that is the problem you are facing.
Indeed.
Post by Uday S Reddy
Post by Konrad Hinsen
Is there a way to get the list of all IMAP folders in an account from
VM? Ideally, I'd like to build a virtual folder by selecting all
mailboxes from my account that match a given pattern.
M-x vm-imap-list-folders.
Works fine as well - and this looks like a recent addition as well.

It's good to see that VM gets improved IMAP support!

Konrad.
Uday Reddy
2011-12-20 09:22:47 UTC
Permalink
Post by Konrad Hinsen
I discovered one inconvenient aspect though: opening a virtual folder
based on three IMAP folders first opens the three IMAP folders
individually. I end up having three frames on my screen that I need to
close one by one. I was planning to have a virtual folder regrouping
all new messages from about 20 mailing lists, but I don't think that's
a good idea.
You can configure the frame creation aspects in VM. See the "Frames and
Windows" section of the VM manual. I myself have `vm-mutable-frames' set to
nil because I don't like new frames being created willy nilly. There are
other variables you can use to get finer grained control on frame
configuration.

But I think you are right that opening a virtual folder shouldn't create a
frame for each underlying folder. I will tweak the code to avoid that.
Post by Konrad Hinsen
It's good to see that VM gets improved IMAP support!
Indeed, IMAP support is my main mission!

If you get the development branch, you will find `vm-list-imap-folders'
vastly improved as well.

Cheers,
Uday
Konrad Hinsen
2011-12-20 11:21:16 UTC
Permalink
Post by Uday Reddy
You can configure the frame creation aspects in VM. See the "Frames and
Windows" section of the VM manual. I myself have `vm-mutable-frames' set to
Thanks, I'll look at that.
Post by Uday Reddy
But I think you are right that opening a virtual folder shouldn't create a
frame for each underlying folder. I will tweak the code to avoid that.
Great.
Post by Uday Reddy
If you get the development branch, you will find `vm-list-imap-folders'
vastly improved as well.
I just installed the development branch, but found that
`vm-list-imap-folders' doesn't work at all there. The error message I get is

vm-imap-protocol-error: IMAP protocol error: "unexpected response to STATUS command"

It works fine in 8.2.0a.

Konrad.
blueman
2012-06-13 05:53:44 UTC
Permalink
Post by Uday Reddy
If you get the development branch, you will find `vm-list-imap-folders'
vastly improved as well.
Is there any difference between vm-list-imap-folders and
vm-imap-list-folders?

It's a cool function, btw.
It would be nice (wish list?), if one could 'click'/'select' on each
folder to open it...

Actually, more generally, it would be nice to be able to creat a
customizable list of local and IMAP folders displayed in a buffer that
could be selected/clicked upon to visit the corresponding folder.

Not sure how hard this would be to implement but presumable emacs has
the functionality to do it...
blueman
2012-06-13 05:56:29 UTC
Permalink
Post by blueman
Post by Uday Reddy
If you get the development branch, you will find `vm-list-imap-folders'
vastly improved as well.
Is there any difference between vm-list-imap-folders and
vm-imap-list-folders?
It's a cool function, btw.
It would be nice (wish list?), if one could 'click'/'select' on each
folder to open it...
Actually, more generally, it would be nice to be able to creat a
customizable list of local and IMAP folders displayed in a buffer that
could be selected/clicked upon to visit the corresponding folder.
Not sure how hard this would be to implement but presumable emacs has
the functionality to do it...
Ideally, it would be nice to be able to keep such a buffer with either
the most commonly visited (local & IMAP) folders and/or recently visited
folders [ideally customized based on alists or regex's] always OPEN on
the screen either as a separate frame or as a subwindow so that one can
always easily visit one's favorite and/or history folders...

Continue reading on narkive:
Search results for '[VM] Finding IMAP mailboxes that have new/unread mail' (Questions and Answers)
143
replies
What would make you switch your email provider, either on desktop or phone?
started 2015-05-27 11:11:23 UTC
internet
Loading...