locked
Can I export an Outlook OST to PST using a script? RRS feed

  • Question

  • Hi all.  I would like to export my local OST file to a PST using a script (VB or otherwise).  Is this possible? 

    To be clear, I know how to manually export my local OST to a PST (using Outlook 2013).  But I would like to carry this out via a script, if possible.

    The ultimate objective of this particular task is to automate the process of the OST-to-PST export, and have it carried out on a weekly schedule.

    I'm not asking for anyone to provide me with any actual code.  I just want to know if this would be possible via some kind of Windows script, and if so, perhaps a nudge in the right direction :-)

    I am running Win 10, x64.

    Thanks in advance.

    Wednesday, May 10, 2017 7:27 AM

Answers

  • I know the answer to your question.  You have to learn how to use PowerShell with Outlook and the Office object model.  There is no one line answer to your questions.

    To be a technician you must be willing to do fundamental research on any technology you wish to use. After you understand the technology you will be able to ask better questions.

    Start by reviewing blogs that show you how t use the Outlook object to do basic things.

    https://www.google.com/?gws_rd=ssl#newwindow=1&q=powershell+outlook+copy+folder&spf=1495387259713

    Being a tech is mostly a self-service world. 


    \_(ツ)_/

    • Marked as answer by cagross99 Monday, May 22, 2017 11:13 AM
    Sunday, May 21, 2017 5:21 PM

All replies

  • Open Outlook and copy all folders from the mailbox to a data file.  Just select them in the GUI and past into a new data file.

    Post Outlook user questions to the Outlook user forum.  Once you know how to use Outlook the answer to how to use script will be more obvious.


    \_(ツ)_/

    Wednesday, May 10, 2017 9:47 AM
  • I appreciate the reply.  

    >> Open Outlook and copy all folders from the mailbox to a data file.  Just select them in the GUI and past into a new data file.

    I think perhaps you are saying that I could replicate this procedure by use of a script--is that correct?

    My post is more trying to ascertain the feasibility--not necessarily exactly how I would carry it out.  I just want to find out if there would be anything prohibiting me from scripting such an export.

    Thanks.

    Sunday, May 21, 2017 9:07 AM
  • The ultimate objective of this particular task is to automate the process of the OST-to-PST export, and have it carried out on a weekly schedule.

    What problem are you trying to solve?


    -- Bill Stewart [Bill_Stewart]

    Sunday, May 21, 2017 12:38 PM
    Moderator
  • I frequently backup my local Outlook OST to a PST, and store this PST offline.  To do this, from within Outlook, I manually export my OST to PST.  I would like to automate this process so it occurs by itself, on a weekly (or daily) schedule.  The system would keep the last three backups.

    Thanks.

    edit:  I am not using an Exchange server.
    • Edited by cagross99 Sunday, May 21, 2017 12:41 PM
    Sunday, May 21, 2017 12:41 PM
  • There are rules in Outlook that will automatically archive folders to a PST.  Post in Outlook forum to learn how to configure Outlook to auto-archive folders.

    https://www.google.com/?gws_rd=ssl#newwindow=1&q=outlook+archive+folder&spf=1495379947983


    \_(ツ)_/

    Sunday, May 21, 2017 3:19 PM
  • I am aware of archiving in Outlook.  But as I understand, archiving will move the emails out of my OST and into a separate PST.  I'm not looking to do that.  I am looking to copy the emails in my OST to a PST, but so the emails remain in my OST.  Please correct me if I have misunderstood anything.

    The export process does what I want--it copies all email in my OST to a separate PST, but leaves the emails in the OST so I can continue to access them from the OST.

    • Edited by cagross99 Sunday, May 21, 2017 3:25 PM
    Sunday, May 21, 2017 3:24 PM
  • You can also create rules that will copy all emails as received or sent into any folder you wish to copy them to.


    \_(ツ)_/

    Sunday, May 21, 2017 3:36 PM
  • Yep.  I know that as well.  But my issue is getting the emails from the OST into a PST--specifically, doing so in an automated way.  Do you know if there is a scripting solution to that?

    Edit:  Would I be able to create a rule to copy all emails from my OST into a separate email account--an email account with a different data file--e.g. a separate PST?

    • Edited by cagross99 Sunday, May 21, 2017 3:42 PM
    Sunday, May 21, 2017 3:40 PM
  • There are many backup tools available if you search for them.

    We do not supply custom scripts on request.  If you have a specific question about a script you have written we can try yo answer it for you.

    YOU can also look here for pre-written scripts: https://gallery.technet.microsoft.com/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=Office&f%5B0%5D.Text=Office&f%5B1%5D.Type=SubCategory&f%5B1%5D.Value=Microsoft%20Outlook&f%5B1%5D.Text=Microsoft%20Outlook


    \_(ツ)_/

    Sunday, May 21, 2017 4:04 PM
  • >> We do not supply custom scripts on request.

    I'm not asking for a custom script.  I made this clear in my original post.

    >>  If you have a specific question about a script you have written we can try yo answer it for you.

    I do have a specific question.  I also made it clear in my original post.  I just want to know if such a procedure is possible to script.  If you don't know the answer to that, no worries.

    Sunday, May 21, 2017 4:07 PM
  •   I just want to know if such a procedure is possible to script.  .

    Yes it is possible. Look at the link I posted.

    \_(ツ)_/

    Sunday, May 21, 2017 4:13 PM
  • In that list are several OST-to-PST converters.  But they all specifically mention that they recover damaged or corrupt OST files.  I'm not sure if they would be applicable in my case--I do not have a damaged OST.

    Additionally, as I mentioned in my original post, I would like to write the script myself, and was hoping to get some tips on what approach to use.  I appreciate the help though.  Maybe someone else will know.

    Sunday, May 21, 2017 4:53 PM
  • The link shows examples of how to access Outlook folders from a script.  That is the best place to start.  Also try searching for examples.

    \_(ツ)_/

    Sunday, May 21, 2017 5:00 PM
  • >> The link shows examples of how to access Outlook folders from a script.

    Right O.  Again though, that's not exactly what I'm asking.  I appreciate the intent, but a list containing 816 entries, most of which are not applicable, isn't too helpful.

    >> Also try searching for examples.

    Ah thanks, that's a good idea--does it have to be an internet search, or will any type of search suffice? Regardless, how do I mark this as the best answer?

    Honestly though, it's OK if you don't know the answer to my question.  Maybe someone else will come along who does.  If not, I'll find a workaround.

    Sunday, May 21, 2017 5:11 PM
  • I know the answer to your question.  You have to learn how to use PowerShell with Outlook and the Office object model.  There is no one line answer to your questions.

    To be a technician you must be willing to do fundamental research on any technology you wish to use. After you understand the technology you will be able to ask better questions.

    Start by reviewing blogs that show you how t use the Outlook object to do basic things.

    https://www.google.com/?gws_rd=ssl#newwindow=1&q=powershell+outlook+copy+folder&spf=1495387259713

    Being a tech is mostly a self-service world. 


    \_(ツ)_/

    • Marked as answer by cagross99 Monday, May 22, 2017 11:13 AM
    Sunday, May 21, 2017 5:21 PM
  • Sunday, May 21, 2017 5:39 PM
  • >> I know the answer to your question.  You have to learn how to use PowerShell with Outlook and the Office object model.

    What took you so long to say this?

    >>  There is no one line answer to your questions.

    So give me the long winded version.  I never said I wanted a one line answer.

    >> Being a tech is mostly a self-service world. 

    I understand the value of learning things myself, and I do indeed want to do that.  But I think you're being a little too draconian in your enforcement of that tenet.  The whole reason for a forum like this--and indeed the goal of my question--is to at least to be pointed in the right direction.  You gave me a list of 816 posts and said, "One of those might be helpful." You've finally said the solution lies in PowerShell with Outlook and the Office object model, and given a starting link, so that at least gives me an avenue I can research.  Thank you for that.

    >> You can also just use the builtin - export function in Outlook.

    Yes I'm aware of that.  I currently carry out such an export manually, once a week.  I'm looking for a way to automate this export process.

    Sunday, May 21, 2017 5:42 PM
  • You can create a macro to do this and add it as a button on your toolbar.  For basics of how to use Macros in Outlook you will need to post in the Outlook VBA forum.

    We cannot give you a long-winded tutorial on how to do this.  That is beyond the scope of this forum.

    The export function in Outlook cannot be directly automated as it is a wizard. You will have to code it manually in VBA.


    \_(ツ)_/

    Sunday, May 21, 2017 6:04 PM
  • >> We cannot give you a long-winded tutorial on how to do this.  That is beyond the scope of this forum.

    OK that's fair.

    >> You can create a macro to do this and add it as a button on your toolbar.  For basics of how to use Macros in Outlook you will need to post in the Outlook VBA forum.

    >> The export function in Outlook cannot be directly automated as it is a wizard. You will have to code it manually in VBA.

    I'm a little unclear on these two statements.  It seems like the first indicates that I *can* automate the export function, by use of a macro.  But then you say that is not possible, as the export function is a wizard.  What am I misunderstanding about one (or both of) your statements?  Are you saying the macro button on my toolbar will merely open the Export wizard?

    Sunday, May 21, 2017 6:12 PM
  • Again - you need to post Outlook issues r questions in the Outlook forum.

    You can create a macro that copies all items selected for copying to a PST.  This is what the export wizard does.


    \_(ツ)_/

    Sunday, May 21, 2017 6:39 PM
  • >> Again - you need to post Outlook issues r questions in the Outlook forum.

    I did.  No one there suggested a macro.

    >> You can create a macro that copies all items selected for copying to a PST

    Gotcha.  If I have to do any manual pre-selection, that is not what I'm after.  But if I could somehow automate the selection process, then this may be viable.  I will look into it, and perhaps more importantly, the Power Shell route.  Thank you.

    Sunday, May 21, 2017 6:50 PM
  • Good research will help you too define your request in a less ambiguous way.  That is a prerequisite for writing any kind of code or solution.


    \_(ツ)_/

    Sunday, May 21, 2017 6:56 PM
  • This is part of my research.  And I'm fairly confident I defined my request clearly in my original post.  Most of our wheel-spinning in this thread was due to your misunderstanding or disregard of my requirements.

    • I stated that I wanted an export solution, yet you gave me an archive solution.
    • I stated that I wanted an automated OST-to-PST solution, yet you suggested a semi-automated solution involving Outlook rules.
    • I stated that I wanted to script the solution myself, yet you gave me pre-packaged backup tools.

    Read my original question--how much clearer could I have been about those requirements?  I'm not complaining about your help.  But accusing me of being ambiguous isn't fair.

    It was only after all this that you actually attempted to address my question.  


    • Edited by cagross99 Sunday, May 21, 2017 7:12 PM
    Sunday, May 21, 2017 7:11 PM
  • Sorry that I tried t pint you in the right direction. I will avoid that in the future.

    You are posting in the wrong forum.  Please post in Outlook VBA or developers forum to learn how to automate outlook.


    \_(ツ)_/

    Sunday, May 21, 2017 7:38 PM
  • >> Sorry that I tried t pint you in the right direction.

    You did indeed eventually point me in the right direction, and I thanked you for it.  I stand by that.

    >> Please post in Outlook VBA or developers forum to learn how to automate outlook.

    Had I known such forums existed, I would have posted there.  All I could find was this forum and the "Outlook IT Pro Discussions" forum.  I can't seem to find either of the forums you just mentioned in the list of Technet forums--are you able to provide a link to at least the Outlook VBA forum? That sounds like it might be useful for future posts.  

    Sunday, May 21, 2017 7:58 PM
  • Office forums are not part of TechNet. You will have to search the office and MSDN communities.

    \_(ツ)_/

    Sunday, May 21, 2017 8:01 PM
  • Thanks for this--you've been very helpful.
    Monday, May 22, 2017 11:13 AM