473,806 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MailMessage problem - Could not access 'CDO.Message' object.

Hello All,

I have a VB.Net app that needs to send mail. I have created a class for
building my e-mail, but keep getting the error (Could not access
'CDO.Message' object.) when trying to send it. I can successfully send an
e-mail when I use the CreateObject("C DO.Message") method, but it fails when
trying to send using VB.Net. My code is below, I have included three
different ways that I have tried it, and both VB.Net options fail, any help
will be greatly appreciated.

--
Thank you,

Anthony Fine
'// VB 6.0 - This works fine...
'************** *************** *************** ***
Private Sub Form_Load()
Dim iNewMsg As Object
Set iNewMsg = CreateObject("C DO.Message")
iNewMsg.To = "so*****@there. com"
iNewMsg.From = "me@here.co m"
iNewMsg.Subject = "Test"
iNewMsg.TextBod y = "Hello..."
iNewMsg.Send
Set iNewMsg = Nothing
End Sub
'************** *************** *************** ***

'// VB.Net - This fails...
'************** *************** *************** ***
Imports System.Web.Mail
Imports System.Web.Mail .SmtpMail

Public Class Form1
Inherits System.Windows. Forms.Form

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim iMsg As New MailMessage
Dim srv As SmtpMail
iMsg.To = "so*****@there. com"
iMsg.From = "me@here.co m"
iMsg.BodyFormat = MailFormat.Text
iMsg.Body = "Testing... "
iMsg.Subject = "Test..."
srv.SmtpServer = "myServer"
srv.Send(iMsg)
End Sub
End Class
'************** *************** *************** ***

'// VB.Net - This fails as well...
'************** *************** *************** ***
Imports System.Web.Mail
Imports System.Web.Mail .SmtpMail

Public Class Form1
Inherits System.Windows. Forms.Form

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim newMail As New emailMessage
newMail.EmailTo = "so*****@there. com"
newMail.EmailFr om = "me@here.co m"
newMail.EmailBo dyFormat = MailFormat.Text
newMail.EmailBo dy = "Testing... "
newMail.EmailSu bject = "Test..."
newMail.EmailSe rver = "myServer"
newMail.sendEma il()
newMail = Nothing
End Sub

End Class

Class emailMessage
Dim iMail As New MailMessage
Dim _to As String
Dim _from As String
Dim _server As SmtpMail
Dim _subject As String
Dim _body As String
Dim _bodyFormat As System.Web.Mail .MailFormat
Dim myServer As String

Public Property EmailTo() As String
Get
iMail.To = _to
End Get
Set(ByVal Value As String)
_to = Value
End Set
End Property

Public Property EmailFrom() As String
Get
iMail.From = _from
End Get
Set(ByVal Value As String)
_from = Value
End Set
End Property

Public Property EmailServer() As String
Get
_server.SmtpSer ver = myServer
End Get
Set(ByVal Value As String)
myServer = Value
End Set
End Property

Public Property EmailSubject() As String
Get
iMail.Subject = _subject
End Get
Set(ByVal Value As String)
_subject = Value
End Set
End Property

Public Property EmailBody() As String
Get
iMail.Body = _body
End Get
Set(ByVal Value As String)
_body = Value
End Set
End Property

Public Property EmailBodyFormat () As System.Web.Mail .MailFormat
Get
iMail.BodyForma t = _bodyFormat
End Get
Set(ByVal Value As System.Web.Mail .MailFormat)
_bodyFormat = Value
End Set
End Property

Public Sub sendEmail()
_server.Send(iM ail)
End Sub
End Class
'************** *************** *************** ***
Nov 20 '05 #1
3 2588
Cor
Hi Anthony,

Five messages below yours is an answer from Herfried as well as from Bernie
on a problem like this, maybe you can have a look at that?

Cor

I have a VB.Net app that needs to send mail. I have created a class for
building my e-mail, but keep getting the error (Could not access
'CDO.Message' object.) when trying to send it. I can successfully send an
e-mail when I use the CreateObject("C DO.Message") method, but it fails when trying to send using VB.Net. My code is below, I have included three
different ways that I have tried it, and both VB.Net options fail, any help will be greatly appreciated.

Nov 20 '05 #2
* "Anthony Fine" <an*****@sfa200 0.com> scripsit:
I have a VB.Net app that needs to send mail. I have created a class for
building my e-mail, but keep getting the error (Could not access
'CDO.Message' object.) when trying to send it. I can successfully send an
e-mail when I use the CreateObject("C DO.Message") method, but it fails when
trying to send using VB.Net. My code is below, I have included three
different ways that I have tried it, and both VB.Net options fail, any help
will be greatly appreciated.


Does this sample work for you (notice that I forgot to specify the SMTP
server):

<http://www.mvps.org/dotnet/dotnet/samples/net/downloads/SendMail.zip>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Thanks for the responses, but sorry to report that it still does not work.
I get the same error message. The error message has to be a generic message
since I was able to successfully send mail using the
CreateObject("C DO.Message") method from VB 6.0, and the error I get is,
"Could not access 'CDO.Message' object." when trying it from VB.Net.

Thanks again,

Anthony

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:br******** ****@ID-208219.news.uni-berlin.de...
* "Anthony Fine" <an*****@sfa200 0.com> scripsit:
I have a VB.Net app that needs to send mail. I have created a class for
building my e-mail, but keep getting the error (Could not access
'CDO.Message' object.) when trying to send it. I can successfully send an e-mail when I use the CreateObject("C DO.Message") method, but it fails when trying to send using VB.Net. My code is below, I have included three
different ways that I have tried it, and both VB.Net options fail, any help will be greatly appreciated.


Does this sample work for you (notice that I forgot to specify the SMTP
server):

<http://www.mvps.org/dotnet/dotnet/samples/net/downloads/SendMail.zip>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1339
by: JP | last post by:
I have been at odds with our network guy over an application that is designed to send alert emails to accounts outside of our domain to users. The issue is the mail server is not set for "open relay" so any Mail.Send() that is to an account outside of our domain server gets rejected by the SMTP. Any accounts inside the domain get sent properly. System.Web.HttpException: Could not access 'CDO.Message' object. --->...
3
6549
by: Mike P | last post by:
Can the MailMessage class be used to send emails from a machine that has no email account (such as Outlook)? Mike *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
3
3279
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From = "W-MyPcName.mycompany.com"; mail.To=strTo; mail.Cc=strCC; mail.Bcc=strBCC;
6
2546
by: Frank | last post by:
Straightforward VB.NET 2002 code that works form both Windows and ASP.NET apps on a Windows 2000 machine, and works in the Windows app on a newly installed XP machine, but fails in the ASP.NET code on XP. The unhandled exception is "COMException: The 'SendUsing' configuration value is invalid." If I handle the exception, the exception's Message is "Could not access 'CDO.Message' object." The essence of the code is:
4
7553
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP SP2, and IIS's SMTP and WWW servers are installed. Here is the error trace: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an...
0
1806
by: Carlos | last post by:
Hmm it should be fairly simple i guess, but im stuck big time. Cant seem to find iDataSource anywhere. What im trying to do is to read a textfile (mail.mai) into an CDO Mailmessage object. So that i can modify it from there. Ive found this sample from ms, but.. im stuck. could anyone translate ? Function LoadMessageFromFile(Path) 'As Message Dim Stm
7
1570
by: MSG Servicos de Informatica | last post by:
Hi MSDN Team! I have a doubt about the "MailMessage" class in Framework .NET 1.1. My SMTP server works in a local network that no have access to the internet for security reasons. And in my network we have an application that send emails to other department inside the company using us SMTP server that requires authentication... I'd like to know why when I use the "MailMessage" Class with "SMTPServer" class to authenticate in my SMTP...
1
1161
by: mannyGonzales | last post by:
Guys, Using .Net 1.1 I have a xml config file that list of two email address separated by a semicolon. <to>mailbox1@here.com;mailbox2@here.com</to> using the system.web.mail namespace
2
1261
by: Jerryb | last post by:
I am using the Mailmessage class in my VB app, Everything works fine on my WinXP development box but when I run the app on Windows 2000 server it fails with "could not create cdo.message object" Please help, my code is below and like I said it works fine on my XP machine: (to,cc,subject and from are passed to the sub) Dim strHTML As String Dim newmsg As New MailMessage
0
9598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3852
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.