Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting multiple "To" recipients using CDO.Message 1

Status
Not open for further replies.

dekesc

Programmer
Mar 29, 2012
15
US
I am trying to send an email dynamically to multiple recipients with the recipients defined within a variable. The code below works if I set selectedEmailList = "myemail@mindspring.com" (a single email address within quotes) but doesn't work if I set selectedEmailList = "emailname1@mindspring.com,emailname2@mindspring.com,emailname3@mindspring.com". I have tried semi-colons between email addresses to no avail, and also tried using <> at start and end of each email address--no luck there either.

Any suggestions on how to properly define 'selectedEmailList to send a message to multiple recipients at one time?

Here is the code:

Dim selectedEmailList
Dim sch, cdoConfig
sch = "
Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "smtp.mydomain.org"
.update
End With
Dim cdoMessage
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = "me@mindspring.com"
.To = selectedEmailList
.Subject = "Care Ministry Individual Care Contact Update"
.TextBody = "An online Care Ministry update is ready for viewing. Open the attachment to view/print the latest update regarding " & selectedFirstName & " " & selectedLastName
' NOTE: strEmail_attach_report is previously set and works as an attachment.
.AddAttachment (strEmail_attach_report)
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
 
Have you tried to play with the CC or BCC properties ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I have not but will give your suggestion a try. Thanks for responding.
 
How would multiple eMail addresses be displayed in an Outlook eMail? You have your answer there.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Turns out the ".cc" nor the ".bcc" allow for a variable, even one with just one email address. When I run the app with FireFox it tells me that that variable is undefined--although it is.

As for replicating the Outlook multiple emaill address format, I replicated the stream that Outlook shows when I expand a distribution list. I defined my variable to that format and still the FF browser says the variable is undefined. Here is the variable's format:
seletedEmailTEST = "webmaster@thewebplusgroup.com; sales@thewebplusgroup.com"

Any further thoughts on this? So far, I'm concluding that (1) the ".to" field will accept a variable but only for one email address, and (2) the ".cc" and ".bcc" will also allow for the use of a variable with one email address only.

 
Well... here's one of those programming "solutions" that just doesn't have an explanation--at least I can't think of one. As I reported I used the variable format: seletedEmailTEST = "webmaster@thewebplusgroup.com; sales@thewebplusgroup.com" in the ".To" line of code as I recorded in my last reply that it didn't work.

I just ran the app again and the .send emailing works with a variable containing more than 1 email address. It works also with the ".to", the ".cc" and the ".bcc".


I have done multiple tests under, what I consider to be, controlled testing conditions. However, 'something has changed' (we've all heard this before) as the format that works is the one above: variable = "emailaddress1; emailaddress2; emailaddress3" which is the one I had used previously.

Looks like the problem is resolved and I thank each of you for your time and suggestions re this issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top