none
How to get mail attachment file count RRS feed

  • Question

  • Hi buddies,

    When after adding multiple attachment files to a new mail, i want to pop up a new form.
    I want to count the BeforeAttachmentAdd events according to the number of selected attachment files. 
    In the last BeforeAttachmentAdd event handler i can display my form.
    But i don't know how to achieve the selected attachment files count.
    Anybody knows this or has other solutions?

    Any hints or solutions will be appreciated.


    Tuesday, May 27, 2014 4:57 AM

Answers

  • Hello,

    There is no way to count the selected files.

    The only possible way is to handle the BeforeAttachmentAdd event and count the attachment files. When the limit is reached you can cancel the action setting the Cancel parameter to true and display a dialog box. Hope it makes sense. 

    • Marked as answer by 董建华 Tuesday, June 3, 2014 7:46 AM
    Tuesday, May 27, 2014 6:35 AM
  • I don't think BeforeAttachmentAdd event could help you. You want to select many attachment files once and pick out which file is last added. BeforeAttachmentAdd event occurs before an attachment is added to an instance of the parent object. When lost of attachment files are selected to insert, we are hard to know which one should be inserted at last in Outlook.

    • Marked as answer by 董建华 Tuesday, June 3, 2014 7:44 AM
    Tuesday, June 3, 2014 5:48 AM

All replies

  • Hello,

    There is no way to count the selected files.

    The only possible way is to handle the BeforeAttachmentAdd event and count the attachment files. When the limit is reached you can cancel the action setting the Cancel parameter to true and display a dialog box. Hope it makes sense. 

    • Marked as answer by 董建华 Tuesday, June 3, 2014 7:46 AM
    Tuesday, May 27, 2014 6:35 AM
  • Hello,

    There is no way to count the selected files.

    The only possible way is to handle the BeforeAttachmentAdd event and count the attachment files. When the limit is reached you can cancel the action setting the Cancel parameter to true and display a dialog box. Hope it makes sense. 

    Hi Eugene,

    I am here waiting for you.I need to deal with the situation like the link below.
    drag & drop files to folder
    I found that for mapifolder, when i drag many files to it.The folder.items.Count is the  all dragged files count.
    But for a new mail, when insert many attachment files at the same time.The mail.attachments.Count is increased one by one.
    So i don't know when the limit is reached in this senario.



    • Edited by 董建华 Tuesday, May 27, 2014 8:14 AM
    Tuesday, May 27, 2014 7:20 AM
  • You can declare a global variable which you can increase by one each time the file is added.
    Tuesday, May 27, 2014 11:16 AM
  • Yeah, but when should i pop up the form? This is import.

    Though i know how many file is added, i still don't know which file is the last!

    I need to know the attachment files count or which file is the last before call the BeforeAttachmentAdd implementation.
    Only in this way, i could know when i should pop up the form in the BeforeAttachmentAdd implementation.




    • Edited by 董建华 Wednesday, May 28, 2014 1:02 AM
    Wednesday, May 28, 2014 12:37 AM
  • Hi,

    >>Though i know how many file is added, i still don't know which file is the last!<<

    As far as I know, there is no property or method of Outlook Object Model to capture the last file appended into the attachment of a mail item directly.

    For a workaround, as Eugene said, we could declare a global variable to increase by one each time the file is added. We could also store the attachment file name and its number in an array each time the file is added. When the attachment files count reaches a value, you could find the file from the array based on the number.


    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.

    Friday, May 30, 2014 9:33 AM
    Moderator
  • Hi Luna,

    You mean the files count is just the selected attachment files?What about i add many attachment files for the next operation?When you clear the array?
    As i already said, the mail.attachments.Count is increased one by one.
    So this means when you select many attachment files, then click the insert button.
    Then for the first attachment file, you can find the mail.attachments.Count is 1 from the BeforeAttachmentAdd implementation.You just said add file to an array, but when do you think the added operation should finish?





    • Edited by 董建华 Monday, June 2, 2014 1:05 AM
    Monday, June 2, 2014 12:48 AM
  • I don't think BeforeAttachmentAdd event could help you. You want to select many attachment files once and pick out which file is last added. BeforeAttachmentAdd event occurs before an attachment is added to an instance of the parent object. When lost of attachment files are selected to insert, we are hard to know which one should be inserted at last in Outlook.

    • Marked as answer by 董建华 Tuesday, June 3, 2014 7:44 AM
    Tuesday, June 3, 2014 5:48 AM
  • Hi team,

    Yeah,the problem is just as you say.This operation nearly could not be archived.
    I have to close this qustion.Thanks for you all buddies, all of you are the best.

    Best regards.

    • Edited by 董建华 Tuesday, June 3, 2014 7:48 AM
    Tuesday, June 3, 2014 7:44 AM
  • Hi team,

    I have tried many, may be this could not be archived.
    Thanks Eugene, you gave me a light path of truth always.

    Best regards.
    Tuesday, June 3, 2014 7:49 AM