Hi
In my web application, I was created form, it contains a richtext field , named as “Message”. And a button to run the agent to send the mail to the respected authority.
Then I wrote a script for a agent assigned it to the button. Once the end user clicks, it sends the all the things, but not the Message of richtext field. And one thing it is sending the mail in Notes client only, but no mail from the web mode.
Please give me ur valuable suggestions. And if possible pls send the correct script, if previously u used. This is my final task, once it completes my project will complete. Please give me ur valuable suggestions.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim currdoc As notesdocument
Dim doc As NotesDocument
Dim rtitem As notesrichtextitem
Dim a As String
Set db = session.CurrentDatabase
Set currdoc=session.documentcontext
Set doc = New NotesDocument( db )
doc.Form = "Memo"
doc.Subject = "Reminder!"
Set rtitem = New NotesRichTextItem( doc, "Body" )
a=Cstr(currdoc.Message(0))
Call rtitem.appendtext(a)
Call doc.Send( True, "xyz@abc.com" )
End Sub
Advance Thanks
Sri
Subject: Sending a mail via web, script
try:Set rtitem = currdoc.GetFirstItem( “Message” )
Call rtitem.CopyItemToDocument( doc, “Body” )
instead of:
Set rtitem = New NotesRichTextItem( doc, “Body” )
a=Cstr(currdoc.Message(0))
Call rtitem.appendtext(a)
good luck,
http://vinceschuurman.com
Subject: RE: Sending a mail via web, script
Hi,
Thank u Schuurman for the response. I was changed my script according to ur suggestions. But it is giving the error at debugging mode as “Object Variable not set”.
Giving error at the line
Call rtitem.CopyItemToDocument(doc, “Body”)
Please give the suggestion. Pls, i am suffering.
Hope soon
Sri
Subject: Sending a mail via web, script
Here’s a example…==================================
…this agent will run in the background (web, too)
On Error Goto Oops
Dim s As New NotesSession
Dim db As NotesDatabase
Dim newmail As NotesDocument
Dim req As NotesDocument
Dim dc As notesdocumentcollection
Dim email As notesitem
Dim item As notesitem
Dim value1, value2 As notesitem
Dim message As String
Dim i As Integer
Set db = s.CurrentDatabase
Set dc = db.unprocesseddocuments
For i = 1 To dc.count
Set req = dc.getnthdocument(i)
If (req.form(0) = "form1" Or req.form(0) = "form2") Then
Set newmail = New NotesDocument( db )
Set email = req.getfirstitem("email")
Set item = req.getfirstitem("item")
Set value1 = req.getfirstitem("value1")
Set value2 = req.getfirstitem("value2")
'Create the memo
newmail.Form = "Memo"
' Create the memo body
Dim bodyItem As NotesRichTextItem
Set bodyItem = newmail.CreateRichTextItem( "Body" )
Call email.copyitemtodocument(newmail, "SendTo")
If req.hasitem ("value1") Then
Call value1.copyitemtodocument(newmail, "Subject")
Call bodyItem.AppendText("a message goes here...")
End If
If req.hasitem("value2") Then
Call value2.copyitemtodocument(newmail, "Subject")
Call bodyItem.AppendText("a message goes here...")
End If
' Append the message prefix
Call bodyitem.AddNewLine(1)
Call bodyItem.AppendText("Thank you!")
Call bodyitem.AddNewLine(1)
Call bodyitem.AddNewLine(1)
Call bodyItem.AppendText("Your organization name")
Call bodyitem.AddNewLine(1)
Call bodyItem.AppendText("Your email address")
newmail.Send( False )
Call req.Save( False, True )
Oops:
End If
Next
Exit Sub
Subject: RE: Sending a mail via web, script
Thank u Michael, for ur prompt response. I want some few clarifications in ur script.1) In ur script u wrote that “form1” and “form2”
but I am using only one form, pls give me the clarification.
2)In my form richtextitem field name is “Message”, but u r not mentioned any where this field name, for this i am little bit confused.
Because end user types his long message in that rich text field only, but u r not mentioned.
Pls Michael, pls give me the clarification. I can Thank ful to u.
Thank u very much
Sri