Send an SMTP email to multiple recipients?? 
Author Message
 Send an SMTP email to multiple recipients??

I am having problems sending a SMTP message to multiple recipients using
Microsoft's System.Web.Mail library.  I continuously receive the error
"Could not access 'CDO.Message' object.".  Whats the deal?

If I send to one address, it works fine. If I try to assign the To property
to a semi-colon delimited list of addresses or loop through the list of
emails and separately sending the messages.  When sending separately, the
first message gets sent and then the error occurred on the second email.

Here's a code snippet of the looping:
...
Dim aAddr() As String = strAddr.Split(";")
Dim i As Int32
For i = 0 To aAddr.Length - 1
  If aAddr(i).Length > 0 Then
    Dim mail As New MailMessage()
    mail.From = ConfigurationSettings.AppSettings("SmtpFromAddr")
    mail.Subject = strSubject
    mail.BodyFormat = MailFormat.Html
    mail.Body = sBody
    mail.To = aAddr(i)
    SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("SmtpServer")
    SmtpMail.Send(mail)
    mail = Nothing
  End If
Next

I was hoping I could just assign the list of email addresses to the "To"
property.  What's the deal with the CDO library??  If a freeware SMTP
conponent exists, I would love to hear about it too.

Thanks.



Wed, 23 Mar 2005 01:30:40 GMT  
 Send an SMTP email to multiple recipients??
I used this example from DotNetJunkies.com to send mail to multiple
recipients. The email addresses are stored in a database, though. It has
worked great for me.

Original Source: http://www.dotnetjunkies.com/howto/default.aspx?id=3

'cmd is a SqlCommand that gets email addresses
Dim _r As SqlDataReader = cmd.ExecuteReader()
Dim _mm As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage()

_mm.Body = "This is my e-mail message"
While _r.Read()
   _mm.To = _r("Email")
   System.Web.Mail.SmtpMail.Send(_mm)
Loop

Rick


Quote:
> I am having problems sending a SMTP message to multiple recipients using
> Microsoft's System.Web.Mail library.  I continuously receive the error
> "Could not access 'CDO.Message' object.".  Whats the deal?

> If I send to one address, it works fine. If I try to assign the To
property
> to a semi-colon delimited list of addresses or loop through the list of
> emails and separately sending the messages.  When sending separately, the
> first message gets sent and then the error occurred on the second email.

> Here's a code snippet of the looping:
> ...
> Dim aAddr() As String = strAddr.Split(";")
> Dim i As Int32
> For i = 0 To aAddr.Length - 1
>   If aAddr(i).Length > 0 Then
>     Dim mail As New MailMessage()
>     mail.From = ConfigurationSettings.AppSettings("SmtpFromAddr")
>     mail.Subject = strSubject
>     mail.BodyFormat = MailFormat.Html
>     mail.Body = sBody
>     mail.To = aAddr(i)
>     SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("SmtpServer")
>     SmtpMail.Send(mail)
>     mail = Nothing
>   End If
> Next

> I was hoping I could just assign the list of email addresses to the "To"
> property.  What's the deal with the CDO library??  If a freeware SMTP
> conponent exists, I would love to hear about it too.

> Thanks.



Sun, 27 Mar 2005 04:19:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Send email to multiple recipient

2. Multiple Recipient Email from an array

3. multiple email recipients with MAPI

4. Need to code sending email to various recipients

5. Send as email recipient

6. Same Email sent to multiple email accounts

7. sending e-mail to multiple recipients.

8. sending email directly via SMTP

9. Sending Anon email via SMTP through Access97

10. Sending out emails. SMTP

11. Sending HTML format in Email messages using SMTP prototocal

12. send email using SMTP with VBA

 

 
Powered by phpBB® Forum Software