Link to home
Start Free TrialLog in
Avatar of RichardStarkey
RichardStarkey

asked on

Getting the location of a users local mail file


Hi All,

I want to be able to write documents to a users calender.  I am currently doing this fine using the folloiwng code

      'Get users mail databases and create a new document
      mail = Evaluate(|@MailDbName|)
      Set maildb = New NotesDatabase( mail(0) , mail(1) )

The problem is this does not work for all users for some reason.  And it also means it will not work if the user is working offline.  What I think I need to do is get the code for looking for the local replica of the mail and use this.  Is that possible?

Thanks,
Stuart
Avatar of RichardStarkey
RichardStarkey

ASKER


I have also tried the following...

      Dim maildb As New NotesDatabase( "", "" )
      Call maildb.OpenMail
      Set appt = maildb.CreateDocument

It seems to work when pulling in from the mail file but not when writing to it.  Requires the server for the CreateDocument argument

Hi !

Your earlier code (MailDbName approacy) works only if the user's location document (mail tab) points to the server mail copy. If the user is using the local mail replica, your @maildbname's will return "" for server and the local mail replica location for the mail database location. To over come this problem.

You could write something like the following....

dim server as string
dim mail as string
dim localmailreplica as notesdatabase
Dim servermailreplica As new NotesDatabase("","")
dim localrepid as string

 mail = Evaluate(|@MailDbName|)

if mail(0) = "" then 'if the user is using a local mail replica (mail tab - location doc)
server = s.getenvironmentstring("MailServer") 'get the mail server from the Notes.INI - environment variable
 Set localmailreplica = New NotesDatabase( mail(0) , mail(1) )
localrepid = localmailreplica.ReplicaID
If servermailreplica .OpenByReplicaID( server, localrepid  )
else
 Set servermailreplica = New NotesDatabase( mail(0) , mail(1) )
end if


Hope this helps

   
ASKER CERTIFIED SOLUTION
Avatar of madheeswar
madheeswar
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial