Web Email Agent

Hi,I wrote this agent to send some information from the form:

Sub Initialize

Dim s As New notessession

Dim db As notesdatabase

Dim memo As notesdocument

Dim webdoc As notesdocument

Set db = s.currentdatabase

Set webdoc = s.documentcontext

Set memo = New notesdocument(db)

Dim item As NotesItem



Set rtitem = New NotesRichTextItem( memo, "Body" )

Call rtitem.appendtext("The Web Client has authorised an install in project "+webdoc.pfrc_name(0)+" described as "+webdoc.pfrc_hosp_info(0)+Chr(10)+Chr(10))

Call rtitem.appendtext("Please follow the document link below to view this document and assign it to a member of the department")

Call rtitem.AppendDocLink( webdoc, "Document Link" )



memo.form = "Memo"

memo.SendTo = "test@test.com"

memo.Importance = "1"

memo.CopyTo = Email

memo.Subject = "Request has been Authorised by Client"



Call memo.Send(False)

End Sub

But my problem is: instead to have this : memo.SendTo = “test@test.com”

I have an Email field in my form , I would like to have that:

memo.SendTo = Email Field

Please need the code for that.

Thanks

Subject: Web Email Agent

Hi,

Single value field :

…

memo.SendTo = webdoc.YourFieldName(0)

…

or if multi values field :

…

memo.SendTo = webdoc.YourFieldName

…

also

Forall AdrMAil in webdoc.YourFieldName

memo.SendTo = AdrMAil

memo.Importance = “1”

memo.CopyTo = Email

memo.Subject = “Request has been Authorised by Client” Call memo.Send(False)

end forall

HTH

Thierry

Subject: RE: Web Email Agent

When I put thismemo.SendTo = webdoc.Email(0)

my agent doesn’t work anymore !!!

Subject: and what’s in webdoc.Email(0)?

Subject: RE: and what’s in webdoc.Email(0)?

the Email of the person I want to mail the form

Subject: RE: and what’s in webdoc.Email(0)?

So it’s a single-value field? Then it should work as you’ve coded it. What exact result do you get? Any error message? Make sure that the email field has what you think it does by Printing its content to the server console/log or using the NotesLog class or even creating a second email doc, addressing it to yourself, and putting the contents of the email field in as the subject or body of that email.

Subject: RE: and what’s in webdoc.Email(0)?

Here’s my code:Sub Initialize

Dim s As New notessession

Dim db As notesdatabase

Dim memo As notesdocument

Dim webdoc As notesdocument

Set db = s.currentdatabase

Set webdoc = s.documentcontext

Set memo = New notesdocument(db)

Dim item As NotesItem



Set rtitem = New NotesRichTextItem( memo, "Body" )

Call rtitem.appendtext("You have recieved a new PFRC Request  "+webdoc.pfrc_name(0)+" described as "+webdoc.pfrc_hosp_info(0)+Chr(10)+Chr(10))

Call rtitem.appendtext("Please follow the document link below to view this document.")

Call rtitem.AppendDocLink( webdoc, "Document Link" )



memo.form = "Memo"

memo.SendTo = webdoc.Email(0)

memo.Importance = "1"

memo.CopyTo = "test@test.com"

memo.Subject = "New PFRC Request"



Call memo.Send(False)

End Sub

I don’t get any Emails, any error … Nothing happens

Thanks for your help

Subject: RE: and what’s in webdoc.Email(0)?

Again, I see nothing wrong with the way you’re treating the email field; did you try any of the debugging techniques for checking whether you’re getting a value?

Subject: Web Email Agent

Sorry, It’s working perfectly, It was my fault, I didn’t put my agent in the right place.

Thanks for your help