This project is read-only.

Work with GMAIL on folder name that include white space

Oct 16, 2012 at 2:00 PM

Hi!

Another one question about work with IMAP GMAIL.

Can i get messages from folder "[GMail]/All Mail" 

Using cl As ImapClient = New ImapClient("imap.gmail.com")
 cl.SelectFolder("[Gmail]/All Mail")
End Using

This code doesn't work, I think it because I use GMAIL on russian and this folder name is

"[Gmail]/Вся почта".

But code

Using cl As ImapClient = New ImapClient("imap.gmail.com")
 cl.SelectFolder("[Gmail]/Вся почта")
End Using

doesn't work too :(

And if I use  cl.GetAllFolders(),  Flags   -  Error No children available.

Oct 17, 2012 at 1:12 AM

Hi.

I can not reproduct your bug.
I can receive mail of Japanese folder by below code.
------------------------------------------------------------------------------------------------------------------------
            using (ImapClient cl = new ImapClient("imap.gmail.com", 993, "xxx@gmail.com", "xxxxxx"))
            {
                cl.Ssl = true;
                if (cl.Authenticate() == true)
                {
                    ImapFolder r = cl.SelectFolder("[Gmail]/すべてのメール");
                    var mg = cl.GetMessage(1);
                }
            }
------------------------------------------------------------------------------------------------------------------------
Is there any way I can get russian account of GMail?

Oct 17, 2012 at 7:39 AM

You can set Gmail display language to Russian in Gmail Settings, but If I set "Gmail display language"  to English and run -  cl.SelectFolder("[Gmail]/All Mail") , I receive error too.

After cl.GetAllFolders() function call,  I get strange results for "[Gmail]/All Mail" folder: 

Name = "[Gmail]/All Mail" 

NoSelect = True

Why this value is equal to True?   For "INBOX" folder this value is  equal to False and all OK. 

Oct 18, 2012 at 6:49 AM

I could not reproduct your bug.

1.Change settings to Русский
2.Execute this code

---------------------------------------------------------------------------------------------------------------------------------
            using (ImapClient cl = new ImapClient("imap.gmail.com", 993, "myaccount@gmail.com", "mypass"))
            {
                cl.Ssl = true;
                if (cl.Authenticate() == true)
                {
                    var l = cl.GetAllFolders();
                    ImapFolder r = cl.SelectFolder(l[6].Name);
                    var mg = cl.GetMessage(1);
                }
            }
---------------------------------------------------------------------------------------------------------------------------------
I can get MailMessage object.

If you can, please give me your code that actually you executed.
And please make sure that your IMAP enable on GMail settings.

I appreciate other your information.

 

Oct 18, 2012 at 7:15 PM
Edited Oct 18, 2012 at 7:24 PM

My code:

Using cl As ImapClient = New ImapClient("imap.gmail.com")
         cl.Port = 993
         cl.Ssl = True
         cl.UserName = GetParamValue("UserName")
         cl.Password = GetParamValue("Password")
         If cl.Authenticate() Then
                    'Select folder
                    Dim allFolder = cl.GetAllFolders()
                    Dim aa As ImapFolder =  cl.SelectFolder(allFolder(8).Name) '[Gmail]/Вся почта'
	 End If
End Using
When execute cl.SelectFolder(allFolder(8).Name) -  I have error
StackTrace: "HigLabo.Net.Imap.ImapClient.GetSelectResult(String folderName, String text)      HigLabo.Net.Imap.ImapClient.ExecuteSelect(String folderName)      HigLabo.Net.Imap.ImapClient.SelectFolder(String folderName)  
If I use cl.SelectFolder("INBOX") - all OK! 
Oct 19, 2012 at 8:34 AM

Hi.

I add ReqeustEncoding property to ImapClient class.
Please set UTF-8 and test it.

Oct 22, 2012 at 10:28 AM

Good day.

cl.RequestEncoding = System.Text.UTF8Encoding.UTF8

All the same I have the error :(((

Oct 22, 2012 at 11:03 AM

I want to know the value of text.
Please tell me actual this value.

StackTrace:
"HigLabo.Net.Imap.ImapClient.GetSelectResult(String folderName, String text)
HigLabo.Net.Imap.ImapClient.ExecuteSelect(String folderName)
HigLabo.Net.Imap.ImapClient.SelectFolder(String folderName)

Oct 22, 2012 at 11:48 AM

  cl.SelectFolder("[Gmail]/Вся почта") 

StackTrace is the same

   HigLabo.Net.Imap.ImapClient.GetSelectResult(String folderName, String text)    

HigLabo.Net.Imap.ImapClient.ExecuteSelect(String folderName) 

 HigLabo.Net.Imap.ImapClient.SelectFolder(String folderName)   

Oct 23, 2012 at 1:19 AM

I want to know the value of text parameter of GetSelectResult method.
StackTrace: HigLabo.Net.Imap.ImapClient.GetSelectResult(String folderName, String text)

text include actual response text from server.
It may bring us to solve this problem.

regards.

Dec 12, 2013 at 1:56 AM
Finally, I found out that the white space is the reason and must quote like "My Folder Name" when sending a comand to imap mail server.

I fixed it and upload new version.
Please check it out!