2

I am attempting to instantiate an MSGraph ItemAttachment object in order to attach a Message object to another Message object. I've tried the following:

            var itemAttachment = new ItemAttachment
            {
                Item = message,
                //Size = ??,
                ContentType = "message/rfc822",
                Id = Guid.NewGuid().ToString(),
                IsInline = false,
                Name = "OrderMessage.msg",
                ODataType = message.ODataType,
                LastModifiedDateTime = DateTimeOffset.Now
            };
            errorMessage.Attachments.Add(itemAttachment);

Fiddler tells me this produces the error: "The property 'item' does not exist on type 'Microsoft.OutlookServices.Attachment'. Make sure to only use property names that are defined by the type or mark the type as open type."

I've also tried:

            var itemAttachment = new ItemAttachment
            {
                Item = message,
                //Size = ??,
                ContentType = "message/rfc822",
                Id = Guid.NewGuid().ToString(),
                IsInline = false,
                Name = "OrderMessage.msg",
                ODataType = "#microsoft.graph.itemAttachment",
                LastModifiedDateTime = DateTimeOffset.Now
            };
            errorMessage.Attachments.Add(itemAttachment);

Fiddler tells me that this produces the error: "The annotation 'odata.context' was found. This annotation is either not recognized or not expected at the current position."

I've tried several other variations of these, and nothing works. Can anyone tell me how this is supposed to work?

Thanks.

Chuck

Chuck
  • 55
  • 5

1 Answers1

0

I had a similar problem with Microsoft Graph Mail Attachment --- see Microsoft.Graph send mail with attachment as this might be helpful. Tim:

Community
  • 1
  • 1
twc
  • 449
  • 1
  • 3
  • 12
  • Thanks for the reference, but that is about FileAttachment and I have that working fine already. My current problem is with ItemAttachement which is specifically designed for attaching Outlook items such as messages, contacts, calendar items, etc. – Chuck Apr 26 '17 at 01:58
  • Ok, I'm interested as well to how this works as I thought FileAttachment was basically the same as ItemAttachment which was in the MessageAttachmentsCollectionPage attachments = new MessageAttachmentsCollectionPage() so I would just change FileAttachement to ItemAttachment. Hopefully, Microsoft can help here. Tim: – twc Apr 26 '17 at 09:38