Mail agent in LS to control sender name

Please I need help urgently!I’m so “new be” in LScript, can someone help me writing this agent (below) in LS? Or in Java if it’s possible?

The reason why I need to write this agent in LS is to ne able to write the sender name, in this formula agent I get my servername as sender.

It didn’t help by using “Run on behalf of”

SELECT @If((status = “Planed” & step = “Normal”);@MailSend( “email1” ; “emailCC” ; “emailBlind” ; “SubjectText”+ FIELD 1 ; “” ; “Body text 1 “+ FIELD2+” Body text.”+@NewLine+

“MoreBody Text” + @NewLine+ FIELD3 +@NewLine+@NewLine+

“Boby text agin” ; “”);”")

regards

Sara

Subject: Script Library for Controlling the ‘From’ name

Hi Sara,

We have a script library you can freely download from our website that enables you to set the value of the ‘From’ field to whatever you want. We use it for all our auto-responder web agents and for ad-hoc emails where we can set the sender name on the fly.

The script library handles all the necessary message formatting, address resolution, etc. All you need to do is call the methods and pass the message data and away you go.

It can be downloaded from here:

Regards,

Alex

Subject: RE: Script Library for Controlling the ‘From’ name

Thak you Alex! I’ll check!

Subject: Mail agent in LS to control sender name

It would be so in an Action of a view:'—

dim session as new NotesSession

dim db as NotesDatabase

dim docMail as NotesDocument

dim RTItem as NotesRichTextItem

'—

set db=session.currentDatabase

set docMail = new NotesDocument(db)

set RTItem= new NotesRichtTextItem(docMail,“Body”)

'—

email1$=inputbox(“Please, inform recipient”)

subj$=inputbox(“Please, inform Subject”)

msg$=inputbox(“Please, inform text”)

'—

call docMail.Subject=subj$

call RTItem.AppendText(msg$)

'—

call docMail.send(email1$,false)

Subject: RE: Mail agent in LS to control sender name

Thanks! But it has to be an agent not an action.

And what about the IF condition?

Please I need more help!

Subject: RE: Mail agent in LS to control sender name

This code will work in your agent and will also check your conditions…

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim docMail As NotesDocument

Dim doc As notesdocument

Dim RTItem As NotesRichTextItem



Set db=session.currentDatabase	

Set doc = session.DocumentContext 

Set docMail = New NotesDocument(db)

If (doc.status(0) = "Planed" And doc.step(0) = "Normal") Then

	Set RTItem= New NotesRichTextItem(docMail,"Body")

	email1$=Inputbox("Please, inform recipient")

	subj$=Inputbox("Please, inform Subject")

	msg$=Inputbox("Please, inform text")

	docMail.Subject=subj$

	Call RTItem.AppendText(msg$)

	Call docMail.send(email1$,False)

Else

	Exit Sub

End If

End Sub

Regards,

Ruchit

Subject: RE: Mail agent in LS to control sender name

I got “Object variable not set” error when I run the agent. ==>> If (doc.status(0) = “Planed” And doc.step(0) = “Normal”) Then

Thankful for more help!

Sara

Subject: RE: Mail agent in LS to control sender name

Hi Sara,From where are you trying to run your agent ??

Is it a form ? if Yes do u have fields on the form with names status & step ??

Subject: RE: Mail agent in LS to control sender name

The agent I’m looking for is a scheduled agent that runs every hour on new or modified documents.It should check if (field “step” =“Normal” and filed “status” = “planed”) if its true send mail to special person if not do nothing.

Subject: RE: Mail agent in LS to control sender name

Dear Sara Barg,the previous code intends to be run on web. Is it true?

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim docMail As NotesDocument

Dim doc As notesdocument

Dim RTItem As NotesRichTextItem

'-------

Set doc=session.DocumentContext 'this line says you are running on web. Is it true?

'-------

Set db=session.currentDatabase

Set docMail = New NotesDocument(db)

If (doc.status(0) = “Planed” And doc.step(0) = “Normal”) Then

Set RTItem= New NotesRichTextItem(docMail,“Body”)

email1$=Inputbox(“Please, inform recipient”)

subj$=Inputbox(“Please, inform Subject”)

msg$=Inputbox(“Please, inform text”)

docMail.Subject=subj$

Call RTItem.AppendText(msg$)

Call docMail.send(email1$,False)

Else

Exit Sub

End If

End Sub

Hope this help