Search code examples
gmail-apiservice-accountsgetmessage

Gmail API .NET: Get full message


How do I get the full message and not just the metadata using gmail api?

I have a service account and I am able to retrieve a message but only in the metadata, raw and minimal formats. How do I retrieve the full message in the full format? The following code works fine

var request = service.Users.Messages.Get(userId, messageId);
request.Format = UsersResource.MessagesResource.GetRequest.FormatEnum.Metadata;
Message message = request.Execute();

However, when I omit the format (hence I use the default format which is FULL) or I change the format to UsersResource.MessagesResource.GetRequest.FormatEnum.Full I get the error: Metadata scope doesn't allow format FULL

I have included the following scopes:

https://www.googleapis.com/auth/gmail.readonly, 
https://www.googleapis.com/auth/gmail.metadata,
https://www.googleapis.com/auth/gmail.modify,
https://mail.google.com/

How do I get the full message?


Solution

  • I had to remove the scope for the metadata to be able to get the full message format.