I responded to a post concerning the use of Convert when upgrading mail templates, that you have to be careful that the Prohibit Design Refresh flag is set correctly with some folders in users' mail files. Charles posted that he, too, had this issue, but he had some code that would loop through the Domino Directory, looking at all of the mail files on the server and then correctly set the flag. This is a great tip, and I had to share it with you.
Here is his post.
And here is the code.
Sub Initialize '*** January 21, 2005 - Charles Robinson '*** Set the Prohibit Design Refresh flag on all non-template views and folders '*** to prevent a design refresh from overwriting user-created folders '*** On Error Goto ErrTrap Dim nLog As NotesLog Set nLog = New NotesLog("Set Prohibit Design Refresh for Mail") Call nLog.OpenAgentLog Dim nSession As NotesSession Dim nDBNAB As NotesDatabase Dim nDBMail As NotesDatabase Dim nDBNTF As NotesDatabase Dim nVW As NotesView Dim nDoc As NotesDocument Dim nDCPeople As NotesDocumentCollection Set nSession = New NotesSession Set nDBNTF = nSession.GetDatabase("mail/wmbird", "wmbinot6.ntf", False) Set nDBNAB = nSession.GetDatabase("mail/wmbird", "names.nsf", False) Set nDCPeople = nDBNAB.Search({Form = "Person"}, Nothing, 0) Set nDoc = nDCPeople.GetFirstDocument Do Until nDoc Is Nothing Set nDBMail = nSession.GetDatabase("mail/wmbird", nDoc.MailFile(0), False) If Not nDBMail Is Nothing Then Forall vw In nDBMail.Views 'See if the view in the mail file exists in the template Set nVW = nDBNTF.GetView(vw.Name) 'If not set the prohibitdesignrefresh flag vw.IsProhibitDesignRefresh = (nVW Is Nothing) End Forall End If GetNextDoc: Set nDoc = nDCPeople.GetNextDocument(nDoc) Loop Set nVW = Nothing Set nDBNAB = Nothing Set nDBNTF = Nothing Set nDBMail = Nothing Set nDCPeople = Nothing Set nSession = Nothing Exit Sub ErrTrap: Call nLog.LogError(Err, "Unable to modify database " & nDoc.MailFile(0)) 'This is necessary to prevent logging an error for every folder and overflowing the agent log Resume GetNextDoc End Sub
provided by Julian Robichaux at nsftools.com.
Technorati tag: Show-n-Tell Thursday Lotus Lotus Domino
Comment posted by Charles Robinson09/21/2006 02:44:47 PM
Homepage: http://cubert-codepoet.blogspot.com
Thanks for the pat on the back, Gregg. I'm glad you found this useful.
Comment posted by Curt Stone09/21/2006 09:28:41 PM
Homepage: http://curtsisland.blogspot.com
Good stuff. Being a developer with plenty of apps to keep me busy, I rarely get involved with mail templates. But I remember an incident where I work now where the help desk replaced a shared mail account and blew away some user created folders. The users were pissed and they thought they lost their mail. Of course, they didn't lose the mail docs, just the folders. Some senior vp's sent a couple notes out and my boss asked me to investigate what happened. I believe the admins went though a process like this to identify any others we may have this issue.
Comment posted by Gregg Eldred09/21/2006 09:36:43 PM
Homepage: http://www.ns-tech.com/blog/geldred.nsf
First, @Charles, this is some excellent work and needed to have the attention. Lord knows that I could have used it in the past.
@Curt, I am always amazed at the number of Domino Admins who don't do a lick of coding. This is a perfect example, where some code will save you the headaches later. I am not nearly in the same ballpark as most of you, but I know my way around the Designer Client and the @Commands and Functions. I have been able to script some stuff, too.
I just see it as "self-preservation." (well, and something that makes me just a little bit more than an Admin).
Comment posted by Curt Stone09/22/2006 06:36:23 AM
Homepage: http://curtsisland.blogspot.com
@Gregg,
...and I don't know a ton about being an admin, so we're even. Difference being that where I work, they'll never give me the chance to try admin stuff.
It's important to know the "other" side so you can know the potential and find others to help with the details. One cool thing this code does that some developers don't take advantage of is logging.
@Charles, I just noticed there's no looping through all the databases on a server. That might be something someone might want to do to clean'em all up.
Comment posted by Charles Robinson09/22/2006 10:41:57 AM
Homepage: http://cubert-codepoet.blogspot.com
@Curt - I never thought about that since none of my users ever create folders in our custom apps. If you do want to loop through all the databases on a server use a NotesDBDirectory. Get the template name from NotesDatabase.TemplateName, open it, then do the comparison as I have it above.
Comment posted by Gregg Eldred09/22/2006 03:07:28 PM
Homepage: http://www.ns-tech.com/blog/geldred.nsf
While we are piling on Charles:
This is a small thing, but sometimes people looking for answer are small minded when it comes to the code - in your example you have the server and templates hard coded to something that no one else will have. I wonder if anyone that lifts the code will notice?
And since I am on "rant," don't you love it when you post something like this, and then a person, and I will use Curt as an example (he is NOT representative of this remark) tells you that it doesn't work and wants you, for free, to fix it? I laugh at those remarks.
Comment posted by Charles Robinson09/23/2006 01:58:43 PM
Homepage: http://cubert-codepoet.blogspot.com
Well, you could have modified the code before you posted it, so any misrepresentations on your blog are your responsibility. I posted the code on Notes.Net, which includes a disclaimer somewhere that all code is provided as-is, blah blah blah.
When I provide sample code I usually think about how it would fit other environments. The attempts I make to generalize it are directly proportional to the complexity. This is pretty straight forward and the parts someone needs to replace are fairly obvious, and if it fails the errors will be obvious, too. Perhaps it is elitist of me, but I think if people aren't savvy enough to modify my code for their environments they shouldn't be using my code.
And I agree wholeheartedly about the people who don't even attempt to alter sample code to fit their own needs. (Incidentally, there seems to be an increase of that on notes.net lately.) I rarely make any attempt to help them. In this case I considered that Curt may not know about NotesDBDirectory, but you will notice that I didn't give him the code, just some nudges. I'm not completely heartless but I'm not going to give away the farm, either.
Comment posted by Curt Stone09/25/2006 08:25:21 PM
Homepage: http://curtsisland.blogspot.com
@Charles - I believe your making the point I was referring to. That is, one could use the bulk of this code to solve another problem. I mentioned this because we had a situation where we wanted to loop though all the databases in a directory and check the design refresh property. I'm aware of the NotesDBDirectory because I have used in the past. If I were searching for code in this example, I would have done the "technology transfer"(as we used to call it) and added what I need for the specific situation.
I was just making a point that code snippets often lead to ideas of other uses.
Thanks.
BlogSphere V1.3.1
Join The WebLog Revolution at BlogSphere.net