Subject: send email to 2 Domino groups
This is a good example of why you should sometimes write more verbose code, and thereby making it more flexible and easier to upgrade in the future.
I would solve it as follows:
Dim sendto As String
Dim group As Variant ’ Will be an array later
Set view = db.GetView(“Groups”)
'*** Get the first group and put into array
Set doc = view.GetDocumentByKey(“Calendar Group”)
group = doc.GetItemValue(“Members”)
'*** Build string of mail addresses, separated by comma
ForAll g in group
sendto = sendto + g + “,”
End ForAll
'*** Get the second group and put into array
Set doc = view.GetDocumentByKey(“Calendar Group2”)
group = doc.GetItemValue(“Members”)
'*** Add new addresses to string of mail addresses
ForAll g in group
sendto = sendto + g + “,”
End ForAll
Call memo.ReplaceItemValue(“SendTo”, Split(sendto))
Don’t use extended notation (e.g. memo.SendTo), use the full class methods.
I would also recommend taking a look at my mail notication class, it makes it very easy to add multiple recipients to an email.
http://blog.texasswede.com/lotusscript-mail-notification-class/
Your code woould them look like this:
Dim group As Variant ’ Will be an array later
Set view = db.GetView(“Groups”)
Set mail = New NotesMail()
'*** Get the first group and put into array
Set doc = view.GetDocumentByKey(“Calendar Group”)
group = doc.GetItemValue(“Members”)
'*** Build string of mail addresses, separated by comma
ForAll g in group
Call mail.AddMailTo(g)
End ForAll
'*** Get the second group and put into array
Set doc = view.GetDocumentByKey(“Calendar Group2”)
group = doc.GetItemValue(“Members”)
'*** Add new addresses to string of mail addresses
ForAll g in group
Call mail.AddMailTo(g)
End ForAll
Call mail.Subject = “Your Subject”
Call mail.Send()