Results 1 to 14 of 14
  1. #1
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Searching for attachment name. (2000)

    Does someone have a way to search Outlook for attachment names?
    I'm sure this has been answered before but can't easily find it (without the search capabilities).
    A built in method or a vba method would be acceptable.

  2. #2
    Bronze Lounger
    Join Date
    Jun 2001
    Location
    New York, New York, Lebanon
    Posts
    1,449
    Thanks
    1
    Thanked 1 Time in 1 Post

    Re: Searching for attachment name. (2000)

    <img src=/S/hello.gif border=0 alt=hello width=25 height=29> Lance

    Yes you can check the name of the attachment via:

    Message.Attachments.Item().FileName

    Item can be a For Next loop index because you may have more than one attachment per message.

    HTH

    Wassim
    <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

  3. #3
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for attachment name. (2000)

    Thank you for the effort!. colFolders "blew up" as not defined.

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    Lance, that code I posted has been revised, and is working for me in simple tests. (Kind of embarrassing because I was repeating an error I made a few weeks ago, where <!profile=HansV>HansV<!/profile> had steered me straight.) Make sure you copy the entire text, starting with Option Explicit, into a standard Outlook code module. Be warned that it takes a long time if you have a very large number of folders to process.

    If it errors on you, please post back the exact line of code and the exact error message.

    You should not need to reference any special libraries, but FWIW, in my OL VBE window under Tools, References, the active libraries are (abbreviated) VBA, Outlook 9 Obj Lib, OLE Auto, Office 9 Obj Lib, FILEMGT 1 Type Lib, & MS Forms 2 Obj Lib.
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    Some more fixes now posted in the above code attachment. I learned quite a few more things:
    1. Slightly better error handling.
    2. I put the search results into a noteitem in case it finds a lot of items. Beats clicking the OK messagebox over and over. But see #5 below.
    3. I made the Item type generic so that any kind of Item including Calendar, Task, etc., can be searched, except Notes, which do not permit Attachments. (It kept blowing up on me because I had stored a rejected meeting request in a mail folder
    -John ... I float in liquid gardens
    UTC -7ąDS

  6. #6
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for attachment name. (2000)

    <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>
    Very impressive. Thank you so much for the help on this.
    I did not experience any errors when using the code...However, I think I will add carriage returns in the note string for slightly better readability.
    I really appreciate the assist.
    <img src=/S/bullseye.gif border=0 alt=bullseye width=45 height=15>

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    >I will add carriage returns in the note string for slightly better readability

    Sorry, must have deleted a trailing " & vbLf" in a last minute edit. I'll post a corrected version later.
    -John ... I float in liquid gardens
    UTC -7ąDS

  8. #8
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for attachment name. (2000)

    Here is an interesting twist - if the mail items are signed with a digital signature, the macro / vba fails.. will have to run again to get the exact error msg.

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    Interesting. At one point in testing I thought that might be a problem, but after I Dim'med Item as a generic Object it didn't seem to be. Attachment Type constants (and their respective value) in OL 2000 are olByValue (1), olByReference (4), olEmbeddedItem (5), or olOLE (6). It may be that 5 & 6 do not have displaynames, and further code logic is necessary to handle this. Would you like to test for this and see if it's the problem? I'm not going to have time for a while.

    On a related note I thought of writing a function to get the Item.Class, to differentiate between and select the most appropriate date-related property to display; CreationTime is not always useful.
    -John ... I float in liquid gardens
    UTC -7ąDS

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    <P ID="edit" class=small>(Edited by JohnBF on 16-Oct-03 16:04. Fixed problem with embedded objects)</P>See if the attached text file VBA code works for you, and report any errors by line and message. It first asks for the text by which to search in attachment names, and then asks the user to choose the parent folder in which and under which to search. You could chnage this to automatically working from the active/selected folder if required; let me know.
    -John ... I float in liquid gardens
    UTC -7ąDS

  11. #11
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    I couldn't resist; see if the new code attached to the original code post fixes the problem.
    -John ... I float in liquid gardens
    UTC -7ąDS

  12. #12
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for attachment name. (2000)

    I'll test it some more... might not be able to dedicate a whole lot of time today but I'll check it out.
    I did try some things out yesterday that proved that it's not always an issue and I think I understand .... just now as I'm writing this.. why the macro failed. There were a number of message that were signed but had an expired digital certificate attached.
    I'll run it later to see if i can prove that out and capture some parameters of the messages.

  13. #13
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Searching for attachment name. (2000)

    I don't have any Digital Certificates to test against, so I leave that to you. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Be sure to check my most recent code attachment.
    -John ... I float in liquid gardens
    UTC -7ąDS

  14. #14
    Lounger
    Join Date
    Apr 2001
    Location
    Sacramento, California, USA
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Searching for attachment name. (2000)

    Thank you kindly. Finally had some time to reload the code and give it a whirl. Seems to work just fine.
    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •