send email with VB.NET and exchange

  • Thread starter Thread starter Samia
  • Start date Start date
S

Samia

I have an application running on a single workstation (win 2000) with
Outlook installed and a profile create using and exchange server with
authentification through the DNS. This user profile is the only one
using the app.

I want the app to send email using the profile's email adress.

Here is what I am doing :

Dim mail As New MailMessage()
mail.From = "(e-mail address removed)"
mail.To = "(e-mail address removed)"
mail.Subject = "test msg"
mail.Body = "blablabla"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "mydomain.com"
SmtpMail.Send(mail)

The problem is that I get the error message
An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll
Additional information: Could not access 'CDO.Message' object.

I tried changing smtpserver to myexchangeserver.mydomain.com and I get
the same error message.

Any ideas?

Samia.
 
Samia said:
I have an application running on a single workstation (win 2000) with
Outlook installed and a profile create using and exchange server with
authentification through the DNS. This user profile is the only one
using the app.

I want the app to send email using the profile's email adress.

Here is what I am doing :

Dim mail As New MailMessage()
mail.From = "(e-mail address removed)"
mail.To = "(e-mail address removed)"
mail.Subject = "test msg"
mail.Body = "blablabla"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "mydomain.com"
SmtpMail.Send(mail)

The problem is that I get the error message
An unhandled exception of type 'System.Web.HttpException' occurred in
system.web.dll
Additional information: Could not access 'CDO.Message' object.

I tried changing smtpserver to myexchangeserver.mydomain.com and I get
the same error message.

Any ideas?

Look at all of the messages in the exception stack, "Could not access
'CDO.Message' object" is the message in the first exception. That exception
also has an InnerException property which probably references another
exception etc, etc. Keep going until InnerException is null. When you see
all of the messages you'll have a better idea of what's going wrong.

You can also use the ToString() method on an exception and it will build a
string that contains all of the messages.
 
I tried what you suggested. Doesn't work. I don't get an error message
however. No error message, the code is executed and nothing happens.

here is the code:

Dim iMsg As New CDO.Message()

iMsg.From = "(e-mail address removed)"
iMsg.To = "(e-mail address removed)"
iMsg.HTMLBody = "samia"


iMsg.Send()

any other ideas???

Thanks

Samia.
 
Samia,

I have the same problem, only doing this from an ASP.Net website. The only
reason I could find for this was the installation of Office XP, which
replaces the reference to the CDO dll on Windows with a newer version (which
in my mind might be the only problem). I haven't found anything to verify my
thoughts, though.

As for the other suggested solution, I've used it, and it works fine. You
have to set the SMTP server on the Configuration of the e-mail message
object:

Dim iMsg As New CDO.Message()

iMsg.From = "(e-mail address removed)"
iMsg.To = "(e-mail address removed)"
iMsg.HTMLBody = "samia"

iMsg.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/se
ndusing"].Value = 2;

iMsg.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserverport"].Value = 25;

iMsg.Configuration.Fields["http://schemas.microsoft.com/cdo/configuration/sm
tpserver"].Value = strMailServer;
iMsg.Configuration.Fields.Update();

iMsg.Send()

Hope this helps

Thys Brits
MCSD/MCAD
 
Back
Top