WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE and Outlook
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Send to Multiple Recipients

 Keywords:  Outlook send email multiple recipients

Question:

I just can't seem to get the correct format to string together recipients for an OLE email. One person works just fine, but I can't seem to get it to work for more than one.

Here is a sample of what I've tried so far:

recip="sa@mterminals.com; tom@thumb.com"

recip="sa@mterminals.com;tom@thumb.com"

Any thoughts?

Answer:

Give this a try instead...

objOutlook = ObjectOpen("Outlook.Application")

; Create the message.
objOutlookMsg = objOutlook.CreateItem(0)

; Display to user (the following line can be removed if you do not want any interface)
objOutlookMsg.Display

; add Recipient
objOutlookRecip=objOutlookMsg.Recipients
objOutlookRecip.Add(Recip)  ;<<<<<<<
objOutlookRecip.Add(Recip2) ;<<<<<<<

; Set the Subject, Body, 
objOutlookMsg.Subject = "This is an Automation test with Microsoft Outlook"
objOutlookMsg.Body = strcat("This is the body of the message.",@CRLF) 

; Add attachments to the message.
objOutlookAttach = objOutlookMsg.Attachments
objOutlookAttach.Add(AttachmentPath)
objOutlookMsg.Send
ObjectClose(objOutlook)

exit

Another Example:

This example Sends an email to multiple BCC recipients
;Send an email to multiple BCC recipients
reciplist = "john_doe@test.com|fred_doe@test.com|jack_doe@test.com"
Csubject = "Test"
Cbody = "Testing OLE Outlook"

objOutlook = ObjectOpen("Outlook.Application")
; create object
objOutlookMsg = objOutlook.createitem(0)
objOutlookRecip = objOutlookMsg.Recipients
;objoutlookmsg.display

count = ItemCount(reciplist, "|")
For x = 1 to count
   Cname = ItemExtract(x, reciplist, "|")
	;add this recipient
	objOutlookRecip.Add(Cname)
	;make this recipient a BCC
	recip_1 = objOutlookRecip.Item(x)
	olBCC = 3
	recip_1.Type = olBCC
Next

;Define the subject
objOutlookmsg.Subject = Csubject
;Define the message body
objOutlookmsg.Body = Cbody
objOutlookMsg.Send
ObjectClose(objOutlook)
exit 

Article ID:   W14920
File Created: 2002:02:14:12:15:58
Last Updated: 2002:02:14:12:15:58