Switch to full style
You can find discussions, solutions and codes related to ASP.NET
Post a reply

Help Sending e-mail from VB.Net application

Thu Nov 06, 2008 3:15 pm

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




Re: Help Sending e-mail from VB.Net application

Thu Nov 06, 2008 3:16 pm

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.

Post a reply
  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     -  
 AJAX - Sending a request to a server     -  
 Sending One lakh character in ajax     -  
 Sending a post request using AJAX     -  
 sending parameters into XSLT sheet     -  
 Sending and playing microphone audio over network     -  
 sending sms using java code and bluetoth device pls send the     -  
 send mail cc and bcc in php     -  
 how to send mail with Ant     -