Total members 11890 |It is currently Thu Apr 18, 2024 3:13 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I'm somewhat new to VB.Net but I've programmed ASP.Net and VB6 before.
Anyway, I'm trying to send a bunch of emails from a listbox and I get an
error. Here's the exception message:
"Could not access 'CDO.Message' object."

I don't know what could be causing it. If someone could shed some light
I'd appreciate it. Here's my code:

Code:
Dim MailMsg As New System.Web.Mail.MailMessage
Dim mServer As System.Web.Mail.SmtpMail

MailMsg.Subject = "Message Subject"
MailMsg.Body = "Message Body."
MailMsg.From = "fromaddress@... <mailto:fromaddress@...>
"
MailMsg.BodyFormat = Web.Mail.MailFormat.Html
mServer.SmtpServer = "smtpserver.com"

For i = 0 To lstEmails.Items.Count - 1
lstEmails.SelectedIndex = i
MailMsg.To = lstEmails.SelectedValue
mServer.Send(MailMsg)
Next





Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

This should work in you mailling application!!!
Code:
Dim ErrLog As String
Dim MailMsg As New System.Web.Mail.MailMessage
Dim mServer As System.Web.Mail.SmtpMail

With MailMsg
.Subject = "Message Subject"
.Body = "Message Body."
.From = "fromaddress@..."
.BodyFormat = Web.Mail.MailFormat.Html
mServer.SmtpServer = "smtpserver.com"

For i = 0 To lstEmails.Items.Count - 1
lstEmails.SelectedIndex = i
.To = lstEmails.SelectedValue
Try
mServer.Send(MailMsg)
Catch EX As Exception
ErrLog = ErrLog & EX.message & "; "
End Try
Next
End with

'Go ahead and display your ErrLog here to the user if any

NOTE:
I put the mServer.Send method in a try block in case there's any of the
lstEmails values that's not in email address format. That could generate an
error and stop the application from sending the mail to others.

Another thing I think was the problem in your application is the introduction
of the <mailto:""> tag in your .From value. As much as I know, that is not
necessary.

I hope this helps.


Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Help Sending e-mail from VB.Net application
 Connecting Java Application to C++ Application from Code     -  
 sending sms from bluetooth mobile to pc     -  
 Sending One lakh character in ajax     -  
 Sending a post request using AJAX     -  
 sending parameters into XSLT sheet     -  
 AJAX - Sending a request to a server     -  
 Sending and playing microphone audio over network     -  
 sending sms using java code and bluetoth device pls send the     -  
 validate mail in jsp     -  
 validate e-mail in php     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com