ASP 101 - Active Server Pages 101 - Web06
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

Is The User Still There?
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Sending an Email to Multiple Recipients

I recently got an email from a user who was trying to send an email to two different people from an ASP script. He knew he could use CC to copy the second person, but he wanted to have them both in the To line because other people were going to be CC'd. Here's the code that he couldn't get to work:

Set objMessage = Server.CreateObject("CDO.Message")
With objMessage
  .To       = "John <>"
  .To       = "Gary <>"
  .From     = "Sender <>"
  .Subject  = "Message Subject"
  .TextBody = "Message Body"
End With
Set objMessage = Nothing

While the above code runs without throwing an error, the message only gets sent to one of the users. The reason this code doesn't work is that the .To property of the Message object works like a text string. If you set the .To property again, it doesn't add another user to the list of recipients, it overwrites the existing value with the new value. So how do you send a message to more than one user? Here's my reply to the user:

You're right that the .To property of the CDO Message object is just a text field, but that doesn't mean you can't send email to multiple people. I usually use the .CC to copy people, but you can also just use a semi-colon delimited list to send to multiple people via the .To field. Like this:

.To = "John <>; Gary <>"

or if you don't care about the display names:

.To = ";"

Hopefully this will help people understand why the first set of code doesn't work and clear up the confusion about how to send an email message to multiple recipients.

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers