I\'m using the Gmail API and basically I would like to connect to my GMail account to read my emails, of INBOX categ
First: up-vote @codexer 's answer.
Second, use the following function in his code to decode the base64URL encoded body. Google not only base64 encoded the body, it is also URL encoded :-/
///
/// Turn a URL encoded base64 encoded string into readable UTF-8 string.
///
/// base64 URL ENCODED string.
/// UTF-8 formatted string
private string DecodeURLEncodedBase64EncodedString(string sInput)
{
string sBase46codedBody = sInput.Replace("-", "+").Replace("_", "/").Replace("=", String.Empty); //get rid of URL encoding, and pull any current padding off.
string sPaddedBase46codedBody = sBase46codedBody.PadRight(sBase46codedBody.Length + (4 - sBase46codedBody.Length % 4) % 4, '='); //re-pad the string so it is correct length.
byte[] data = Convert.FromBase64String(sPaddedBase46codedBody);
return Encoding.UTF8.GetString(data);
}