locked
How to get GetAttachmentTable from AssociatedContents for Inbox programatically using EWS RRS feed

  • Question

  • hi,

    I have a requirement to pull GetAttachmentTable from AssociatedContents for Inbox programatically using EWS.

    We have a Add-In added to user Outlook, which is storing some key information under GetAttachmentTable. Using Outlook Spy i can read that information by following the steps:

    1. Select the Inbox folder in Outlook
    2. Click the OutlookSpy tab in the Outlook Ribbon
    3. Click the “IMAPIFolder” button under the OutlookSpy tab
    4. In the “IMAPIFolder – Inbox” window that pops up, click the “Associated Contents” tab
    5. In the list of items on the left of the “Associated Contents” tab, select the desired entry under SetColumns, and double click on it.
    6. In the resulting “IMessage” window, click the “GetAttachmentTable” tab
    7. In the “GetAttachmentTable” tab, double-click the ***.xml attachment on the left hand side of the window

    Below is the screenshot from Outllokspy to get to the GetAttachmenttable

    IMAPIFolder screenshot

    I need help to how to access GetAttachmenttable programatically using EWS.

    Any help and suggestions will be greatly appreciated.

    Thanks


    ashishshukla.1183


    Thursday, April 7, 2016 9:06 PM

Answers

  • The closest thing would be something like

                String MailboxToAccess = "mailbox@domain.com";            
                FolderId FolderToAccess = new FolderId(WellKnownFolderName.Inbox, MailboxToAccess);
                ItemView ivItemView = new ItemView(1000);
                ivItemView.Traversal = ItemTraversal.Associated;
                PropertySet ItemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
                FindItemsResults<Item> FindItemResults = null;
                do
                {
                    FindItemResults = service.FindItems(FolderToAccess,  ivItemView);
                    if (FindItemResults.Items.Count > 0) 
                    {
                        service.LoadPropertiesForItems(FindItemResults.Items, ItemPropertySet);
                    }
                    foreach (Item itItem in FindItemResults.Items)
                    {
                        Console.WriteLine(itItem.Subject + " number of attachments " + itItem.Attachments.Count);
                        if (itItem.Attachments.Count > 0) 
                        {
                            foreach(Attachment Attachment in itItem.Attachments)
                            {
                                if (Attachment is FileAttachment)
                                {
                                    FileAttachment faFileAttachment = (FileAttachment)Attachment;
                                    Console.WriteLine(faFileAttachment.FileName);
                                }
                            }
                        }
    
                    }
                    ivItemView.Offset += FindItemResults.Items.Count;
                } while (FindItemResults.MoreAvailable);

    Where

    >> In the “IMAPIFolder – Inbox” window that pops up, click the “Associated Contents” tab

    Done using a AssoicatedItem Traversal  : ivItemView.Traversal = ItemTraversal.Associated;

    Then you just process the Messages returned as you would normal messages with attachments in EWS

    Cheers
    Glen

    Friday, April 8, 2016 4:44 AM

All replies

  • The closest thing would be something like

                String MailboxToAccess = "mailbox@domain.com";            
                FolderId FolderToAccess = new FolderId(WellKnownFolderName.Inbox, MailboxToAccess);
                ItemView ivItemView = new ItemView(1000);
                ivItemView.Traversal = ItemTraversal.Associated;
                PropertySet ItemPropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
                FindItemsResults<Item> FindItemResults = null;
                do
                {
                    FindItemResults = service.FindItems(FolderToAccess,  ivItemView);
                    if (FindItemResults.Items.Count > 0) 
                    {
                        service.LoadPropertiesForItems(FindItemResults.Items, ItemPropertySet);
                    }
                    foreach (Item itItem in FindItemResults.Items)
                    {
                        Console.WriteLine(itItem.Subject + " number of attachments " + itItem.Attachments.Count);
                        if (itItem.Attachments.Count > 0) 
                        {
                            foreach(Attachment Attachment in itItem.Attachments)
                            {
                                if (Attachment is FileAttachment)
                                {
                                    FileAttachment faFileAttachment = (FileAttachment)Attachment;
                                    Console.WriteLine(faFileAttachment.FileName);
                                }
                            }
                        }
    
                    }
                    ivItemView.Offset += FindItemResults.Items.Count;
                } while (FindItemResults.MoreAvailable);

    Where

    >> In the “IMAPIFolder – Inbox” window that pops up, click the “Associated Contents” tab

    Done using a AssoicatedItem Traversal  : ivItemView.Traversal = ItemTraversal.Associated;

    Then you just process the Messages returned as you would normal messages with attachments in EWS

    Cheers
    Glen

    Friday, April 8, 2016 4:44 AM
  • Actually this did help.

    Apparently i found out that the Add-in was storing some attachments in hidden messages.

    So I just had to query those hidden messages with specific Message ItemClass names and get the attachments.

    Thanks.


    ashishshukla.1183

    Monday, April 11, 2016 9:24 PM