Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Notes email to multiple recipients via VB

61 views
Skip to first unread message

Jeremy Tilson

unread,
Dec 20, 2000, 5:45:30 AM12/20/00
to
Hi

I'm trying to e-mail via Lotus Notes from VB/VBA. What I have so far
works fine (see below) but I can't find any way to set either the to,
cc or bbc fields to more than one recipient.

Does anyone know a method of populating these fields with multiple
recipients in a format that Notes recognises without giving an address
book error? I think the problem might be centered around the fact that
Notes thinks these fields are a list, but I haven't been able to
determine the correct format.

This is what I've got so far :-

Sub SendEmail()
Dim objNotes As Object
Dim objNotesDB As Object
Dim objNotesMailDoc As Object
Dim objNotesBody As Object

Set objNotes = GetObject("", "Notes.Notessession")
Set objNotesDB = objNotes.getdatabase("", "")

Call objNotesDB.openmail
Set objNotesMailDoc = objNotesDB.CreateDocument

With objNotesMailDoc
'Insert message details
.Subject = "Subject"
.Body = "Message"
.SAVEMESSAGEONSEND = True
.Form = "Memo"
.SendTo = "reci...@domain.com"
.CopyTo = "ccrec...@domain.com"
.BlindCopyTo = "bccrec...@domain.com"
Call .Send(False)
End With
Set objNotes = Nothing
Set objNotesDB = Nothing
Set objNotesMailDoc = Nothing
Set objNotesBody = Nothing
Exit Sub


Thanks for any help you can give
Jeremy Tilson
London, UK


Sent via Deja.com
http://www.deja.com/

Darren Davison

unread,
Dec 20, 2000, 6:19:14 AM12/20/00
to
try creating an array and appending it to the doc..
(NB: UNTESTED)

'use ReDim Preserve for flexibility
Dim sNames(2) As String
...
sNames(0) = "a...@acme.com"
sNames(1) = "b...@acme.com"
sNames(2) = "c...@acme.com"
...
With objNotesMailDoc
.AppendItemValue "SendTo", sNames
.Send False
End With
...

hth
DD

Jeremy Tilson wrote

Jeremy Tilson

unread,
Dec 20, 2000, 11:48:31 AM12/20/00
to
Thanks for the prompt response, Darren. Will try this out when I get a
chance.

One question: Does it have to be an array? Could you instead using
something like :-

With objNotesMailDoc
.AppendItemValue "SendTo", "a...@acme.com"
.AppendItemValue "SendTo", "b...@acme.com"
.AppendItemValue "SendTo", "c...@acme.com"
.Send False
End With

(forgive my ignorance with the Notes API, haven't been able to find out
much about it other than what's been posted in newsgroups -
Lotus 'support' site is useless!)

regards
Jeremy


In article <3A4095B2...@SPAMtomkins.co.uk>,

Darren Davison

unread,
Dec 20, 2000, 12:25:45 PM12/20/00
to
yes, you do have to use an array. Although I don't think the code as
listed will generate any errors in VB, it will not acheive the desired
result. Notes will create multiple (distinct) items on the document
with the name "SendTo", but only the first will be recognised and hence
the email will only go to the first recipient.

As mentioned though, you don't have to know the upper limit of the array
in advance, you can just initialise it then redeclare it every time you
want to add a new recipient with

ReDim Preserve sNames(Ubound(sNames) + 1)
sNames(Ubound(sNames)) = "nextre...@domain.com"


or something similar. Best bet for info on the API is the notes online
help.


Regards,
DD

Glenn S. Orenstein

unread,
Dec 22, 2000, 8:44:30 PM12/22/00
to
Dim recipients() as variant

Redim recipients(NumberOfRecipients - 1)
recipients(0) = "....."
recipients(0) = "....."
recioients(2) = "..."
etc.

.SendTo = recipients


Glenn S. Orenstein
Glenn Orenstein Consulting
(If replying by email, remove the "XXXX"s from the address)

0 new messages