Create a local replica of your mail file using LotusScript

I recently had the need to create local mail file replicas for a bunch of folks. This is something that *had* to be in place for a certain time but we wanted people to be able to create the replicas at a time of their choosing up until the drop dead date.

So I have two versions of this code. The first, which I’m not posting here because it’s a part of a much larger housekeeping module invoked from the PostOpen event of the user’s mail file, gives no choice to put it off. The end user will receive a dialog indicating what is about to happen and then the replica creation will kick off.

The second, which is sent as a button in an email explaining to the user why they would want to do this and that this allows them to run it at a time of their choosing, I include below. It has some friendlier dialogs for the end user.

When run, the code will pop up a message box explaining what is about to happen and give them an opportunity to stop before they get started.

Then I check to make sure they are the owner of the database (so an admin opening the message on their manager’s behalf doesn’t inadvertently create a local replica of the managers file on their own workstation).

Then – and this is probably overkill – I make sure that the user is explicitly in the ACL (not in there via a group) and is a Manager. In our environment this will always be the case so it doesn’t hurt to leave this check in.  You can probably delete it. This was put in out of a concern that folks would open this in a misconfigured mail-in database (where the owner in the preferences had been allowed to default to the users name instead of that of the mailbox). We manage access to our mail-in databases via groups so it would be unusual for the user to be explicitly listed and HIGHLY unusual for them to have manager access under any circumstances.

I then validate whether or not there already exists a file with the same name and along the same path as the one I wish to create. I’m lifting the path and file directly from the server-side database. I’ve actually come across a few cases where folks have local mail file replicas with completely different names and/or in surprisingly different folders than you would expect. Ah… the creativity of the end user!  For our purposes we need to have the file path and name consistent between the local and server copies.

Note that for the LotusScript Dir$ command, Notes will only return an empty string if the file doesn’t exist. If the containing folder doesn’t exist you will receive an error “76” . But if you create a handler that contains simply “Resume Next” Notes will gleefully pick up INSIDE the conditional statement. I was prepared to create a Boolean variable that would be set if either the file was not there or would be set in the error handler but I was able to take this little bizarre shortcut.

The tricky part for me was to get the new replica to show up automatically on the replication tab. For this I need to thank Notes 411 for a little bit of code that I really should have figured out for myself. This is what the UIWorkspace is doing in the code. Basically you just open both replicas in the UIWorkspace and they will be added to the replication tab. Easy as pie. I did not have any issues getting the replica appear on the workspace as the Notes 411 logic also purports to do.

Once done, I let the user know and exit the script.

This is designed to work on Lotus Notes 6.5.x and 7.

Sorry about the lack of formatting, WordPress seems to have taken to stripping it out.

Sub Click(Source As Button)
‘Check if there is a local mail file replica and create one if it doesn’t already exist.
‘Created by Marc Bourassa – July 16, 2010

Dim Sess As New NotesSession
Dim ws As New NotesUIWorkspace
Dim dbUI As NotesUIDatabase
Dim db As NotesDatabase
Dim ACL As NotesACL
Dim ACLEntry As NotesACLEntry
Dim dbLocal As NotesDatabase
Dim docCalProf As NotesDocument
Dim namName As NotesName
Dim sDataDir As String
Dim iRC As Integer
Dim sMsg As String
Dim sPrintText As String

On Error Goto ErrorGeneral
On Error 4005 Goto ErrorDBExists
On Error 76 Goto ErrorPathNotFound

Set db = sess.Currentdatabase

sMsg = “This button will create a local replica of your mail file (” & db.Title & “) if one does not already exist with the correct name.” & Chr$(13)& Chr$(13)&_
“Please press OK to continue or CANCEL to Abort”

iRC = Messagebox(sMsg,49,”Create Mail File Replica”)

If iRC = 1 Then
Set docCalProf = db.GetProfileDocument(“CalendarProfile”)
Set namName = New NotesName(docCalProf.Owner(0))
If namName.common = sess.Commonusername Then ‘User is the owner of this mail database
Set ACL = db.Acl
Set ACLEntry = ACL.Getentry(namName.Abbreviated )
If Not ACLEntry Is Nothing Then
If ACLEntry.Level=ACLLEVEL_MANAGER Then ‘User is explicitly in ACL AND is a manager
sDataDir = sess.getenvironmentstring(“Directory”,True)
If sDataDir = “” Then ‘something probably wrong with ini file. Don’t expect system to work correctly
Messagebox “There is a problem retrieveing your data directory information from the notes.ini file. Cannot proceed. This issue needs to be resolved by the helpdesk. Aborting Replica Creation.”,0,”Create Mail Database Replica”
Goto LeaveSub
End If
If Dir$( sDataDir & “\” & db.Filepath, 0 ) = “” Then ‘No replica by this name exists. Will fail to next line from error handling if path is bad (i.e. missing mail folder)
Call db.Createreplica(“”, db.Filepath)
‘Now add to the Replication tab
Call ws.opendatabase(db.Server,db.FilePath)
Set dbUI = ws.CurrentDatabase
Call ws.opendatabase(“”,db.FilePath)
Set dbUI=ws.CurrentDatabase
Messagebox “Local mail file replica has been successfully created (” & db.Title & “).”,0,”Create Mail Database Replica”
Messagebox “Replica already exists for your mail file (” & db.Title & “). Nothing to do here.”,0,”Create Mail Database Replica”
End If
End If
Messagebox “You are not a manager of this mail database (” & db.Title & “). Aborting Replica Creation.”,0,”Create Mail Database Replica”
End If
Messagebox “You are not the owner of this mail database (” & db.Title & “). Aborting Replica Creation.”,0,”Create Mail Database Replica”
End If
Messagebox “Replica Creation cancelled by you.”,0,”Create Mail Database Replica”
End If

Exit Sub

Resume LeaveSub

Resume Next

sPrintText = “Error: ” + Cstr(Err) + ” defn: ” + Error$ + “. ”
Messagebox sPrintText & Chr$(13) & Chr$(13) & “Could not complete this task you will need to create this replica manually. Please contact the help desk for assistance.” ,0,”Unexpected Error”
Resume LeaveSub

End Sub

Posted under Lotus Domino, Work Portfolio

This post was written by Marc
on July 19, 2010 at 8:28 am

Battle of the Chocolate Milks – Mayfield Lowfat Chocolate Milk

Since there is a dearth of whole chocolate milk options to choose from, and I’ve already opened up this challenge to low fat contenders, I couldn’t resist picking up a “Mayfield Lowfat Chocolate Milk” while at the store last weekend.

Interestingly, the half gallon size (at $3.00) as pretty reasonable compared with the whole milk options which were selling for $2.50 for a quart (1/2 of a half gallon if you are used to metric).

Unexpectedly the lowfat option was significantly darker in color than its whole milk alternative. The taste was commensurately more bittersweet as well.

Not unexpected was the viscosity of the lowfat being much lower than that of the whole. This leads to my perceiving it as being somewhat more watery than I would prefer.

Surprisingly, on its own, it would could well have been passable. But contrasted with the current front runner (Mayfield Whole Chocolate Milk) the lowfat version stands tied for second place with Whole Food’s Whole Chocolate Milk offering.

Posted under Gastronomy, Opinions

This post was written by Marc
on July 14, 2010 at 8:45 am

Socialized Medicine – Looking Better and Better – I’m about to do the MRI Thing

For those that don’t know, I hail originally from Canada. There is a lot about America that attracts me and “Government staying out of my affairs” is a biggie. It is with no surprise then that I was very much in favor of shucking off a socialized medical system and its shortcomings for a more pay as you go system.

When I arrived here I was healthy and did not have kids so my contact with the medical system was minimal. Pretty much limited to a general physical now and then.

As I live here longer, I’m starting to grow more and more fearful of the financial repercussions of even a modest illness and find myself hesitant to take advantage of what is arguably one of the best medical systems in the world.

I’ve had a couple of procedures done over the past half decade or so and found myself annoyed that it is very difficult to get a cost for a procedure. They seem easily able to give you a bill before you go into the operating theater but try to get that bill amount when you are setting the appointment and people seem confused. On top of the, rather substantial, bill that you pay up front. The little bills that keep floating in weeks or months later are unexpected and annoying. When you call about them you will find that they are “usual and customary” but that is only for folks in the billing departments of hospitals or in insurance departments.

If I went to a mechanic and had my transmission replaced you can be sure that I am going to get an estimate from him. That estimate better be what I’m charged at the end unless something unusual comes up and, if it’s substantial, I expect a further call to ensure that I want the extra work done (maybe they notice a broken support for the engine while they’ve got the car up on the lift). You can be damn sure I’m not going to be receiving a bill from the “Oil Support Technician” or “Hydraulic Lift Specialist” two months after the fact because they consider it “Usual and Customary”.

In medicine it seems perfectly OK to have essential folks’ services completely omitted from any estimates. I had a hernia operation about 6 years ago and the anesthetist’s (or anesthesiologist’s – can never keep those two straight)  services, something that I consider quite essential when I’m to be rendered unconscious for surgery, were charged for separately at least a month after the fact. I had to call to see if this was legit or some kind of scam because I was so amazed at this boldness.

I need to have an MRI to sort out some issues left over from my bicycle accident a few months back. On Friday my doctor tells me he’ll begin a precertification for this. Today I receive a call from the MRI place to schedule an appointment. I went ahead and set up a date and decided to persue this to see if it’s possible to determine one’s liability and maybe plan for this kind of thing.

The girl on the phone for scheduling, of course, can do nothing for me to help nail down the cost of this thing. So I contact my insurance company. After 15 minutes waiting on the phone I find out that my insurance company contracts out radiology type stuff to a 3rd party precertification company. I’m told I need to call back if I want to find out more about costs because their department also doesn’t handle that.

So I call the insurance company back. We’ll leave the sorry-ass IVR system out of this conversation suffice it to say that it aided me not at all in getting to a customer service rep. All the rep is able to tell me is that I’ll have a $500 deductible and then I’m responsible for 20% of the cost beyond that. OK, that’s in my benefits plan. How much does this kind of procedure cost?  All he is able to tell me is that it will be a negotiated amount and that my liability will be as he’s already said.

So I contact the third party pre-cert group and find that my doctor’s office hasn’t yet initiated the precertification process with them and that my plan is the kind where only a doctor or the MRI folks can initiate the process. But that this process typically takes one business day, so my appointment (scheduled for next week) is not yet in jeopardy.

So I contact my doctors office to see what needs to be done, they acknowledge that they need to initiate this and that they’ll call me back.They call back within the hour and it turns out that this is the normal way that things are done since the pre-cert company likes to know where and when the procedure will occur. So I’ve jumped the gun on this part but they tell me that everything is now in place.

Finally I call the billing department of the MRI folks. It took them 10 minutes to figure out how much this was going to cost me. When I asked if this was an all inclusive price, explicitly mentioning that there’ll be someone administering an IV they did agree that I can expect another, separate bill from them that should only be in the range of “a hundred or so dollars”.

So, an MRI of my head, both with contrast and without will cost me no less than $868. With a little math that puts the “negotiated cost” at $2,340. Then I can expect at least another $100 bill to come floating in sometime after that for the IV person and I have no idea how many other folks it is “usual and customary” to have wander into the room while the procedure is under way and then send me a bill.

The care we have available might be some of the best in the world, but the cost for that care is terrifying – for its magnitude certainly but more so for its quixotic cost. For all its pitfalls, under a socialized medical scheme for all but the most catastrophic of issues my liability is capped so I do not have to put my self or my family at financial risk – heck it’s not even a risk because you cannot even begin to forecast the costs before you begin it’s really more of a game of chance than anything that can be calculated.

So color me leaning back in favor of the socialized medicine side of the debate.  If we can get to a system where I can get off the phone with an appointment and a guaranteed estimate (representing the cost both with and without insurance) and none of those “gotchas” that make this such a risk I will rethink this. Hell I can do it for my car, my cat and my washing machine. Surely we’ve got enough knowledge and experience to estimate simple procedures accurately by now.

Posted under Medicine, Opinions, Retail Experiences

This post was written by Marc
on July 12, 2010 at 4:49 pm