XLIST | Blog | Limilabs https://www.limilabs.com/blog Using Limilabs .net components Fri, 24 Mar 2023 11:54:13 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 Common IMAP folders https://www.limilabs.com/blog/common-imap-folders Thu, 19 Apr 2012 14:56:18 +0000 http://www.limilabs.com/blog/?p=2647 There are no well-know names for common folders such as Drafts, Trash, Spam, … defined in IMAP protocol standards. This makes quite difficult for an IMAP client to know the real purpose of the folders on the server. Fortunately there are two IMAP protocol extensions: XLIST – supported by Gmail SPECIAL-USE – RFC 6154 standardized […]

The post Common IMAP folders first appeared on Blog | Limilabs.

]]>
There are no well-know names for common folders such as Drafts, Trash, Spam, … defined in IMAP protocol standards.

This makes quite difficult for an IMAP client to know the real purpose of the folders on the server.

Fortunately there are two IMAP protocol extensions:

You can check if your servers support it by checking if SupportedExtensions returns ImapExtension.XList or ImapExtension.SpecialUse

Both extensions are supported by Mail.dll and, if your server supports any of them, you can take advantage of CommonFolders class. CommonFolders allows you to get the name of the folder and Select it, by knowing its purpose (for example Spam folder may be called “Junk email” on the server).

// C# version:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("pat@gmail.com", "password");

    CommonFolders folders = new CommonFolders(imap.GetFolders());

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name);
    Console.WriteLine("Sent folder: " + folders.Sent.Name);
    Console.WriteLine("Spam folder: " + folders.Spam.Name);

    // You can select folders easy:
    imap.Select(folders.Inbox);
    imap.Select(folders.Sent);
    imap.Select(folders.Spam);

    imap.Close();
}
' VB.NET version:

Using imap As New Imap()
    imap.ConnectSSL("imap.gmail.com")
    imap.UseBestLogin("pat@gmail", "password")

    Dim folders As New CommonFolders(imap.GetFolders())

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name)
    Console.WriteLine("Sent folder: " + folders.Sent.Name)

    ' You can select folders easy:
    imap.Select(folders.Inbox)
    imap.Select(folders.Sent)


    imap.Close()
End Using

You can check if you can use CommonFolders with following code:

// C#

List<ImapExtension> extensions = client.SupportedExtensions();
bool canUseCommonFolders = extensions.Contains(ImapExtension.XList) 
    || extensions.Contains(ImapExtension.SpecialUse);
' VB.NET

Dim extensions As List(Of ImapExtension) = client.SupportedExtensions()
Dim canUseCommonFolders As Boolean = extensions.Contains(ImapExtension.XList) OrElse extensions.Contains(ImapExtension.SpecialUse)

The post Common IMAP folders first appeared on Blog | Limilabs.

]]>
Gmail extensions in Mail.dll https://www.limilabs.com/blog/gmail-extensions-in-mail-dll https://www.limilabs.com/blog/gmail-extensions-in-mail-dll#comments Mon, 13 Jun 2011 13:05:11 +0000 http://www.limilabs.com/blog/?p=1907 Here’s the list of Gmail IMAP protocol extensions implemented in Mail.dll: Extension of the LIST command: XLIST Extension of the SEARCH command: X-GM-RAW Access to the Gmail unique message ID: X-GM-MSGID Access to the Gmail thread ID: X-GM-THRID Access to Gmail labels: X-GM-LABELS OAuth and OAuth 2.0: XOAUTH, XOAUTH2 You can read on how to […]

The post Gmail extensions in Mail.dll first appeared on Blog | Limilabs.

]]>

Here’s the list of Gmail IMAP protocol extensions implemented in Mail.dll:

  • Extension of the LIST command: XLIST
  • Extension of the SEARCH command: X-GM-RAW
  • Access to the Gmail unique message ID: X-GM-MSGID
  • Access to the Gmail thread ID: X-GM-THRID
  • Access to Gmail labels: X-GM-LABELS
  • OAuth and OAuth 2.0: XOAUTH, XOAUTH2

You can read on how to use Mail.dll with Gmail in the following articles:

OAuth 2.0

OAuth 1.0

The post Gmail extensions in Mail.dll first appeared on Blog | Limilabs.

]]>
https://www.limilabs.com/blog/gmail-extensions-in-mail-dll/feed 1
IMAP: LIST, XLIST and LSUB https://www.limilabs.com/blog/imap-list-xlist-and-lsub Thu, 24 Jun 2010 15:11:52 +0000 http://www.limilabs.com/blog/?p=934 In IMAP protocol there are two commands to retrieve a folder list from the remote server. Most servers use LIST command, some servers support XLIST command (e.g. Gmail). XLIST provides additional folder flags such as Inbox or Spam (which are very useful if folder names are localized to know the purpose of the folder). Mail.dll […]

The post IMAP: LIST, XLIST and LSUB first appeared on Blog | Limilabs.

]]>
In IMAP protocol there are two commands to retrieve a folder list from the remote server. Most servers use LIST command, some servers support XLIST command (e.g. Gmail).

XLIST provides additional folder flags such as Inbox or Spam (which are very useful if folder names are localized to know the purpose of the folder).

Mail.dll automatically uses XLIST if it is supported by the server. You can read more about XLIST here:
/blog/localized-gmail-imap-folders

Unfortunately when you ask for subscribed folders with LSUB command, those additional flags are not send by the server. There is no such thing as XLSUB command.

The only way to workaround this limitation is to first download all folders with flags using XLIST, then use LSUB to get subscribed folders and finally match the flags by name.

The post IMAP: LIST, XLIST and LSUB first appeared on Blog | Limilabs.

]]>
Localized Gmail IMAP folders https://www.limilabs.com/blog/localized-gmail-imap-folders https://www.limilabs.com/blog/localized-gmail-imap-folders#comments Mon, 22 Mar 2010 18:57:55 +0000 http://www.limilabs.com/blog/?p=700 There are no well-know names for common folders such as Drafts, Trash, Spam, … on IMAP servers. The problem is even worse when you use localized version of IMAP client. Gmail folder names are localized with respect to the user localization settings, so ‘[Gmail]/All Mail’ show as ‘[Gmail]/Todos’ to Spanish users for example. Google and […]

The post Localized Gmail IMAP folders first appeared on Blog | Limilabs.

]]>


There are no well-know names for common folders such as Drafts, Trash, Spam, … on IMAP servers.

The problem is even worse when you use localized version of IMAP client. Gmail folder names are localized with respect to the user localization settings, so ‘[Gmail]/All Mail’ show as ‘[Gmail]/Todos’ to Spanish users for example.

Google and Apple developed a special IMAP XLIST command to address this issue.

IMAP XLIST command returns a list of folders and their well-know flags.

Here’s the sample XLIST response:


C: A001 CAPABILITY
S: * CAPABILITY IMAP4rev1 ID XLIST ...
S: A001 OK Thats all she wrote! 17if1168678ebj.35
C: A002 XLIST "" "*"
S: * XLIST (\HasNoChildren \Inbox) "/" "Inbox"
S: * XLIST (\HasNoChildren \AllMail) "/" "[Gmail]/All Mail"
S: * XLIST (\HasNoChildren \Drafts) "/" "[Gmail]/Drafts"
S: * XLIST (\HasNoChildren \Spam) "/" "[Gmail]/Spam"
...

As you can see XLIST is advertised in CAPABILITY response.
You can probably spot additional flags in the XLIST response: \AllMail, \Spam, \Drafts…

Mail.dll IMAP library supports XLIST command (and SPECIAL-USE extension). It is used automatically when server advertises support for this feature.

You can use CommonFolders class to match folder names with they real purpose.

Take a look at the examples:

// C# version:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("pat@gmail.com", "app-password");

    CommonFolders folders = new CommonFolders(imap.GetFolders());

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name);
    Console.WriteLine("Sent folder: " + folders.Sent.Name);

    // You can select folders easy:

    imap.Select(folders.Inbox);
    imap.Select(folders.Sent);

    imap.Close();
}
' VB.NET version:

Using imap As New Imap()
    imap.ConnectSSL("imap.gmail.com")
    imap.UseBestLogin("pat@gmail", "app-password")

    Dim folders As New CommonFolders(imap.GetFolders())

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name)
    Console.WriteLine("Sent folder: " + folders.Sent.Name)

    ' You can select folders easy:

    imap.Select(folders.Inbox)
    imap.Select(folders.Sent)

    imap.Close()
End Using

Remember to enable IMAP in Gmail (your authentication options are app-passwords and OAuth 2.0).

The post Localized Gmail IMAP folders first appeared on Blog | Limilabs.

]]>
https://www.limilabs.com/blog/localized-gmail-imap-folders/feed 3