Can someone show me what I’m doing wrong. I’m having problems with the array part. I want to take each element of the array and look at a view, collect the docs, then email the report. I want to loop through the array until finished. Tmp1-6 are declared in Declarations by the way.
Any suggestions?
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim rtitem As NotesRichTextItem
Dim ctr As Integer
ctr = 0
Dim DocOne As NotesDocument
Dim NewDoc As NotesDocument
Dim ViewOne As NotesView
Set ViewOne = db.Getview("Division")
Dim collectionone As NotesDocumentCollection
Dim Division(1 To 4) As String
Division(1) = "North"
Division(2) = "South"
Division(3) = "East"
Division(4) = "West"
Forall V In Division
Set collectionone = viewone.GetAllDocumentsByKey(V,True)
Set DocOne = collectionone.GetFirstDocument
Do Until DocOne Is Nothing
Set NewDoc = DB.CreateDocument
NewDoc.Form = "FormA"
NewDoc.sendto = "Scott Price"
NewDoc.Subject = "New Customers"
NewDoc.Title = "List of new customers."
NewDoc.Division = V
Set rtitem = New NotesRichTextItem(NewDoc, "Link")
tmp1(ctr) = Format(DocOne.docdate(0),"mm/dd/yyyy")
tmp2(ctr) = Left(DocOne.author(0),20)
tmp3(ctr) = Left(Strconv(DocOne.companyname(0),3),30)
tmp4(ctr) = Left(DocOne.partnumber(0),20)
tmp5(ctr) = Format(DocOne.rdate(0),"mm/dd/yyyy")
tmp6(ctr) = Format(DocOne.ddate(0),"mm/dd/yyyy")
Call rtitem.AppendDocLink(DocOne,"Link")
Call rtitem.AddNewLine(1)
ctr = ctr + 1
Set DocOne = collectionone.GetNextDocument(DocOne)
Loop
End Forall
NewDoc.DocCreated = Fulltrim(tmp1)
NewDoc.DocAuthor = Fulltrim(tmp2)
NewDoc.CompName = Fulltrim(tmp3)
NewDoc.PartNo = Fulltrim(tmp4)
NewDoc.RDate = Fulltrim(tmp5)
NewDoc.DClosed = Fulltrim(tmp6)
'Clear arrays and send the emails
Call NewDoc.Send(True, NewDoc.SendTo)
Erase tmp1
Erase tmp2
Erase tmp3
Erase tmp4
Erase tmp5
Erase tmp6
Call rtitem.Update
End Sub