none
BeforeAttachmentsave event is not fired? RRS feed

  • Question

  • I have written the code below but my BeforeAttachmentsave event not fired when i am trying to save the attached event, Where am i doing mistake?

    Open event is firing successfully. what am i doing wrong here?

    public static void Inspectors_NewInspector(Inspector Inspector)
            {
                object o = Inspector.CurrentItem;
                if (o is Microsoft.Office.Interop.Outlook.MailItem)
                {
                    Microsoft.Office.Interop.Outlook.MailItem mailItem =
                        (o as Microsoft.Office.Interop.Outlook.MailItem);
                    mailItem.BeforeAttachmentSave+= new ItemEvents_10_BeforeAttachmentSaveEventHandler(mailItem_BeforeAttachmentSave);
                    mailItem.Open+=new ItemEvents_10_OpenEventHandler(mailItem_Open);                
                    //if (mailItem.Attachments.Count > 0)
                    //    MessageBox.Show(mailItem.Attachments[0].FileName);

                }
            }

    Wednesday, January 1, 2014 8:05 PM

Answers

  • Hi Amit,

    Which version of Outlook are you developing with? Did this event never occur? Have you ever added a break point to make sure about this?

    I tested the code in Outlook 2013, this event will occur when I insert an attachment.

    This event corresponds to when attachments are saved to the messaging store. The BeforeAttachmentSave event occurs just before an attachment is saved when an item is saved. If a user edits an attachment and then saves those changes, the BeforeAttachmentSave event will not occur at that time; instead it will occur when the item itself is later saved. It also does not occur when the attachment is saved on the hard disk using the SaveAsFile method.( Refer to BeforeAttachmentSave Event)

    Best 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, January 2, 2014 10:07 AM
    Moderator
  • Hello Amit,

    Unfortunately the Outlook Object Model doesn't provide any event for detecting when the attachment is saved on disk.

    Could you please continue discussing your issue in the single forum thread don't create duplicates?

    Thursday, January 2, 2014 11:17 AM

All replies

  • Hi Amit,

    Which version of Outlook are you developing with? Did this event never occur? Have you ever added a break point to make sure about this?

    I tested the code in Outlook 2013, this event will occur when I insert an attachment.

    This event corresponds to when attachments are saved to the messaging store. The BeforeAttachmentSave event occurs just before an attachment is saved when an item is saved. If a user edits an attachment and then saves those changes, the BeforeAttachmentSave event will not occur at that time; instead it will occur when the item itself is later saved. It also does not occur when the attachment is saved on the hard disk using the SaveAsFile method.( Refer to BeforeAttachmentSave Event)

    Best 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, January 2, 2014 10:07 AM
    Moderator
  • Hello Amit,

    Unfortunately the Outlook Object Model doesn't provide any event for detecting when the attachment is saved on disk.

    Could you please continue discussing your issue in the single forum thread don't create duplicates?

    Thursday, January 2, 2014 11:17 AM