
E-MAIL
Regular Message Deletion From Users' Mail Files
Bruck Sewnet 03.28.2000
Rating: --- (out of 5)




Mail servers are usually short of disk space due to constantly received and sent messages. To overcome this notify your users about a message deletion strategy and implemented that within a Lotus script in each mail file. The following code is written based on a strategy of deleting messages which are older than three months from both the Inbox folder and the Sent view. The script sends an email message (eventhough it appears to be sent from the users themselves) saying that messages older than three months will be deleted after the users' 10th login to their Inbox, to give them time to archive important messages. You can customize the code as to your strategy. You can put this code in the mail file template of your system, mail46.ntf or mailc46.ntf. I put it in the Folder design, ($Inbox) view, Postopen event for the Inbox Folder. Once you do this you can replace the design of users' mail file using the following command from the server console: Load Convert -s mail*.nsf StdR4Mail mail46.ntf(the -s parameter will preserver any customizations made to mail file designs by users) or if the Design task runs according to a schedule it will refresh the design of the mail files the next time the task runs
Code
Function FindFile(FName As String) As Integer 'Function to check if a file exists or not Dim Path As String Dim FileName As String, exists As Integer Path = "C:
otes" FileName = Dir$(Path, 0) exists = 0 Do While FileName <> "" If Instr(1, FileName, FName, 1) > 0 Then exists = 1 FileName = Dir$() Loop FindFile = exists End Function Function ReadIntFromFile (FName As String) As Integer 'Function to read a parameter from a file Dim fileName As String Dim value As Integer fileNum% = Freefile() fileName$ = FName Open fileName$ For Input As fileNum% Input #fileNum%, value ReadIntFromFile = value Close fileNum% End Function Function WriteIntToFile (FName As String, value As Integer) As Integer 'Function to write a parameter to a file Dim fileName As String fileNum% = Freefile() fileName$ = FName Open fileName$ For Output As fileNum% Write #fileNum%, value Close fileNum% End Function Function SendMailMemo(sendTo As String, subject As String, body As String, sess As NotesSession) As Integer 'Function to send a mail message to a user Dim mailDb As New NotesDatabase("", "") Dim mailDoc As NotesDocument Dim rtxtItem As NotesRichTextItem Call mailDb.OpenMail If (mailDb.IsOpen = False) Then Call mailDb.Open("", "") Set mailDoc = mailDb.CreateDocument mailDoc.Form = "Memo" mailDoc.SendTo = sendTo mailDoc.Subject = subject Set rtxtItem = mailDoc.CreateRichTextItem("Body") Dim richstyle As NotesRichTextStyle Set richstyle = sess.CreateRichTextStyle richStyle.Bold = True Call rtxtItem.AppendStyle(richStyle) richStyle.NotesColor = COLOR_BLACK Call rtxtItem.AppendStyle(richStyle) Call rtxtItem.AppendText("Messages older than three months will be deleted after the 10th login to your Inbox") 'Customise 'this message as to your need Call mailDoc.Send(False) SendMailMemo = True End Function Dim session As New NotesSession Dim db As NotesDatabase Dim view As NotesView Dim doc As notesDocument Dim doc2 As NotesDocument Dim CreatedDate As Variant Dim SendFlag As Variant Dim user As String user = session.CommonUserName 'Get the current mail user Common Name Set db = session.CurrentDatabase 'Get the current db which is the mail file Dim DateToday As String DateToday = Today() Dim yr As Integer, mon As Integer, dy As Integer yr = Year(DateToday) mon = Month(DateToday) dy = Day(DateToday) Dim FileExist As Integer 'Check if C:
otesDelete.txt and C:
otesNoOfOpens.txt are existant. If they are not 'create the files and write 0 to them. FileExist = FindFile("delete") If FileExist = 0 Then Call WriteIntToFile("delete.txt", 0) FileExist = FindFile("NoOfOpens") If FileExist = 0 Then Call WriteIntToFile("NoOfOpens.txt", 0) Dim UserNotified As Integer UserNotified = ReadIntFromFile("delete.txt") Dim buffer, buffer2 As Integer Dim NoOfOpens As Integer buffer = mon NoOfOpens = ReadIntFromFile("NoOfOpens.txt") 'Perform the Notification and Deletion if '1.Delete.txt is created for the first time, 2.If it is a new month If (UserNotified = 0) Or (UserNotified <> mon) Then If (NoOfOpens = 0) Then Messagebox "Attn: Messages older than 3 months will be deleted after you have opened your Inbox 10 times from now on. Please take the necessary measures.", 64, "Message Deletion" End If buffer2 = mon mon = mon - 3 If mon = -2 Then mon = 10 'If month is January set the deletion for October
 |

|
Rate this Tip
|
To rate tips, you must be a member of SearchDomino.com. Register now
to start rating these tips. Log in if you are already a member.
|


');
// -->
DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.
|
 |
|
|
 |
|
 |