Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 7:30 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: Help Sending e-mail from VB.Net application
PostPosted: Thu Nov 06, 2008 3:15 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: Help Sending e-mail from VB.Net application
PostPosted: Thu Nov 06, 2008 3:16 pm 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
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.


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 video chat application in java
 Sending One lakh character in ajax
 Ajax Source code to Suggest application with JSP Server side
 I need chat application using php
 creating application
 want to develop an application of my own
 Application for the post of Network Admin.
 how to develop a mobile application for nokia help of java
 how to make an application in java for cell phone.
 How to send conformation e-mail through JSP

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






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