A couple of issues that arose while working with Gmail, and the fixes that I made (please tell me if there are better fixes - these seem to work, but I'm no expert :)):
1) The ParseMessages function in ImapCommand was not parsing flags, so I changed line 608 from:
if ((match = Regex.Match(responses[i], @"\(FLAGS \(([^\)]*)\)")).Success)
to:
if ((match = Regex.Match(responses[i], @"FLAGS \(([^\)]*)")).Success)
removing the opening and closing \( seemed to do the trick.
2) Upon setting the deleted flag for a message, Gmail returns more than 1 line beginning with a *, and therefore subsequent calls fail because the extra output isn't getting read before moving on. Also, it is possible that a response of BAD is received, but would be interpreted as a success, because no check is made, only the check for the beginning *
Fix (SetFlag in ImapCommand, line 556):
if (response.StartsWith("*"))
{
Connection.Read();
return true;
}
...
becomes:
if (response.StartsWith("*"))
{
if (!response.Contains("BAD")) //we could have a failure
{
while (response.StartsWith("*"))
{
response = Connection.Read(); //read the whole response
}
return true;
}
else
{
return false;
}
}
Any and all comments/suggestions/corrections are certainly welcome :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A couple of issues that arose while working with Gmail, and the fixes that I made (please tell me if there are better fixes - these seem to work, but I'm no expert :)):
1) The ParseMessages function in ImapCommand was not parsing flags, so I changed line 608 from:
if ((match = Regex.Match(responses[i], @"\(FLAGS \(([^\)]*)\)")).Success)
to:
if ((match = Regex.Match(responses[i], @"FLAGS \(([^\)]*)")).Success)
removing the opening and closing \( seemed to do the trick.
2) Upon setting the deleted flag for a message, Gmail returns more than 1 line beginning with a *, and therefore subsequent calls fail because the extra output isn't getting read before moving on. Also, it is possible that a response of BAD is received, but would be interpreted as a success, because no check is made, only the check for the beginning *
Fix (SetFlag in ImapCommand, line 556):
if (response.StartsWith("*"))
{
Connection.Read();
return true;
}
...
becomes:
if (response.StartsWith("*"))
{
if (!response.Contains("BAD")) //we could have a failure
{
while (response.StartsWith("*"))
{
response = Connection.Read(); //read the whole response
}
return true;
}
else
{
return false;
}
}
Any and all comments/suggestions/corrections are certainly welcome :)