search and store directory in outlook macro

Answered search and store directory in outlook macro

  • Saturday, April 14, 2012 8:19 PM
     
     

    Hello,

    In Excel i can make a macro who starts the file-open-popup to search for a directory and when the directory is found, i can add the information to a cell. The next time i can use the information which is stored in that cell.

    But how i can i search a directory in an Outlook-macro and store it somewhere so i can use it on an other day?
    Can i write the directory to a txt-file an read it from there? Are there other options?

    Who can help me with this question?

All Replies

  • Monday, April 16, 2012 4:07 AM
    Moderator
     
     

    Hi h2u,

    Thanks for posting in the MSDN Forum.

    What directory means in your issue. Does it exist on the disk or just in the default store of your Outlook?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, April 17, 2012 5:02 AM
    Moderator
     
     

    Hi h2u,

    Any update?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

  • Tuesday, April 17, 2012 7:44 PM
     
     

    Hello Tom,

    Sorry for some delay.

    The directory is an existing directory on my harddisk.
    On the internet i found a macro which moves the mail-attachements to a directory and puts a hyperlink to these files and directory in the mail (so my pst-file-size keeps small).
    At this moment the directory is hard-coded in the macro, but i would like to make a kind of setting where the user can choose the destiantion-directory.

    Hope you, or anyone else, can help me.

  • Wednesday, April 18, 2012 7:35 AM
    Moderator
     
     

    Hi h2u,

    Thanks for posting in the MSDN Forum.

    You are able to use Dir function to search the directory. http://office.microsoft.com/en-us/access-help/dir-function-HA001228824.aspx

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

  • Wednesday, April 18, 2012 5:10 PM
     
     

    Hello Tom,

    You're right, you can use the Dir-function to search for a directory.
    But how can i store the choosen directory so i don't have to choose every time i start Outlook?

    Everytime you close Outlook, the choosen directory will be lost because the macro-variable will become empty.
    Can a macro write the directoryname to a kind of file and read it again the next time the macro is started?

    Hope you, or someone else, can help me.

  • Wednesday, April 18, 2012 9:42 PM
    Moderator
     
     Answered
    You can use the Folder.GetStorage() method if you're using Outlook 2007 or later.
     
    That will get or create a hidden item that you can get/set for any folder. For example, you can add a hidden item to Inbox using GetStorage(). You could set the subject of the item to your selection and retrieve it at any time.
     
    See the Object Browser help for GetStorage() in the Outlook VBA project to see how to use that method and view some sample code.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "h2u" <=?utf-8?B?aDJ1?=> wrote in message news:1b947dc6-7017-457f-921d-d1c225010cda...

    Hello Tom,

    You're right, you can use the Dir-function to search for a directory.
    But how can i store the choosen directory so i don't have to choose every time i start Outlook?

    Everytime you close Outlook, the choosen directory will be lost because the macro-variable will become empty.
    Can a macro write the directoryname to a kind of file and read it again the next time the macro is started?

    Hope you, or someone else, can help me.


    Ken Slovak MVP - Outlook
    • Marked As Answer by h2u Thursday, April 19, 2012 3:26 PM
    •  
  • Thursday, April 19, 2012 12:06 PM
     
     

    check this link this may help you out

    http://techniclee.wordpress.com/2012/03/26/finding-an-outlook-folder/

  • Thursday, April 19, 2012 3:30 PM
     
     

    Hello Ken,

    Thanks for you answer. Probably Folder.GetStorage() does the job. I looked at the msdn-site for information and it looks very good.

    At this moment i work with Office 2003, but soon we will work with Office 2010. SO, i just have to wait a little time before i can try this object.

    Thanks!

  • Thursday, April 19, 2012 3:33 PM
     
     

    Hello Kevin,

    Thanks for your answer, but i think that Ken gave me the answer to what i was looking for. Your answer finds a folder but i don't read where it stores the answer when i close outlook.
    See my answer above.

    Tom, Ken en Kevin,
    Thanks for the given answers and the time you spent for looking for an answer for me.

  • Thursday, April 19, 2012 6:19 PM
    Moderator
     
     
    For Outlook 2003 you'd have to use Redemption (www.dimastr.com/redemption) and access the folder's HiddenItems collection to use a hidden item (or use C++ or Delphi/Pascal, and Extended MAPI in non-managed code only).
     
    Alternately you can reference Windows scripting and use a FileSystemObject to save the selection as a text file to a known location, where it could be read back later.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "h2u" <=?utf-8?B?aDJ1?=> wrote in message news:ff6a284a-df1a-4b71-a75c-e2da2a73586c...

    Hello Ken,

    Thanks for you answer. Probably Folder.GetStorage() does the job. I looked at the msdn-site for information and it looks very good.

    At this moment i work with Office 2003, but soon we will work with Office 2010. SO, i just have to wait a little time before i can try this object.

    Thanks!


    Ken Slovak MVP - Outlook