Hello,I have an agent that I want to run on some docs that will send out emails to emps.
I have setup profile docs in the db where they store the email addy and a 4 digit code. The 4 digit codes are to be sent to each individual email address.
Problem: it sends the 4 digit code to the first one, but then on the second profile doc, it puts in the 4 digit code from the 1st and 2nd profile doc. Then it just keeps putting them all in the emails, its not only grabbing the 1st #, then going to the next and grabbing that and only putting that one in.
************ Start of agent code *************
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim db2 As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
'Dim itemA As NotesItem
Set db = session.CurrentDatabase
Set db2 = New NotesDatabase( "server", "mail.nsf" )
Set view = db.GetView("Profile2")
Set view2 = db.GetView("EmailBody")
Dim maildoc As New NotesDocument(db)
Set doc = view.GetFirstDocument
Set doc2 = view2.GetFirstDocument
Dim itemA As notesrichtextitem
Set itemA = doc2.GetFirstItem("EmailBody")
Dim itemB As notesrichtextitem
Set itemB = itemA.copyitemtodocument(maildoc, "Body")
While Not(doc Is Nothing)
'send it
maildoc.Principal = "Charles G. Huber <emailaddresshere>"
maildoc.Subject = "Ralcorp Annual Questionnaire ACTION REQUIRED"
maildoc.Form = "Memo"
Call itemB.AppendText( doc.Code(0) )
Call maildoc.Send(False, doc.emailaddy)
Set doc = view.GetNextDocument(doc)
Wend
End Sub
**************End agent code *************