We help IT Professionals succeed at work.

how to find out users mail template and then redirect to their mail file

saleemkhan
saleemkhan asked
on
hai experts,
    i want to find out the users design mailtemplate.
if the users design mailtemplate is mail50.ntf it should redirect to their mail the print stat should be like this

Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"';"      
if the users design mailtemplate is inotes5.ntf is should redirect to their mail .

Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"/iNotes/Mail/?OpenDocument';"      

here is the agent which i am using
here depending on the users mail template i want to change the print stat.
Sub Initialize
  Dim s As New Notessession
  Dim db As New NotesDatabase("","names.nsf")
  Dim user As NotesName
  Dim v As NotesView
  Dim doc As NotesDocument
  Set v = db.GetView("($Users)")
  Set user = New NotesName(s.EffectiveUserName)
  Set doc = v.GetDocumentbyKey(user.Abbreviated)
  Print "<Script language=""Javascript"">"
  Print "window.focus();"    
  Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"/iNotes/Mail/?OpenDocument';"      
 Print "</Script>"
End Sub


waiting for reply.

Saleem.
Comment
Watch Question

You can determine Design Template of a db by using this following property

=======
DesignTemplateName property  

Read-only. The name of the design template from which a database inherits its design. If the database does not inherit its design from a design template, returns an empty string ("").

Defined in
NotesDatabase

Data type
String

Syntax
To get: name$ = notesDatabase.DesignTemplateName

Usage
If a database inherits a specific design element (such as a form) but not its entire design from a template, this property returns an empty string ("").
=======

~Hemanth

Commented:
Hello Saleem,

there is a pitfall in your code. NotesSession.EffectiveUserName returns agent signer name when called from web. Only on NotesClient is current user name returned. If you need current user name on web, than use NotesSession.DocumentContext and in this agent context document the field Remote_User(0)
Another method (that I would not recommand to you) is to set in agent properties "RunAgentAsWebUser". If you set this propery, then is not agent signer but web user name returned as effective user name. Not recomanded because after this your agent is not allowed to do restricted accesses I suppose your agent do need.

Take care of this.

Regards,
zvonko

Author

Commented:
hai ,
 i already set the  agent properties as "runagentaswebuser".
its working fine.the second thing is where to embed the hemanth kuamar comment

name$ = notesDatabase.DesignTemplateName
i want to write one if condition if it is
mail50.ntf
the print stat should be like
Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"';"
else
Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"/iNotes/Mail/?OpenDocument';"
how to do this.

waiting for reply.
saleem.

Commented:
Sorry for my intermix.
I prefere allowing Heman to complete his answer <|;-)

Regards,
zvonko
include this if statement

Dim db as NotesDatabase
set db = session.CurrentDatabase
name$ = db.DesignTemplateName

IF Instr( name$, "iNotes) > 0 then

Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"/iNotes/Mail/?OpenDocument';"

else

Print "location.href='/" + ReplaceSubstring(doc.MailFile(0), "\","/") + ".nsf" +"';"

End if


~Hemanth

Author

Commented:
when i include the if stat i am getting agent done in the browser.
 and observed the following error in server console.


10/08/2001 06:20:20 PM  Addin: Agent 'shaikmaillogin' error message:Variant does not contain an object


where i am wrong
.
waiting for reply.
Use s instead of session object in statement

set db = session.CurrentDatabase


Author

Commented:
hai hemanth,
  Excellent hint.Thanks for ur respone.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.