I download the attachment(the nested mail) and want to bring it back into a "Microsoft.Graph.Models.Message"-class so I can iterate over it.
What format is the message you downloaded in eg did you use $value and get the MimeContent of the Message, if so there is no way of converting it directly back into the Message class without uploading to the server (eg create a draft and then access back the draft). If you have an EML/Mime message and you need to iterated on that message then you would be better of using a MIME library like Mime/MaiKit http://www.mimekit.net/ . If you have the ItemAttachment in it Native Json format (or you just saved the Message of and left it in Json it pretty easy to deserialize it back with the Kiota SDK's eg
string itemAttachmentjsonMessage = @"{
""@odata.context"":""https://graph.microsoft.com/v1.0/$metadata#users('d1a2fae9-db66-4cc9-8133-2184c77af1b8')/messages('AAMkADA1M-zAAA%3D')/attachments/$entity"",
""@odata.type"":""#microsoft.graph.itemAttachment"",
""id"":""AAMkADA1MCJKtzmnlcqVgqI="",
""lastModifiedDateTime"":""2017-07-21T00:20:34Z"",
""name"":""Reminder - please bring laptop"",
""contentType"":null,
""size"":32005,
""isInline"":false,
""item"":{
""@odata.type"":""#microsoft.graph.message"",
""id"":"""",
""createdDateTime"":""2017-07-21T00:20:41Z"",
""lastModifiedDateTime"":""2017-07-21T00:20:34Z"",
""receivedDateTime"":""2017-07-21T00:19:55Z"",
""sentDateTime"":""2017-07-21T00:19:52Z"",
""hasAttachments"":false,
""internetMessageId"":""<BY2PR15MB05189A084C01F466709E414F9CA40@BY2PR15MB0518.namprd15.prod.outlook.com>"",
""subject"":""Reminder - please bring laptop"",
""body"":{
""contentType"":""html"",
""content"":""<html><head>\r\n</head>\r\n<body>\r\n</body>\r\n</html>""
},
""sender"":{
""emailAddress"":{
""name"":""Adele Vance"",
""address"":""AdeleV@contoso.onmicrosoft.com""
}
},
""from"":{
""emailAddress"":{
""name"":""Adele Vance"",
""address"":""AdeleV@contoso.onmicrosoft.com""
}
},
""toRecipients"":[
{
""emailAddress"":{
""name"":""Alex Wilbur"",
""address"":""AlexW@contoso.onmicrosoft.com""
}
}
],
""ccRecipients"":[
{
""emailAddress"":{
""name"":""Adele Vance"",
""address"":""AdeleV@contoso.onmicrosoft.com""
}
}
],
""flag"":{
""flagStatus"":""notFlagged""
}
}
}";
//Desearlize it back
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(itemAttachmentjsonMessage));
var parseNodeFactory = new JsonParseNodeFactory();
var parseNode = parseNodeFactory.GetRootParseNode(CoreConstants.MimeTypeNames.Application.Json, memoryStream);
var parsedAttachment = parseNode.GetObjectValue<ItemAttachment>(ItemAttachment.CreateFromDiscriminatorValue);
if(parsedAttachment.Item is Message)
{
Console.WriteLine(((Message)parsedAttachment.Item).Subject);
}
```