I need a lotus script for mass move of users mail files from one domino directory to another. I've found script for mass user deletion and just replaced method notesAdministrationProcess.DeleteUser
with method noteID$ = notesAdministrationProcess .MoveMailUser
( username$ , newhomeserver$ , newhomeservermailpath$ ) , where is newhomeservermailpath$
- moved
- directory which I previously created to move mail files from default mail folder mail
. Domino console didn't report any error but script doesn't move user's mail files. What is missing? Am I doing something wrong?
Script code:
Sub Initialize
Dim session As New NotesSession
Dim db,addbk As NotesDatabase
Dim usrvw As NotesView
Dim Username As String
Dim movecounter As Integer
Dim nap As NotesAdministrationProcess
Dim FIleNumber As Integer
Dim Filename As String
Set nap = session.CreateAdministrationProcess("MyServer/myserverdomain")
Set db = session.CurrentDatabase
Set addbk=session.GetDatabase("MyServer/myserverdomain","names.nsf",0)
Set usrvw=addbk.getview("$NamesFieldLookup")
filenumber%=FreeFile()
fileName$="D:\moveMail.csv"
Open fileName For Input As fileNumber%
On Error Resume Next
movecounter=0
Do Until EOF(fileNumber%)
Input #fileNumber%,Username
movecounter=movecounter+1
Call nap.MoveMailUser(Username, MyServer/myserverdomain , moved)
Print "Moved" & CStr(movecounter) "Users"
Loop
End Sub
There are -as stated in comments- some major problems with your code:
First: NEVER use "On Error Resume Next" except for expected single errors you want to suppress.
Your case is the best example: Your code fails because of non defined variables, but you will never get an error message because you suppress it: No chance of knowing where it went wrong.
Second: EVER add
Option Declare
to any code you write in LotusScript. There is even a Designer setting to do this automatically. This option would have checked if all variables you use are declared... and would have not even allowed you to save this code.
Third: The errors in code. You managed to produce 2 errors when changing one single line of code...
This is how it looks:
Call nap.MoveMailUser(Username, MyServer/myserverdomain , moved)
This is how it should look:
Call nap.MoveMailUser(Username, "MyServer/myserverdomain" , "moved")
Just look at the difference... I will not start to teach you basics about variables vs. string literals as these are the same for almost every programming language.
-off topic- One more thing: The way you approach business tasks is reckless at least but in any case very dangerous... You seem to copy some code from somewhere but even lack the very basics in coding. Seeing that you delete productive users and move productive mail databases I would be very concerned when I saw you doing this via "trial and error"... But this is just my point of view... -/end off topic-
If you do it in the Administrator client, moving a user's mailfile consist of several steps, see https://help.hcltechsw.com/domino/10.0.1/admn_moveamailfilefromoneservertoanother_r.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.