Total members 11356 |It is currently Thu Aug 28, 2014 12:22 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

All times are UTC [ DST ]



  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



Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time
  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.


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

All times are UTC [ DST ]









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team