I found that some of IMAP mail servers send different response to command FETCH BODYSTRUCTURE.
This client expects that all named RegEx values will be send back, eg:
("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "8bit" 502 19 NIL NIL NIL)
but sometimes last three NILs are skipped, eg:
("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "8bit" 502 19)
I fixed it by changing RegEx non_attach constant value in ImapMessageBodyPart.cs to the new value:
const string non_attach = "^\\((?<type>(\"[^\"]*\"|NIL))\\s(?<subtype>(\"[^\"]*\"|NIL))\\s(?<attr>(\\([^\\)]*\\)|NIL))\\s(?<id>(\"[^\"]*\"|NIL))\\s(?<desc>(\"[^\"]*\"|NIL))\\s(?<encoding>(\"[^\"]*\"|NIL))\\s(?<size>(\\d+|NIL))\\s(?<lines>(\\d+|NIL))\\s?(?<md5>(\"[^\"]*\"|NIL))?\\s?(?<disposition>(\\([^\\)]*\\)|NIL))?\\s?(?<lang>(\"[^\"]*\"|NIL))?\\)$";
After that change last three NILs are optional.
That forced extra change to the ParseNIL(string data) function. New body of it:
data = data.Trim();
if (data == "NIL" || data == string.Empty)
return null;
return data;
I'm not 100% sure if these changes are not against some standards but I had been made tests of this IMAP server with Outlook and Thunderbird and all went fine so I decided to write about this here.
AP2
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I found that some of IMAP mail servers send different response to command FETCH BODYSTRUCTURE.
This client expects that all named RegEx values will be send back, eg:
("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "8bit" 502 19 NIL NIL NIL)
but sometimes last three NILs are skipped, eg:
("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "8bit" 502 19)
I fixed it by changing RegEx non_attach constant value in ImapMessageBodyPart.cs to the new value:
const string non_attach = "^\\((?<type>(\"[^\"]*\"|NIL))\\s(?<subtype>(\"[^\"]*\"|NIL))\\s(?<attr>(\\([^\\)]*\\)|NIL))\\s(?<id>(\"[^\"]*\"|NIL))\\s(?<desc>(\"[^\"]*\"|NIL))\\s(?<encoding>(\"[^\"]*\"|NIL))\\s(?<size>(\\d+|NIL))\\s(?<lines>(\\d+|NIL))\\s?(?<md5>(\"[^\"]*\"|NIL))?\\s?(?<disposition>(\\([^\\)]*\\)|NIL))?\\s?(?<lang>(\"[^\"]*\"|NIL))?\\)$";
After that change last three NILs are optional.
That forced extra change to the ParseNIL(string data) function. New body of it:
data = data.Trim();
if (data == "NIL" || data == string.Empty)
return null;
return data;
I'm not 100% sure if these changes are not against some standards but I had been made tests of this IMAP server with Outlook and Thunderbird and all went fine so I decided to write about this here.
AP2