This project is read-only.


Jul 16, 2013 at 6:43 PM
Thank you very much for creating such a valuable api.
I just started using it and the only problem that I am having
is that I can't get the method CopyMessageToFolder from the Folder.cs
class to work.

I'm looking to assign a "label" to an email.
I was able to use the method CreateFolder to create a label, but not the CopyMessageToFolder.

Is there any way that you can provide some sample code to assign a label/folder to an email?

Thank you
Jul 16, 2013 at 10:00 PM
Hi raramuri,

the CopyMessageToFolder method can only be used to copy messages from one standard folder to another.

I guess you're using the library with a Gmail account, don't you?

On GMail there are certain extensions to the IMAP protocol implemented. I'm currently working on providing access to GMail labels in ImapX, and could put a sample for you together.

Please let me know if it's what you need.

Kind regards,

Pavel Azanov
Jul 16, 2013 at 10:14 PM
Thanks for your reply Pavel,

Yes, that's exactly what I'm using, a gmail account with google apps.

That would be exactly what I need. I'm looking to be able to tag an email with a gmail label (after I have read and used the information in the email).

Thanks again!
Jul 19, 2013 at 5:03 PM
Okay, i'm going to update the source code in the next days, will let you know when the required changes are available!
Jul 20, 2013 at 6:20 AM
Thank you so much Pavel,

I am looking forward to the new code / dll !
Jul 25, 2013 at 12:10 PM
Hi raramuri,

i updated the source code in the repository. You can now access the labels through the Labels property of a message and modify them using the Labels.Add/AddRange and Labels.Remove/RemoveRange methods.

The code is not tested. I'd like to ask you giving it a try. I'm happy about all kind of feedback.

Best regards,

Pavel Azanov
Jul 26, 2013 at 2:58 AM
Hi Pavel,

I really appreciate it. I will begin testing it tomorrow and will let you know if I find any issues!
Jul 31, 2013 at 8:37 PM
Hi raramuri,

how are your tests running? Any issues you have experienced or suggestions you have?


Pavel Azanov
Jul 31, 2013 at 9:26 PM
Hi Pavel,

Thanks for the message. I have not been able to test it yet. However, I will start testing this week and will update you as soon as I do.
I do apologize for the delay.
Aug 1, 2013 at 7:58 PM
Hi raramuri,

that's okay, no reason to apologize.
I just want to tell you there was another update of the code, with a bugfix for message flag and label handling, please use the latest version for tests.
Aug 1, 2013 at 8:48 PM
You're very kind Pavel,

Thanks for informing me of the update.
Aug 5, 2013 at 5:56 AM
Hi Pavel,

I was able to test the new code that you uploaded. Let me give you my feedback.

It works. I am able to assign labels, but there is a question that I have for you.

If my label in Gmail includes spaces, your method is parsing the string as separate word, and multiple labels are being created and added to the message.

If my Gmail label is called Inventory Checked, then two labels are added to the message (Inventory and Checked).

From what i am able to tell, this code is coming from the method AddRange in class MessageFlagCollection.
Of course, the obvious solutions in my end is to rename my labels to not include spaces.

Thank you
Aug 5, 2013 at 8:46 AM
Hi raramuri,

Thank you for feedback!

I didn't test the code with labels containing spaces, and it's definitely an issue if there are labels added instead of one.
I'll look deeper into it and will provide a fix for that.

Best regards,

Pavel Azanov
Aug 5, 2013 at 9:52 PM
Edited Aug 5, 2013 at 9:53 PM
Its' my pleasure Pavel.

Another thing that I have noticed is that in some instances, the label \Seen
gets added to the message, as well as the new one that I am adding.

I traced this, and I believe this occurs whenever I set the Flag Seen before I set my label.

In order to prevent the label \Seen to be added, I set my custom Label before I add the flag SEEN.

Aug 6, 2013 at 10:15 PM
Hi raramuri,

I fixed all the issues you mentioned. Please check the latest code.
Aug 8, 2013 at 11:01 PM
Thank you Pavel for the quick work. I will test it by latest this weekend.
Aug 9, 2013 at 11:50 AM
Thank you! Waiting for feedback.

I also will provide support for another GMail feature soon - the message threads (which combine messages like in the web interface). The code is already working, just need to do some minor changes to the message processing, before will make a new stable release.
Aug 14, 2013 at 4:47 PM
Edited Aug 14, 2013 at 5:18 PM
Hi, im using commit: 29867 (latest as of today) compiled for .net 3.5 and while i can assign labels i cant remove them.

Im looking for an easy way to filter out emails which have already been processed by my app. ideally i would want to move them to a different folder so theyre no longer in my inbox

if i remove a label ive set myself in gmail the function returns true (but isnt actually removed) and if i try to remove the "Inbox" label it fails. However, removing the label i set in code works.

        public bool setLabel(ImapX.Message msg, string label)
                if (!msg.Labels.Add(label))
                    return false;
                if (!msg.Labels.Remove("Inbox")) // fails
                    return false;
            catch (Exception) { return false; }
            return true;
if (!msg.Labels.Remove("mylabel")) // returns true but label isnt removed (label is set in gmail web client)
                    return false;
if (!msg.Labels.Remove(label)) // works 
                    return false;

Am i doing something wrong?

as for the inbox label failing, perhaps this can give a clue as to why
Aug 15, 2013 at 9:36 AM
Hi thesquig,

currently i can say for sure that you can add and remove custom labels.

If it comes to labels like "Inbox", are you sure the labels collection contains it? I didn't see this label while testing the code, and I'd suggest it is not treated as label in this case, and you need the MoveMessageToFolder method to move messages to another folder.

I'll take a look at it and go through the documentation one more time and let you know the results.

Thank you for feedback!

Kind regards,