Solved

Sending mail from a form designed on Lotus hosted in Web

Posted on 2006-07-07
15
285 Views
Last Modified: 2013-12-18
Hi

Could you Please help me urgently.

I am basically an Lotus Domino Administrator and had been asked to develop small application on Lotus which is Requestor will submit his request through web and the same application will be accessed by approvers through lotus client and approve their requests.

In this scenario, there is a submit request button. Once the requestor fills the relevant details and clicks the submit button on web, immediately a mail should be sent to the approver about the new request for his action.
The approver is available in a field. All are internal users on the same server, but the requestors will access this form over web.

I had used a agent with send a mail in webquerysave. But its not working. When I used @mailsend in webquerysave, it sends mail when the requestor submits his request. But it goes with the server name and also I need a popup on the browser, once the requestor clicks the submit request button. I was trying to get the solution for the last 14 hours.
Nothing is working for me. Could anyone help me urgently on this?

I need bring it to online by tomorrow nite(deadly timeline)

Thanking You
0
Comment
Question by:deivakumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17059020
Seems right to me. What's the code you use in the WebQuerySave agent?

Ehm, we don't like threats about deadlines and so... ;) but we'll try to help!
0
 

Author Comment

by:deivakumar
ID: 17059331
Sorry my friend! if the deadline hurts........................ Looking for your help thanks

------------------------------------------------------------------

Please find the agent (SendMail) which is in agent with the following settings.

Shared
Trigger - on event
Runtime - Action Menu Selection
Target - All new and modified Documents
------------------------------
The following code is available in agent - intialize

Dim session As New NotesSession
      Set db = session.CurrentDatabase
      Set maildoc = db.CreateDocument
      Dim doc As notesDocument
      Dim rtitem As NotesRichTextItem
      Dim Body As NotesRichTextItem
      
      Set doc = session.DocumentContext
      tmpreqname=doc.Txt_Author
      tmpcontact=doc.ID
      
      maildoc.Form = "memo"
      maildoc.SendTo = doc.Analyst
      maildoc.Subject = "You have a new request from "+tmpreqcomp
      Set Body=New NotesRichTextItem(maildoc,"Body")
      Set rtitem = New NotesRichTextItem( maildoc, "Body" )
      message="Please review new request from "+ tmpreqname+" from "+tmpreqcomp+"."
      Call rtitem.AppendText(message)
      Call Body.AddNewLine(2)
      message1="Click here to open the form=========>>"
      Call Body.AppendText(message1)
      Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
      Call maildoc.send(False)

In this code, Txt_Author is a computed field having formula ( @Name([CN];@UserName) ) and ID is an another computed field ( which is generating a request id based on time and date) and  Analyst is the field, where the approvers mail Id are stored will be selected by another field based on their respective region.

I dont' want to send any text or anything on body of the mail. Just to send a mail in the subject saying that a request with ID no from the field - ID is waiting for your approval.

-----------------------------------

The following formula had been available at webquerysave

@Command([RunAgent];MailSend)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17059487
Probably the agent never ran. The target is wrong, it has to be None.

From the Designer Help db:
Using the Agent Properties box, do the following:
- Check the "Shared" option when you create the agent.
- Set the agent trigger to "On event" and either "Agent list selection" or "Action menu selection."
- Set the agent target to "None" for agents that work on the current document such as those launched from WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields in the current document.

Otherwise, I think you would have seen errors in the log.nsf database. Also, creating two richtext items with the name Body is impossible.

Dim session As New NotesSession
     Set db = session.CurrentDatabase
     Set maildoc = db.CreateDocument
     Dim doc As notesDocument
     Dim rtitem As NotesRichTextItem
     Dim Body As NotesRichTextItem
     
     Set doc = session.DocumentContext
     tmpreqname=doc.Txt_Author(0) ' <---
     tmpcontact=doc.ID(0) ' <---
     
     maildoc.Form = "memo"
     maildoc.SendTo = doc.Analyst(0) ' <---
     maildoc.Subject = "You have a new request from "+tmpreqcomp
     Set Body=New NotesRichTextItem(maildoc,"Body")
'     Set rtitem = New NotesRichTextItem( maildoc, "Body" ) ' <---
     message="Please review new request from "+ tmpreqname+" from "+tmpreqcomp+"."
     Call Body.AppendText(message) ' <---
     Call Body.AddNewLine(2)
     message1="Click here to open the form=========>>"
     Call Body.AppendText(message1)
     Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
     Call maildoc.send(False)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:deivakumar
ID: 17064093
I had done the following changes. Could you please review and advise?

Shared
Trigger on event
Runtime - Action Menu Selection
Target - None.

----------------------------------------------------------------------
Dim session As New NotesSession
      Set db = session.CurrentDatabase
      Set maildoc = db.CreateDocument
      Dim doc As notesDocument
      Dim rtitem As NotesRichTextItem
      Dim Body As NotesRichTextItem
      
      Set doc = session.DocumentContext
      tmpreqname=doc.Txt_Author
      tmpcontact=doc.ID
      
      maildoc.Form = "memo"
      maildoc.SendTo = doc.Analyst
      maildoc.Subject = "You have a new request from "+tmpreqname
      Set Body=New NotesRichTextItem(maildoc,"Body")
      message="Please review new request from "+ tmpreqname+" from "+tmpcontact+"."
      Call maildoc.send(True)

------------------------------------------------------------------------------------
If I run this agent from designer then it gives an error saying that " object variable not set "

At end, there is no mail has been sent to the requestor
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17064167
You can't run the agent from the Designer, because there is no current document, hence doc is Nothing, so the code will stop at the first line where the object doc is used. You have to run it as a web agent.

Secondly, the message isn't put into the mail. The following is allowed:
    Call Body.AppendText("Please review new request from "+ tmpreqname+" from "+tmpcontact+".")

Thirdly, you didn't copy all the code I changed above. It is maybe strange, but a reference to a field in a document yields an array. In the Notes object system, ALL NotesItems are potentially multi-value. So, if there is only one value, you still have to get the first value of the array. E.g. with Txt_Author:
    tmprequname= doc.Txt_Author
will stop execution right there, because you try to assign an array to a String variable... ah, now I see, tmpreqname isn't declared, therefore a Variant by default, and the statement is permitted. It will set the value of tmpreqname to an array. What you need is the first value of the aray:
    tmprequname= doc.Txt_Author(0)

And make it a good habit to declare ALL variables before you use them. To assist you, set Option Declare in the option section of the module. In the Programmer's Pane Properties, 2nd tab, you can set "Automatically add 'Option Declare' ".

If you want to follow the execution of a web agent, you can add some MsgBox calls. The output is sent to log.nsf and not to a screen. Like this:

     Dim session As New NotesSession
     Set db = session.CurrentDatabase
     Set maildoc = db.CreateDocument
     Dim doc As notesDocument
     Dim Body As NotesRichTextItem
     Dim tmpreqname As String
     Dim tmpcontact As String
     
     Set doc = session.DocumentContext
     tmpreqname=doc.Txt_Author(0)
     tmpcontact=doc.ID(0)
     
     maildoc.Form = "Memo"
     maildoc.SendTo = doc.Analyst(0)
     maildoc.Subject = "You have a new request from "+tmpreqname
     Set Body=New NotesRichTextItem(maildoc,"Body")
     Call Body.AppendText(Please review new request from "+ tmpreqname+" from "+tmpcontact+".")
     Call Body.AddNewLine(2)
     Call Body.AppendText("Click here to open the form=========>>")
     Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
     Call maildoc.send(False)
0
 

Author Comment

by:deivakumar
ID: 17064471
hi it looks like working but the doc.Analyst should be selected based on the other field.
ex. If the field Region is populated with " Tunis " by user, then the mail should be sent to approver " User1"
If the field Region is populated with "Congo" by user, then the mail should be sent to approver "User2"

Now all the approvers listed in a field "Analyst" which was manually selected by the requestors. I want to hide the approvers name from the requestors. The requestors should select only regions and mails should be sent to respective approvers.

Sorry for bothering you much........... Since Im just few steps away from hosting this apps, request your help on this.

thanks
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17064531
Several ways to do that, this is the simplest.

field Region, Dialog list, editable, with all regions.

field Analyst, computed, formula:
    regions:= "Tunis":"Congo":"Anywhere":....;
    approvers:= "User1/ACME":"User2/ACME":"User1/ACME":...;
    @Replace(Region; regions; approvers)

These two lists have to be of the same length.

The next step could be that you remove names and regions from the source code of the form, and you develop a simple form with Analyst and Region, and a view, so you can do a @DbLookup.
0
 

Author Comment

by:deivakumar
ID: 17064802
thanks, its working for region with one approver.

here i hv another problem. for few regions, there are two approvers, both must be notifed on the same request.

how we can achieve this? appreciate ur kind help.thanks
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17064823
That's your 3rd question... ;)

field Analyst, computed, formula:
    regions:= "Tunis":"Congo":"Anywhere":....;
    approvers:= "User1/ACME":"User2/ACME;User4/ACME":"User1/ACME":...;
    @Explode(@Replace(Region; regions; approvers); ";")

In one entry in the approvers list, put two names, separated by a ";"
0
 

Author Comment

by:deivakumar
ID: 17067496
Thanks friend! Can I add one more request.

How can you have unique request IDs for all the requestors? Pls. help. Thanks
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 17067552
Yes, my friend, you can add one more question, but I won't answer it here :)

Better create a new question, because it has nothing to do with the original subject.
0
 

Author Comment

by:deivakumar
ID: 17070755
OK. Will do the same.Thanks for your continuous support.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17070839
Ah, you gave a B. Which means you're not fully satisfied? I even answered THREE questions! Could you please reconsider? Do read
    "How to grade" http://www.experts-exchange.com/help.jsp#hi73
0
 

Author Comment

by:deivakumar
ID: 17070873
No probs! my dear friend! can be esclated to A!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 17070911
Smashing! If you would be so kind to post a (free) question in the Community Support TA?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question