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
'************** *************** *************** *** 3 2588
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.
* "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>
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> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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. --->...
|
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!
|
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;
|
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:
|
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...
| |
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
|
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...
|
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
|
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
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |