Replacing list members/elements with LotusScript?

I am trying to write a LotusScript agent (Target: All selected documents) which will scan all of the selected docs in a view, scan the SendTo and CopyTo fields in these docs and remove the e-mail addresses of any NON-local address recipients (eg. recipients other than ‘Joe Bloggs/Local Notes Domain’ or ‘jbloggs@localdomain.com’).

I am able to scan the indicated docs and fields and identify the external addresses using the following code:


Dim sess As New NotesSession

Dim db As NotesDatabase

Dim coll As NotesDocumentCollection

Dim doc1 As NotesDocument

Set db = sess.CurrentDatabase

Set coll = db.UnprocessedDocuments

Set doc1 = coll.GetFirstDocument()

While Not (doc1 Is Nothing)

Forall temp1 In doc1.GetItemValue("SendTo")

If Instr(1,temp1,"Local Notes Domain") = 0 And Instr(1,temp1,"localdomain.com") = 0 Then



        ' The current e-mail address is not a local recipient and should be removed

        ' Do that here



End If		

End Forall

Wend


However, I’m not sure how to modify or remove individual list members of the SendTo field (for instance, set them to “”) or wholly replace the value in the SendTo field.

I was thinking of something like:

’ inside Forall loop (addr and ret are strings)

addr = doc1.GetItemValue(“SendTo”)

ret = Replace(addr,temp1,“”)

Call doc1.ReplaceItemValue(“SendTo”,ret)

Call doc1.Save(True,False)

OR

’ inside Forall loop (newSendTo is a string)

if (address should NOT be removed) Then

newSendTo = newSendTo + temp1 + ","

End If

’ after/outside Forall loop

Call doc1.ReplaceItemValue(“SendTo”,newSendTo)

Call doc1.Save(True,False)

Nothing seems to work and I often end up in an infinite (Forall?) loop. I’ve tried using ubound to limit the number of times the loop runs (eg. c% = Ubound(doc1.SendTo), For i = 1 to c, If doc1.SendTo(i) Then, Next) - this doesn’t work either.

Any ideas how I can accomplish this task?

Paul.

Subject: Replacing list members/elements with LotusScript? (solved)

Nevermind - the second suggestion I posted (newSendTo field) does actually work.

The infinite loop was caused by omission of the line doc1 = coll.GetNextDocument(doc1) in the While loop. Doh!

Paul.

Subject: RE: Replacing list members/elements with LotusScript? (solved)

Can you help me with my LS query…

I dont know LS very well… so any help would be great…

I have an application that has a form that runs on the net… i would like to get an email sent out when a call is logged on the net. This form has a agent that runs on WebQuerySave that goes and gets the call number and writes to the audit fields. In this it also has some email code… but it isnt working… please help me :slight_smile:

This is the code in Initialize:

Set cdoc=session.documentcontext

Set mdoc = New NotesDocument( db )

mdoc.Form = "Memo"

mdoc.SendTo = "anastasia.vassili@capmsl.com"  

	

mdoc.subject =	"Web Call logged"

mdoc.body = "Please note, call number " + refnum + " has been logged via the Internet. " 

Call mdoc.Send( True)

Subject: RE: Replacing list members/elements with LotusScript? (solved)

If I were you I’d create an agent in the database that is triggered ‘After documents are created or modified’. You set this in the action properties.

The agent would include the simple action, Send Newsletter Summary. Add your e-mail address to the ‘To’ field. Create a view in your database which contains the fields you want in the summary (job title, call number etc…) and then link to this view via the Send Newsletter Summary dialog (‘Include summary for each document using view’).

HTH,

Paul.

Subject: RE: Replacing list members/elements with LotusScript? (solved)

Thanks Paul.

You gave me an idea on how I can work around my email issue. What I ended up doing was creating an agent that runs on a specific view (based on calls logged today) and sending an email when a new one is added. Its not running perfectly but i’m getting there…

Thanks

FIELD SupportAuthor:= SupportAuthor;

FIELD Sup_Analyst_1 := Sup_Analyst_1;

FIELD RequestNumber := RequestNumber;

FIELD Severity_1 := Severity_1;

FIELD Subject_1 := "Web Call Logged - “+” Call Number: "+RequestNumber;

FIELD Subject_2 := "Organisation: " + Organization + @NewLine +@NewLine +"Call Catagory: " + CallCategory_1 + @NewLine +@NewLine +"Short Description: " +Short_Desc + @NewLine +@NewLine + "Full Description: " + Topic + @NewLine +@NewLine +"If you have received this mail in Microsoft Outlook you must review the call through the Note Call Centre database, If you are using Notes Mail you may go directly to this call by pressing th following link. " ;

@MailSend(“Anastasia Vassili”;“”;“”;Subject_1;Subject_2;“”);

SELECT @All