I have looked everywhere and continue the dead end.
I am trying to use the Google APIs to load gmail into a C # plugin and then put it in the generated mail objects class that the parent program can understand.
I got the ability to download messages, and I can get everything except the actual body of the email, which is deeply immersed in the MessagePart payload structure.
What I need is a way to convert parts of the payload to Richtext or HTML, if possible, or plain text, if not.
At the moment, I do not need any attachments of the images to go through, just the text in the body.
GmailService gs = new GmailService(new Google.Apis.Services.BaseClientService.Initializer() { ApplicationName = Constant.clientId, HttpClientInitializer = credential });
UsersResource.MessagesResource messagesResource = gs.Users.Messages;
IList<Message> messages = messagesResource.List(userGmail.Value).Execute().Messages;
foreach (Message message in messages)
{
String messageID = message.Id;
ReceivedGmail check = ObjectSpace.RetrieveObjectByKeyProperty<ReceivedGmail>(messageID);
if (check == null)
{
messagesResource.Get(userGmail.Value, messageID).Format = UsersResource.MessagesResource.GetRequest.FormatEnum.Raw;
Message mail = messagesResource.Get(userGmail.Value, messageID).Execute();
MessagePart mailbody = mail.Payload;
ReceivedGmail gmail = new ReceivedGmail() { User = User.CurrentUser, Unread = true, mailID = messageID };
ObjectSpace.StoreObject<ReceivedGmail>(gmail);
}
}
Any help on how to get the data I need to add to gmail.body would be greatly appreciated.