Solved

Backup or Synchronize or create Offline Copy of Public Calendar Outlook 2003 Exchange 2003

Posted on 2009-04-13
54
631 Views
Last Modified: 2012-05-06
Looking for common-sense suggestions/solutions for backing up/having an offiline copy and/or synchronizing a Public Calendar to something - for safe-keeping let's say.
For years, everything was written by hand in an old-school "Daily Diary".  Now we use the Public Calendar to do our scheduling and tacking of jobs and client info.

I have a backup server that is replicating Public Folders I do nightly backup to Tape, but that is really only for DR.
What I am looking for is something where I can restore bits and pieces from, not restore the whoe MS Info Store.
I am looking for a low-maintenance (and hopefully low-cost) solution to having a backup of this calendar in case of server crash - or just loss in general.
I need to sleep at night knowing that I know where there is a complete  untouched (and untouchable by anyone other than those permitted to)  copy of our Public Calendar, for those times when people accidentally delete something, and are afraind to tell you, then too much time goes by and the default store has released it and there is no way to get it back (is there????).  No "Recover Delete", no pfdavadmin, nothin.
I set my default retention to 30 days, because I have already been burned.  I tried several solutions I found here on EE, and nothing helped because it was too late.  Retention policy was over, and now that there are entries gone...
In a small company where not everyone is as savvy as we would like, and many employees traveling alot and lots of late nights and 3rd shift people editing things...it can be scary - makes you miss that old Diary...

So, how can I, hopefully without having to remember to do it myself everyday - keep a safe copy - that will update if not in real-time then at the beginning or end of day, and will be saved somewhere that is not only able to be restored or copied back if deleted (and to be able to copy back individual entries - not overwrite the whole store) but will also end up locally somewhere that I won't need my network to access it.

Are there any ideas out there?
If there isn't a homegrown way to do this simply - without spending more time than I would money on a 3rd party app - then please let me have your recommendations on 3rd party apps.  If they do more than what I want, great, I would love to sync the Public Calendar with my BB reliably (without worrying about endangering the Public Calendar), but my main goal is just to know at the end of the day - should there be disaster - I know where my people are supposed to be and when and who is coming to our office and...
0
Comment
Question by:mmorocco
  • 28
  • 26
54 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24136219
Hi, mmorocco.

The best suggestion I can offer is to use a script to copy the public calendar to a PST file on your computer.  You could use a recurring task to trigger the script so you wouldn't have to remember to do anything.  Of course Outlook would have to be running for the task to fire and trigger the code.  I can provide the script and instructions if you're interested.
0
 

Author Comment

by:mmorocco
ID: 24136758
That is precisely what I am looking for, and I would very much appreciate the script and instructions.  I have no problem with having Outlook running when I want to have the task run.
Excellent!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24136870
Ok, here's the code for doing this.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Run the macro BackupPublicFolder

In case you aren't familiar with folder paths in Outlook, they are just like folder paths in the file system with the exception that they do not include a drive letter.  The path to a public folder will be something like

    Public Folders\All Public Folders\My Public Folder

The path to the root folder of a a PST file will be something like

    Personal Folders

Once we've determined that the macro works properly, then I'll post the code and instructions for having Outlook run it automatically from a task.
Sub BackupPublicFolder()

    Dim olkPublicFolder As Outlook.MAPIFolder, _

        olkArchivePST As Outlook.MAPIFolder, _

        olkBackup As Outlook.MAPIFolder

    'Replace the folder path on the next line'

    Set olkPublicFolder = OpenOutlookFolder("Path to public folder")

    'Replace the folder path on the next line'

    Set olkArchiveFolder = OpenOutlookFolder("Path to PST")

    Set olkBackup = olkPublicFolder.CopyTo(olkArchiveFolder)

    olkBackup.Name = Format(Date, "YYYY-MM-DD") & " Public Calendar Backup"

    Set olkBackup = Nothing

    Set olkArchivePST = Nothing

    Set olkPublicFolder = Nothing

End Sub
 

Function IsNothing(obj)

  If TypeName(obj) = "Nothing" Then

    IsNothing = True

  Else

    IsNothing = False

  End If

End Function
 

Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder

    Dim arrFolders As Variant, _

        varFolder As Variant, _

        olkFolder As Outlook.MAPIFolder

    On Error GoTo ehOpenOutlookFolder

    If strFolderPath = "" Then

        Set OpenOutlookFolder = Nothing

    Else

        Do While Left(strFolderPath, 1) = "\"

            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)

        Loop

        arrFolders = Split(strFolderPath, "\")

        For Each varFolder In arrFolders

            If IsNothing(olkFolder) Then

                Set olkFolder = Session.Folders(varFolder)

            Else

                Set olkFolder = olkFolder.Folders(varFolder)

            End If

        Next

        Set OpenOutlookFolder = olkFolder

    End If

    On Error GoTo 0

    Exit Function

ehOpenOutlookFolder:

    Set OpenOutlookFolder = Nothing

    On Error GoTo 0

End Function

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24137141
Can't wait to try this.
 In the meantime, a few questions:
Can I run this on more than one outlook installation - so maybe I could do it a couple times a week, at different times to capture different "snapshots" I guess I would call them.
2. I suppose there is no harm in doing it on a machine at home where I connect to exchange either via RPC or VPN.  Understanding that my connection may dictate the time it takes.  I assume of course it will run faster on a machine that is local to the exch svr.
3. So this calendar will go to a pst?  Excellent.  So I could either just keep storing/saving them, or I could restore them to outlook from time to time, whether it be my outlook or some offline copy, right?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24137395
1.  Yes, you can run this on as many installations as you want.  It's not a good idea if they all run at the same time or if the times overlap though.

2.  Not sure about the RPC connection, but it should run okay over a VPN connection, just a bit more slowly.

3.  Correct.  This copies the folder to a PST file.  Right now it's going to store all the copies in one PST, but we could change that if you want.  You can restore the entire folder or any given entry from any copy at any point in time.
0
 

Author Comment

by:mmorocco
ID: 24137481
Excellent!  This sounds like exactly what I was looking for.  Low-maintenance with high-availability and customization!
I am a bit of a novice with the scripting, but look forward to learning.

Are there any security issues - I need to check or be aware of within outlook or on my server before trying this, or we will determine that when we try to execute the script?

Am on a rather long and at this point drawn out conf. Call - so am waiting to put this into action.
Hopefully soon.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24137680
"Are there any security issues - I need to check or be aware of within outlook or on my server before trying this"
There shouldn't be any security issues.

"Am on a rather long and at this point drawn out conf. Call - so am waiting to put this into action.  Hopefully soon."
No worries.  I'll be here whenever you get to it.
0
 

Author Comment

by:mmorocco
ID: 24138995
OK.  So, the only two things I need to replace are those two paths?
The Public Folder one I believe I have right:
("Public Folders\All Public Folders\Jackson Finances Calendar")

But for the PST one - am I creating a new PST - or is  this supposed to be going into an already existing one.  Your help just says Personal Folders.  Can you help me out a little more as to what this path should be?  Should it be going to a C:\ drive directory on my local machine?

I am first doing this on a machine that is part of my domain but sits on a VPN tunnel with my server/exch box all day.

Pardon me for saying this - but in testing this macro - am I endangering deleting anything from this Public Calendar?  Should I maybe create a test folder - or make a copy of a smaller folder and test it on that???
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24139654
"The Public Folder one I believe I have right"
Yes, that looks good.

"am I creating a new PST"
Yes, that's what I recommend.  It's not a requirement though.

"Should it be going to a C:\ drive directory on my local machine?"
A folder path in Outlook never has anything to do with the path to file in the file system.  If you create a new PST file it will appear in Outlook as Personal Folders.  You can change the name to whatever you want it to be.  The Outlook path to that folder will then be the name you just gave it.

"Pardon me for saying this - but in testing this macro - am I endangering deleting anything from this Public Calendar?"
No, it isn't endangering anything (the script copies the folder), but you're right to ask.  You should do a test first to make sure you're comfortable with how this works.
0
 

Author Comment

by:mmorocco
ID: 24152443
Havent forgotten about this.  Havent moved forward (unfortunately) since the last communication.  Am hoping to test this tomorrow and get back to you and move forward.  thanks for your patience.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24152892
Thanks for the update.  No rush.  I'll be here whenever you get to this.
0
 

Author Comment

by:mmorocco
ID: 24158443
Hi BlueDevilFan

I initially posted this question as a result of what I thought was a limited incident.  I had planned to put it in place for my Calendar and all public folders...

But then, in the last couple days I realized that I may have a LARGER problem at play.

I just posted question ID 24328183.  

You have been so responsive i thought i would reach out to you and let you know if you have a minute to look at this issue and let me know if you can help?!

and then i can get back to this scripting - and hopefully avoid these types of future issues.

but right now i am hoping for a hail-mary / buzzer-beater / whatever your sport is...
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24158865
I took a look at the question and I don't think I can be of much help.  I'm not enough of an Exchange expert to be able to answer questions about what happens to items deleted from a public folder or how to determine what happened to them.  Are you certain that the items are gone and this isn't an instance of someone applying a filter that makes the folders appear to be empty?
0
 

Author Comment

by:mmorocco
ID: 24164749
Yes, well...i am afraid i am in a bad way on this one.. not sure yet which direction to go in.  I simply cant believe it happened long enough ago for the items to have been deleted permanently.  But who knows.

Question regarding our ongoing original question.

1.  So, where i am supposed to put in a name for the PST I can just name it "Public Calendar Backup"?
2.  And will it automatically be opening up or visible within my current outlook?  or will i (have to) be creating a new profile in outlook and then importing the PST?
3.  After I replace the text you told me to - do I need to delete your instructions from the script - or does the VB just look past it because of the way you format it with the characters?  (i have had very little experience with this kind of thing, but like to learn - so I am curious).

And lastly, while there are probably other ways to accomplish it (Exmerge is one I have yet to dig into) - I assume - and I think I asked this - that I could do this with any public folder I want - in case, for instance I thought things were going to ALL OF A SUDDEN start disappearing!!!! Yeah, right!  (Sorry, a little humor to myself in light of my current circumstance.)

BTW, THANKS VERY MUCH for taking the time to look at my other post and to respond.  Much appreciated.  As for the Filter thing, I don't think so, unless someone really hit a bunch of keys by accident to cause such a thing.  Same goes for archiving, I assume it is possible someone did it - but boy would they have to click through alot of stuff to "accidentally" do that...
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24175855
1.  When you create a PST file you give it a file name (the name you see in Windows Explorer) and a name (the name you see for this PST file in Outlook).  The two names do not have to be the same.  Outlook defaults that name to Personal Folders.  You can call it anything you want, including "Public Calendar Backup".  In fact that can be both the file name and the folder name in Outlook.  The Outlook path to that folder will be "Public Calendar Backup" (without the quotes of course).

2.  The code as is assumes that you already have that PST file open in Outlook (i.e. it appears in the list of mail folders).

3.  You can remove my comments from the script if you want to, but leaving them there has no effect.  All versions of Visual Basic ignore any line where the first printable character is an apostrophe.  Those lines become comments.

4.  This code will work for any public folder you want to backup.  I've made a couple of changes to the code to make that easier.  This version assumes that you want to backup all the public folders to the same PST file.
Sub BackupPublicFolder()

    Dim olkPublicFolder As Outlook.MAPIFolder, _

        olkArchivePST As Outlook.MAPIFolder, _

        olkBackup As Outlook.MAPIFolder

    'Replace the folder path on the next line'

    Set olkArchiveFolder = OpenOutlookFolder("Path to PST")
 

    'Backup public folder #1'

    'Replace the folder path on the next line'

    Set olkPublicFolder = OpenOutlookFolder("Path to public folder #1")

    Set olkBackup = olkPublicFolder.CopyTo(olkArchiveFolder)

    olkBackup.Name = Format(Date, "YYYY-MM-DD" & ) & " Backup of " & olkPublicFolder.Name
 

    'Backup public folder #2'

    'Replace the folder path on the next line'

    Set olkPublicFolder = OpenOutlookFolder("Path to public folder #2")

    Set olkBackup = olkPublicFolder.CopyTo(olkArchiveFolder)

    olkBackup.Name = Format(Date, "YYYY-MM-DD" & ) & " Backup of " & olkPublicFolder.Name
 

    Set olkBackup = Nothing

    Set olkArchivePST = Nothing

    Set olkPublicFolder = Nothing

End Sub

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24188035
OK.  I am really losing it.  That las episode  with the disappearing emails - which is sort of solved  -and is my own fault, and my general lack of sleep must be getting to me.

I did the first steps above - saved the project, but when I try to run it I get an error about "macros in this project are disabled"

I know this is totally an easy fix somewhere, but I am jammed up at the moment - can you point me in the right direction?

FWIW - I copied a bunch of junk emails to a public folder that I am going to test this on first.  I just got done putting my Public Calendar back together - so I need to see this work first before a live run.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24190012
First, check to make sure that macros are enabled.

1.  Close the VB Editor
2.  Click Tools > Macro > Security
3.  Set the Security Level to Medium
4.  Close Outlook
5.  Start Outlook

If macros are enabled, then add this code to the ThisOutlookSession module in Outlook.  Close and restart Outlook.  You'll be prompted to enable macros.  Once they're enabled you can remove this code.

Private Sub Application_Startup()
    MsgBox "Activated"
End Sub
0
 

Author Comment

by:mmorocco
ID: 24190097
OK - I had set the security myself earlier - but like i said - a simple thing like close and restart outlook did the trick.

But i am getting a runtime error saying one or more parameters are invalid.

Can you please clarify that the only pieces of info I need to edit are the public folder path and PST path?

Attached is a screenshot of what I get when I hit Debug on the runtime error - there is a highlighted line and arrow pointing to the
 Set olkBackup = olkPublicFolder.CopyTo(olkArchiveFolder)

and not sure if there is anything after that...


runtime-error.bmp
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24190222
One of the folder paths is invalid, probably the archive folder path.  If the folder Public Folder Backup already exists, then instead of

    Set olkArchiveFolder = OpenOutlookFolder("Mailbox - Matt Morocco\Public Folder Backup")

try

    Set olkArchiveFolder = OpenOutlookFolder("Mailbox - Morocco, Matt\Public Folder Backup")

Otherwise, create Public Folder Backup.
0
 

Author Comment

by:mmorocco
ID: 24190299
OK - easy enough.  THANKS!
So i see it created a subfolder under "Public Folder Backup" with the format with date you have in the code.  I like it.

So, how does it work as far as overwriting?  It sounds as though each time it runs it will create a new subfolder with that date?

So, you keep a few days worth?  and then just manually delete older days once I have a few built up?  Basically I can keep them going back as far back as I want, correct?

But I guess i need to do some renaming or something if I am going to backup two folders in one day.  

Having successfully tested with a folder of mail, i just tried it with a calendar folder.
It appeared to run fine, but then gave me another runtime error saying folder already exists and the debugger pointed to the line with the "Date - format "Public Folder Backup"

So, I should just be careful with naming and/or create separate folders under my personal folder? and then edit the code accordingly?

And if i do that - I can save the code as different Macros to run, correct?  Where do I do that?  in the first line?  How do you rename or save the macro?  I assume you were going to answer that next probably...

i will be quiet now and learn.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24192205
"So, how does it work as far as overwriting?  It sounds as though each time it runs it will create a new subfolder with that date?"
Correct.  It never overwrites.  It always adds a new folder thereby giving you the ability to restore an item from any backup.

"Basically I can keep them going back as far back as I want, correct?"
Exactly.  You can decide how many backups is enough.

"But I guess i need to do some renaming or something if I am going to backup two folders in one day. "
No.  I already made that change for you in the revised code in post 24175855.  

"So, I should just be careful with naming and/or create separate folders under my personal folder? and then edit the code accordingly?"
Shouldn't be necessary if you're using the revised code from 24175855 and only backing up once per day.  If you backup more than once per day, then we'd need to modify the folder name.

0
 

Author Comment

by:mmorocco
ID: 24193375
OK.  Excellent.

I am happy with the way this works!

Am I correct that the revised code in 24175855 should replace the top portion of the original code, but I still need the rest of the original to make a complete macro?
Up until now I had been using the original.  I expect for now I will be using the revised code, and will be running backup of our calendar and contacts.

There isnt much else in our Public Folders right now until I complete my next project or restoring everything.

Are we ready to move onto the part where we can create a task that I can have run weekly to automate this?

Thanks!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24197796
The code in 24175855 replaces the subroutine of the same name from the code I posted in 24136870.  Remember though it just replaces the one routine.  The rest of the code from 24136870 is still necessary and unchanged.

If you're happy with the way this is running, then I'll go ahead and post the other code for scheduling this to run from a task.
0
 

Author Comment

by:mmorocco
ID: 24199226
Excellent.  Looking forward to it.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24206623
This portion of the solution comes in multiple parts.

Part 1 of 3

Follow these instructions for this part.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  Right-click on Class Modules, select Insert > Class Module
5.  In the Properties panel click on Name and enter ScheduledTask
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor

'Events'

Event TaskFired()
 

'Constants'

Private Const CLASSNAME = "Scheduled Task"
 

'Class Variables'

Private WithEvents olkReminders As Outlook.Reminders, _

    strTaskName As String
 

Private Sub Class_Initialize()

    Set olkReminders = Outlook.Application.Reminders

End Sub
 

Private Sub Class_Terminate()

    Set olkReminders = Nothing

End Sub
 

Private Sub olkReminders_ReminderFire(ByVal ReminderObject As Reminder)

    Dim olkTask As Outlook.TaskItem

    If ReminderObject.Item.Class = olTask Then

        Set olkTask = ReminderObject.Item

        If olkTask.Subject = strTaskName Then

            ReminderObject.Dismiss

            With olkTask

                .Complete = True

                .Save

            End With

            RaiseEvent TaskFired

        End If

    End If

End Sub
 

Public Property Let Name(strName As String)

    If strName <> "" Then

        strTaskName = strName

    End If

End Property

Open in new window

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24206679
Part 2 of 3

Follow these instructions.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  Select the ThisOutlookSession module by double-clicking on it.
5.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
6.  Edit the code as needed.  I included comments wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
Dim WithEvents olkArchiveTask As ScheduledTask
 

Private Sub Application_Quit()

    Set olkArchiveTask = Nothing

End Sub
 

Private Sub Application_Startup()

    Set olkArchiveTask = New ScheduledTask

    With olkArchiveTask

        'Enter your task name on the next line'

        .Name = "Test Task"

    End With

End Sub

Open in new window

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24206765
Part 3 of 3

Follow these instructions

1.  Create a task for running this backup.
2.  Fill in whatever details you want.  The only required items are the Subject and the Reminder.
3.  You can make the task recurring if you want, or you can create individual tasks to run the backup at different times.  If you opt for the latter, then you MUST use the same task name for each task.
4.  Edit the code from part 2 replacing the task name on line #11 with the subject you've given your task.
5.  Close Outlook
6.  Start Outlook.  Depending on your security settings Outlook may ask you to enable macros.  Say "yes".

You're ready to go.  When the reminder for the task fires it will mark the task as complete and run the backup process.  This will all take place in the background.  Depending on how much information is in each public folder the backup could take awhile.  Outlook's performance will be affected while the backup runs.
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 76

Expert Comment

by:David Lee
ID: 24206781
Oops.  This code belongs with the code in part 2.  Sorry about that.
Private Sub olkArchiveTask_TaskFired()

    BackupPublicFolder

End Sub

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24211664
Does that last part go at beginning or end of part 2?

I tried both places and each time I go to close outlook i get error in VB editor
0
 

Author Comment

by:mmorocco
ID: 24211678
Normally when you set reminder - you just get that pop-up reminder.
So, I set the reminder for when I want task to run, right?
But I assume it should be when I am around to enable or respond to the task.
And how do I respond - I get that box with "dismiss" "snooze" etc.
Do you have to click something in that window to activate script?
Or is it fired just by the task being run?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24213205
"Does that last part go at beginning or end of part 2?"
It should go at the end of part 2.  

"I tried both places and each time I go to close outlook i get error in VB editor"
What error do you get when closing Outlook?

"So, I set the reminder for when I want task to run, right?"
Correct.

"And how do I respond - I get that box with "dismiss" "snooze" etc."
You'll never see the task.  The code intercepts it when its reminder fires.  It runs the backup while marking the task complete.

0
 

Author Comment

by:mmorocco
ID: 24214800
Compile error:
User defined type not defined
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24214922
What line?
0
 

Author Comment

by:mmorocco
ID: 24215016
It highlights this line - not including the word Dim

Dim WithEvents olkArchiveTask As ScheduledTask
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24215107
Did you follow all the instruction in part 1?  The only way that line would generate that error is if the code in step hasn't been added or the class module it is in wasn't named correctly.
0
 

Author Comment

by:mmorocco
ID: 24218582
BINGO!
SUCCESS!

Where i had named it in properties window i had "ScheduledTask" but in the code had it as 2 separate words.
at least i think thats what did it!
But it works.  it fired just now.
Except - it looks like it ran twice?  I got two copies in my outlook for the same task.
One is named the same as the original folder - and the other has the date - name format from the code.

And I got an error saying the folder already exists.  And the Debug took me to the Module1 line of:
 olkBackup.Name = Format(Date, "YYYY-MM-DD") & "Public Folder Backup" highlighted in yellow.

did I do something twice?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24219112
Did you switch the code out and use the version in 24175855?  I ask because I changed the file naming convention in that version to use

olkBackup.Name = Format(Date, "YYYY-MM-DD" & ) & " Backup of " & olkPublicFolder.Name
0
 

Author Comment

by:mmorocco
ID: 24219135
No, I didn't.
I stayed with the first version because I am only concentrating on doing one folder - the public calendar - right now.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24219192
Ok.


Are you sure one of the folders wasn't left over from previous testing?  How about deleting both and scheduling the task again?
0
 

Author Comment

by:mmorocco
ID: 24219270
thats what i was doing right now...back at you in a few
0
 

Author Comment

by:mmorocco
ID: 24219337
here is my module1
Sub BackupPublicFolder()

    Dim olkPublicFolder As Outlook.MAPIFolder, _

        olkArchivePST As Outlook.MAPIFolder, _

        olkBackup As Outlook.MAPIFolder

    'Replace the folder path on the next line'

    Set olkPublicFolder = OpenOutlookFolder("Public Folders\All Public Folders\Winter Reporting Calendar")

    'Replace the folder path on the next line'

    Set olkArchiveFolder = OpenOutlookFolder("Mailbox - Matt Morocco\Calendar\Public Backup")

    Set olkBackup = olkPublicFolder.CopyTo(olkArchiveFolder)

    olkBackup.Name = Format(Date, "YYYY-MM-DD") & "Public Folder Backup"

    Set olkBackup = Nothing

    Set olkArchivePST = Nothing

    Set olkPublicFolder = Nothing

End Sub

 

Function IsNothing(obj)

  If TypeName(obj) = "Nothing" Then

    IsNothing = True

  Else

    IsNothing = False

  End If

End Function

 

Function OpenOutlookFolder(strFolderPath As String) As Outlook.MAPIFolder

    Dim arrFolders As Variant, _

        varFolder As Variant, _

        olkFolder As Outlook.MAPIFolder

    On Error GoTo ehOpenOutlookFolder

    If strFolderPath = "" Then

        Set OpenOutlookFolder = Nothing

    Else

        Do While Left(strFolderPath, 1) = "\"

            strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)

        Loop

        arrFolders = Split(strFolderPath, "\")

        For Each varFolder In arrFolders

            If IsNothing(olkFolder) Then

                Set olkFolder = Session.Folders(varFolder)

            Else

                Set olkFolder = olkFolder.Folders(varFolder)

            End If

        Next

        Set OpenOutlookFolder = olkFolder

    End If

    On Error GoTo 0

    Exit Function

ehOpenOutlookFolder:

    Set OpenOutlookFolder = Nothing

    On Error GoTo 0

End Function

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24219345
here is my class module
'Events'

Event TaskFired()

 

'Constants'

Private Const CLASSNAME = "ScheduledTask"

 

'Class Variables'

Private WithEvents olkReminders As Outlook.Reminders, _

    strTaskName As String

 

Private Sub Class_Initialize()

    Set olkReminders = Outlook.Application.Reminders

End Sub

 

Private Sub Class_Terminate()

    Set olkReminders = Nothing

End Sub

 

Private Sub olkReminders_ReminderFire(ByVal ReminderObject As Reminder)

    Dim olkTask As Outlook.TaskItem

    If ReminderObject.Item.Class = olTask Then

        Set olkTask = ReminderObject.Item

        If olkTask.Subject = strTaskName Then

            ReminderObject.Dismiss

            With olkTask

                .Complete = True

                .Save

            End With

            RaiseEvent TaskFired

        End If

    End If

End Sub

 

Public Property Let Name(strName As String)

    If strName <> "" Then

        strTaskName = strName

    End If

End Property

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24219349
here is my this outlook session

the task should run any minute now


Dim WithEvents olkArchiveTask As ScheduledTask

 

Private Sub Application_Quit()

    Set olkArchiveTask = Nothing

End Sub

 

Private Sub Application_Startup()

    Set olkArchiveTask = New ScheduledTask

    With olkArchiveTask

        'Enter your task name on the next line'

        .Name = "CalendarBackup"

    End With

End Sub

Private Sub olkArchiveTask_TaskFired()

    BackupPublicFolder

End Sub

Open in new window

0
 

Author Comment

by:mmorocco
ID: 24219772
ok.  it ran - only one folder appeared.  no errors!  Woohoo!
looks like i am in business.

I REALLY appreciate the back and forth and patience.  this has been great, and a great learning experience.  I have had a few other questions about the functionality of this script and what else I can do with it float in and out of my head the last few days as we have gone back and forth - and so I would like to keep this open and see if I can impose upon you for a little more help as this type of thing may be a huge answer to lots of issues and concerns I have had, and a remedy to many problems.

I would like the time to create another project using the revised code and test that and make sure I get it right and have no questions - and then I would just like to make sure I am able to save/export this project and put it on one or two other machines and set tasks and automate some ongoing backups throughout the week.

Again, thanks!  I will work on the second project and saving and loading it onto another machine and hopefully be in touch tomorrow and we can put this one to bed.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24220356
Cool.  You're welcome.  I'll be here when you're ready to proceed on.
0
 

Author Comment

by:mmorocco
ID: 24238562
Hey BlueDevilFan - unfortunately - not sure I got this right.  Thought I had it.  But the last 2 nights - I got that same issue where it seems to be running twice.  I get one folder named with the Date/Name format that is  in the Code - and another folder named the same as the original that is being backed up - and am getting errors about "the folder already exists"

I am probably going to wipe the slate clean tomorrow and start over and test and see what happens.  If you could look at the code I posted above it has not changed - maybe there is something you see there that is out of place?

Otherwise - when I go to start over - I was thinking about using the revised code.  Does it ONLY work if you are doing multiple folders?  What if you leave one of the sections as is and do not modify?  Or can you simply delete one of the sections?

thanks!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24240088
"I got that same issue where it seems to be running twice. "
Is the task scheduled to run twice in one day?  Make sure there aren't duplicate copies of any of the code.

"maybe there is something you see there that is out of place?"
Everything looks right.

"Does it ONLY work if you are doing multiple folders?"
No.  You can comment out or delete one of the blocks of code in that routine that backs up a given folder.
0
 

Author Comment

by:mmorocco
ID: 24253507
Okay - so i deleted the task altogether - checked over my code - which hahs not changed since i posted it above, and am re-scheduling the task now to run shortly and see how it goes.

QUESTION:  I am using an Outlook profile with multiple mailboxes open within it.  
It appears as though the Task should be scheduled under whichever mailbox is the main/default/top account for this profile, correct?
If so or if not so:
Does it matter where I point the backup to go?


I created the VB Macro under a profile where the main mailbox is called Jackson.
Also open in this profile is my mailbox thompson.

So, i schedule the task under Jackson, even though the backup is going to go to a folder under thompson?  is that any problem here?

i will post back again once the task runs.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 300 total points
ID: 24253797
"It appears as though the Task should be scheduled under whichever mailbox is the main/default/top account for this profile, correct?"
Correct.

"is that any problem here?"
There shouldn't be.

0
 

Author Comment

by:mmorocco
ID: 24263539
OK, once again, everything seemed to have run fine last night.  
Am going to let it go for one more day and will hopefully report to you tomorrow that all is well and case closed and points awarded.
thanks for hanging in there.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24265558
No problem.  Thanks for the update.
0
 

Author Comment

by:mmorocco
ID: 24266825
OK,
so ti seems to be working just perfectly on my machine for the last couple days.

I also appear to have successfully exported and imported it onto another user's station and it also worked there successfully as well.

whew!

this is excellent!  really want to say thanks - i learned something here.

points are yours - congrats i see you hit a milestone in points - very cool.

0
 

Author Closing Comment

by:mmorocco
ID: 31569753
This was perhaps my best exchange yet on he site.  I put the solution as one of the coments but there were several parts to the solution throughout the back-and-forth.  Thanks again BlueDevilFan!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24268116
Thanks and you're welcome.  I'm very glad I was able to help.  If you ever want to draw my attention to a question, then my email address is in my profile.  Cheers!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
how to add IIS SMTP to handle application/Scanner relays into office 365.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now