none
Attachments in Outlook 2016 (Recent Items) RRS feed

  • Question

  • Hey guys,

    Just a quick question. I notice in Outlook 2016, when you an attach an item. It now has the drop down with the recent items. As talked about in the blog post.
    https://blogs.office.com/2015/11/09/attachments-in-outlook-2016-ready-for-collaboration/

    If I add an attachment by selecting a recent item rather than browsing and going to my location. This code seems to think there is no attachments?

    Attachments mailAttachments = mailItem.Attachments;
                var attachmentSizes = new List<int>();
                if (mailAttachments != null && mailAttachments.Count > 0)
                {

    //INSERT CODE

    }

    Basically it doesn't run the if statement.

    Wednesday, December 9, 2015 4:42 PM

Answers

  • I cannot reproduce this if I add an attachment from the drop down and then click Item button on the OutlookSpy ribbon and selecting Attachments | Count.

    Are you adding a blocked attachment type (e.g. exe) by any chance?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 9, 2015 11:11 PM
  • Hi Darryl,

    I am also failed to reproduce this issue in Outlook 2016. Here are the test steps for your reference:

    1. Create an Outlook VSTO add-in project

    2. Add an Ribbon Visual item and insert a button with code below then make this ribbon for the compose mode

      private void button1_Click(object sender, RibbonControlEventArgs e)
            {
                MailItem msg = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem;
                Attachments mailAttachments = msg.Attachments;
                var attachmentSizes = new List<int>();
                if (mailAttachments != null && mailAttachments.Count > 0)
                {
                    Debug.WriteLine("Attachments counts:" + mailAttachments.Count);
                    //INSERT CODE
                }
    
            }

    3. Run this project and new a email then insert the attachments with recent items.

    4. Then check the attachments count via clicking the button on the ribbon. The mailAttachments.Count is correct for this demo.

    I suggest that you try some normal file like text to see whether the issue was relative to file block mentioned with Dmitry. And please ensure that file was add successfully before you getting the numbers of attachments.

    In addition, would you mind share the detail attachment you added with us to help us to narrow down this issue?

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, December 10, 2015 3:10 AM
    Moderator

All replies

  • Hello Darryl,

    Did you try to call the Save method of the Attachment class before running the code mentioned? Does it help?

    Wednesday, December 9, 2015 5:46 PM
  • I cannot reproduce this if I add an attachment from the drop down and then click Item button on the OutlookSpy ribbon and selecting Attachments | Count.

    Are you adding a blocked attachment type (e.g. exe) by any chance?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 9, 2015 11:11 PM
  • Hey guys, I reproduced this. Was something my end.
    Thursday, December 10, 2015 2:29 AM
  • Hi Darryl,

    I am also failed to reproduce this issue in Outlook 2016. Here are the test steps for your reference:

    1. Create an Outlook VSTO add-in project

    2. Add an Ribbon Visual item and insert a button with code below then make this ribbon for the compose mode

      private void button1_Click(object sender, RibbonControlEventArgs e)
            {
                MailItem msg = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem;
                Attachments mailAttachments = msg.Attachments;
                var attachmentSizes = new List<int>();
                if (mailAttachments != null && mailAttachments.Count > 0)
                {
                    Debug.WriteLine("Attachments counts:" + mailAttachments.Count);
                    //INSERT CODE
                }
    
            }

    3. Run this project and new a email then insert the attachments with recent items.

    4. Then check the attachments count via clicking the button on the ribbon. The mailAttachments.Count is correct for this demo.

    I suggest that you try some normal file like text to see whether the issue was relative to file block mentioned with Dmitry. And please ensure that file was add successfully before you getting the numbers of attachments.

    In addition, would you mind share the detail attachment you added with us to help us to narrow down this issue?

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, December 10, 2015 3:10 AM
    Moderator