Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

local mail size 1

Status
Not open for further replies.

unixisbest

Technical User
Jul 11, 2005
28
0
0
Hi all,
Is there a way to get a warning message if any of local mail file size gets bigger than 900 mb.
I had an idea like writing a code by VisualBasic to do this. But i am gonna need to know where mail files place in the disk and with what name. So it wouldn`t be easy way.

Thanks for any help
 
By local, you do mean a replica of the server copy of the user's mail file stored on his local disk ?
Even if you mean the server copy, a simple Database Script would do fine. Would you like an example ?

Pascal.
 
Hi Pascal
Yes i mean replica of the server copy.
Would you send me an example please?
 
Simply copy this into your PostOpen event in the Database Script, and modify as you see fit :
Code:
Sub Postopen(Source As Notesuidatabase)
	
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Set db = session.CurrentDatabase
	
	Dim subString As String
	Dim size As Double
	size = Round(db.Size/1048576, 0)
	Dim quota As Long
	quota = Round(db.SizeQuota/1024, 0)
	
	If quota = 0 Then
		Close
	Else
		If size > quota Then
			substring = substring & "your error message here"
			Msgbox subString
		Else
			
			If size => (quota - 10) Then
				substring = substring & "your error message here"
				Msgbox subString
			End If
		End If
	End If 
End Sub
 
Thanks for help Pascal.
But i am really sorry that my Lotus knowladge is not so good enough to do this. So would you please make it a little bit more clear for me.
Should i open replica copy file with designer to add this. Please tell me step by step, and one more question if this works for me will i have to add this script all of my users manually?

Thanks again.
 
Okay, we're getting into tricky territory here. First, you don't know Notes design, and second, you want a modification of the mail template. That is a bit delicate for winging it the first time.
I'm going to try to give you some pointers, but you must realize that we're dealing with the communication infrastructure of your entire company. If, at any point, you don't feel sure of yourself, it yould be better to get a consultant on-site to do the job. Better safe than very sorry. Especially since I can always tell you what to do, but I won't be there to recover the pieces if they fall apart.
Now that I have (hopefully) sufficiently scared you, let's try to get the ball rolling.
First thing : we're going to try to get this working for one user. We'll worry about updating the others after. I suggest therefor that you work on your own mailbox. If that breaks, you won't be impacting anyone else.
Actually, the very first question is : do you have the Notes Designer installed ? Without it, you're not going anywhere.

Pascal.
 
Hi Pascal,
To be honest i got scared enough. So i am going to be carefull and first i am gonna work on my mail.But don`t worry that i know the rule from Unix as my handle says `think one more time before hit the enter key`
Yes i have Notes Designer installed. So what is the next step?
 
Ok, good first start. Have you ever looked at your mail file design ?
A mail db depends on a standard template. A template in Notes is a specific db that houses the design of all production dbs that reference it. You can find that reference if you open the Properties dialog of the database (file/database/properties). Look at the middle tab (the one with the hammer and square ruler), you have a middle section labelled "Inheritance". That is where the reference design is designated ("Inherit design from master template").
Just under that, you have another checkbox ("Database file is a master template") and a name field underneath. This is where you can define your db as a design reference for any other db that would like to use your design.
You can actually use both simultaneously. In other words, you can create a variation of a standard design, and define the variation as the standard for your corporation. We'll do that when your code works fine on your mail file.

For now, open your mail file in Design mode and check the design categories on the left hand side. You should see a list with
- Framesets
- Pages
- Forms
- Views
- Folders
- Shared Code
- Shared Resources
- Other

We are interested in Other right now. Click on that, and you should see a sublist comprised of :
- Database Resources
- Navigators
- Synopsis

Now we want to go into the Database Resources. One click is enough, and it opens a different list in the right-hand panel. You should see :
- Icon
- "Using Database" Document
- "About Database" Document
- Database Script

Now we want to go to Database Script. You need to double-click here to open it.

If all is right, the right hand panel has now divided itself into two parts : a navigation section (on the left), and a code section (on the right).
Here is where the work is actually done. The navigator contains a list of event names - each name corresponds to a specific event in the everyday life of the database.
We want to modify the PostOpen event. One click on that name, and you will see code on the code panel (the right-hand side).
That code should just be a placemarker :
Code:
Sub Postopen(Source As Notesuidatabase)
	
End Sub

If it looks any different, we abort now !

If that is what you see, then you can actually copy/paste the example I gave you over the code in the database.
There should not be any errors yet - but you will have to reconfigure your error messages.

So, any problems with that ?

Pascal.
 
Ok ,i did all you said and it works well. But i got confused with two lines and i have changed them as below. Because my db.sizequota gave me `0` as a value.

size = db.Size
Dim quota As Long
quota = 90000000


So if these changes ok ? Can we go to next step please?
 
Well if you don't have a db quota, then you can implement one. I would suggest a test, though, because the admin might implement a quota one day. So you might want to implement something like this :
Code:
quota = Round(db.SizeQuota/1024, 0)
If quota = 0 then quota = 90000000
. . .

So, if all went well, you should now have code that will alert the person opening the db when the db reaches the size you indicate as threshold.

As a test, I would lower the quota below the current db size in order to be sure that a message should pop up. Make changes to the quota size and test every step of alert you wish to implement.
Once you are satisfied everything is working, then you can go on to implementing the code in the mail template.

That operation is frighteningly simple : just copy/paste your code in the same place in the server file named mail6.ntf.
You will get a warning from Notes, which is normal because you are making a change to the official Notes mail template, and you are not a Notes employee.
Once you save the changes, you'll have to wait until the next day to see the result - panic, or success.

Any questions ?

Pascal.
 
Hi Pascal ,
Sorry that i am late to answer. I haven`t applied this to users accounts yet. I want to test it on my mail for a while before apply all. And i have some questions. If i add these lines to my local replica of mails database it makes same my account database on mail server as well because of scheduled replication. And size limit is under 200 mb on mail server so it can`t work properly as we want. I can make this disable by unchecking replica settings fields but it would also effect some changes we don`t want as well. So is there a way to apply this as only works for local copy.
And another question is ,
In your solution a user get warning message when local mail size gets more than 900 mb. So can u change it to exit session when user open the local copy without doing any changes like creating new local file even see the warning message. You know otherwise some of users will just click to Ok button and keep making size bigger.

Sorry if i am beign too much.

Thanks for helping
 
The size limit you wish to alert about is totally artificial. Since R5, Notes databases are limited only by disk space.
Therefor, there is no need to implement an "increase limit" functionality. If your only goal is to display an alert every 100MB (or other interval), then this code can be useful. Outside of a admin-imposed quota, there is no way to limit db size via code.
The code WILL be replicated everywhere, so if you only want it to work locally, you have to check that the server name is empty like this :
Code:
if db.server = "" then
...
end if

If you wish to create a new db for every 900MB of mail, then I can only say that you're in for a heap of trouble. Sure, the code can do it, but the code is not going to be able to decide what mail is not to be copied over, or which ones are supposed to be deleted anyway.
Could I suggest using the archive function instead ?

Pascal.
 
Hi Pascal,
The codes work well as i want. Thank you for helping to me.
My next step going to be apply this codes to all users. As i mentioned before i was having problem with replication. When replicate the mailbox the replication was making the same local mailbox designs with other mailbox which is on the server. So i have unchecked the ticks from advanced menu of Replication Settings. So when that replicate the mailbox it`s only copis the mails not the designs as well. And then i remove the lines from their mailbox on the server to make codes work for only local mailboxes.
So how can i apply this to users ?

 
It is not a good idea to seperate the local design from the server one. When you update the design on the server (via point upgrade or version change), the new design will be different, and that might make problems.
Additionally, with the db.server check, it is not useful to fork the local design, since the code will not be effective on the server.

Pascal.
 
Hi Pascal,
Ok then lets forget this doing by Lotus designer. I know this thread got quite long but one more and last question. Is this possible to write the where local databes path into a text file ?Like c:\mail\LocalMailpath.txt. If we can do this i will write a small code with Visual Basic.
Thanks again
 
Sure, easy.
All you need to do in Script is open a text file and write the contents of db.filepath to it (oh, and don't forget to close the file handle after). Open the text file in a path that includes the user's drive and you're done.
I fail to see why you'd want to do this though. The server name test should be sufficient to ensure the code only runs on the local client.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top