Home > Domino Tips > Administrator > Address Book > Saving personal addresses to maildatabase
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ADDRESS BOOK

Saving personal addresses to maildatabase


Thomas Ludwig
02.17.2003
Rating: -4.00- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


We had the problem that more and more new computers crashed. All personal names.nsf are on the machines and are deleted. So I developed an agent to save all personal business cards and groups in the maildatabase of the users.



Code

Copy the masks of business cards and groups from the personal address book template into the maildatabase-Template. Copy the view ($People) also to the maildatabase. Make a copy of the ($People)-View and rename the new view to (searchpeople). Just use one column by using the field "type". The selection criteria of the view is:

"SELECT Type = "Person"|Type="Group"".
Put the following code to the 
post-open-event of the maildatabase:

"user := @Name([CN];@UserName);
check :=@Environment("savedaddress");
checkuser := @Left(check;"|");
date := @Date(@Today);
checkdate := @Right(check;"|");
checkdate2 := @TextToTime(checkdate);
checkdays := ((date - checkdate2)/60/60)/24;
@If(checkdays <8;@Return("");"");
@Command([ToolsRunMacro];"savepersaddresses");
@SetEnvironment("savedaddress";user+"|"
+@Text(date))".

By using this postopen-event, the agent to save the addresses will start every 9 days while
opening the mail-database. Agent Nr.1 to start the saving: Mail-ToolsBusiness-Cards backup|savepersaddresses options: Option Public Option Declare Declarations: Dim viewProfile As notesview Dim docCalProfile As notesdocument Dim s As String Dim User As Notesname Dim userabbr As String Dim Owner As Notesname Dim ownerabbr As String Dim dbaddress As notesdatabase Dim dbmail As notesdatabase Dim dcaddress As notesdocumentcollection Dim dcaddressmaildb As notesdocumentcollection Dim searchformula As String Dim searchformdelete As String Dim searchfdname(1) As String Dim docaddress1 As notesdocument Dim docaddress2 As notesdocument Dim viewaddressmaildb As notesview Dim docaddmaildb1 As notesdocument Dim docaddmaildb2 As notesdocument Sub Initialize Dim session As New notessession Set dbaddress = Session.GetDatabase ( "", "names.nsf" ) Set dbmail = session.currentdatabase Set docCalProfile=dbmail. GetProfileDocument("CalendarProfile") s=docCalProfile.getItemValue("Owner")(0) Set Owner=New Notesname (s) Set User=New Notesname (session.Username) ownerabbr = Owner.Abbreviated userabbr = user.abbreviated If Not ownerabbr = userabbr Then Exit Sub searchformdelete = "Type" searchfdname(0) = "Person" searchfdname(1) = "Group" If dbaddress Is Nothing Then Exit Sub Dim dateTime As New NotesDateTime("Today") Dim i As Integer i=0 Do Until i = 2 Set viewaddressmaildb = dbmail.getview("searchpeople") 'Set docaddmaildb1 = viewaddressmaildb.getfirstdocument Set dcaddressmaildb = viewaddressmaildb.GetAllDocumentsByKey(searchfdname(i)) If Not dcaddressmaildb.count = 0 Then Call dcaddressmaildb .removeall(True) End If i=i+1 Loop i=0 Do Until i = 2 searchformula = "SELECT " &"(" & searchformdelete & | = | & |"|
& searchfdname(i) & |"| & ")" Set dcaddress = dbaddress.Search(searchFormula, dateTime, 0) Set docaddress1 = dcaddress.getfirstdocument Do Until docaddress1 Is Nothing Set docaddress2 = dcaddress.getnextdocument(docaddress1) Call docaddress1.copytodatabase(dbmail) Set docaddress1 = docaddress2 Loop i=i+1 Loop End Sub" All the existing addresses are deleted and all the local cards are copied. Agent2 to recover the cards: Mail-ToolsRestore business cards Options: Option Public Option Declare Declarations: Dim viewProfile As notesview Dim docCalProfile As notesdocument Dim s As String Dim User As Notesname Dim userabbr As String Dim Owner As Notesname Dim ownerabbr As String Dim dbaddress As notesdatabase Dim dbmail As notesdatabase Dim info As Variant Dim dcaddress As notesdocumentcollection Dim dcaddressmaildb As notesdocumentcollection Dim searchformula As String Dim searchformdelete As String Dim searchfdname(1) As String Dim docaddress1 As notesdocument Dim docaddress2 As notesdocument Dim viewaddressmaildb As notesview Dim docaddmaildb1 As notesdocument Dim docaddmaildb2 As notesdocument Sub Initialize Dim session As New notessession Dim ws As notesuiworkspace Dim Aend As Integer Aend = Msgbox ("You wan't to restore your business cards to your personal addressbook?" , 4+32, "Restore business cards?") If Aend = 7 Then Exit Sub Else End If Aend = Msgbox ( "You should only use this agent if you don't have any cards in your personal addressbook!" , 4+32,"Restore business cards?") If Aend = 7 Then Exit Sub Else End If Set dbaddress = Session.GetDatabase ( "", "names.nsf" ) Set dbmail = session.currentdatabase Set docCalProfile=dbmail.GetProfileDocument( "CalendarProfile") s=docCalProfile.getItemValue("Owner")(0) Set Owner=New Notesname (s) Set User=New Notesname (session.Username) Ownerabbr = Owner.Abbreviated Userabbr = user.abbreviated If Not ownerabbr = userabbr Then info = Messagebox ("You are not the owner of the database. The agent is stopped.!
" , 0+16, " Kein Eigentuemer!") Exit Sub End If searchformdelete = "Type" searchfdname(0) = "Person" searchfdname(1) = "Group" If dbaddress Is Nothing Then Exit Sub Dim dateTime As New NotesDateTime("Today") Dim i As Integer i=0 Do Until i = 2 Set viewaddressmaildb = dbmail.getview("searchpeople") Set dcaddressmaildb = viewaddressmaildb. GetAllDocumentsByKey(searchfdname(i)) Set docaddress1 = dcaddressmaildb.getfirstdocument Do Until docaddress1 Is Nothing Set docaddress2 = dcaddressmaildb.getnextdocument(docaddress1) Call docaddress1.copytodatabase(dbaddress) Set docaddress1 = docaddress2 Loop If dcaddressmaildb.count = 0 Then info = Messagebox ("Es sind keine Visitenkarten zum RÜcksichern gefunden worden", 0+16, "Keine Visitenkarten vorhanden") Exit Sub End If i=i+1 Loop End Sub"

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.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Address Book
Formula language button manages Deny Access list searches
Find a Lotus Notes user within NAB Deny Access groups
Synchronize LinkedIn contacts with Lotus Notes Domino
How to correct Lotus Notes public key mismatches in four easy steps
Creating a Lotus Notes Personal Address Book replica
Admin user unable to create NAB
@Transform formula for use in R6
Change NAB while maintaining integrity of documents
NAB: A key piece of the Domino administration puzzle
Build an extended directory catalog

Lotus Notes Domino Agents
How the Agent Profiler tool improves Notes/Domino performance
Run or restart Notes/Domino agents via text messages
Calculating results for a column in a Lotus Notes view
Approve Lotus Notes documents using a BlackBerry mobile device
LotusScript agent indexes Lotus Notes/Domino databases
Top 10 Lotus Notes/Domino coding and development tips of 2008
Open documents in Lotus Notes from the Web without a UNID
Fix and update Lotus Notes documents with limited access
Verify scheduled agent status with Domino Extensible Language (DXL)
Top 10 Lotus Notes Domino programming and development tips of 2007

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts