473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cdo errors

hi i am trying to send a mail using C# and asp.net
but i get the following error,
object objMail = Server.CreateObject("CDO.Message");
objMail.From = "ch***@hotmail.com";
objMail.To = "ch***@hotmail.com";
objMail.Subject = "Simple mail test";
objMail.TextBody = "Hi there; this is a test from the web
server.";
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1;
objMail.Fields.Update();
objMail.();

'object' does not contain a definition for 'From'
'object' does not contain a definition for 'To'
'object' does not contain a definition for 'Subject'
and so on
.......

but this works fine in vb.net and asp.net

Dim objMail As Object = Server.CreateObject("CDO.Message")
objMail.From = "ch***@hotmail.com"
objMail.To = "ch***@hotmail.com"
objMail.Subject = "Simple mail test"
objMail.TextBody = "Hi there; this is a test from the web
server."
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1
objMail.Fields.Update()
objMail.()

what do i do?
is it possible to use the cdo.message in c#?
cause everywhere on the net i have seen code for vb.net only and not c#

thanx
Chris

Jul 21 '05 #1
3 3347
Hi Chris,

C# does not support so called late binding - that is, when method names are
not checked at design time but the methods are called by name at run time.
Therefore, you should add the CDO type library as a yet another project
reference, use the new operator to create a CDO.Message instance and then
use the created instance like you did in VB .NET:

CDO.MessageClass message = new CDO.MessageClass();

message.From = from;
message.Sender = sender;
message.To = to;
message.Subject = subject;

message.TextBody = body;

message.Send();

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"chris" <as**@hotmail.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
hi i am trying to send a mail using C# and asp.net
but i get the following error,
object objMail = Server.CreateObject("CDO.Message");
objMail.From = "ch***@hotmail.com";
objMail.To = "ch***@hotmail.com";
objMail.Subject = "Simple mail test";
objMail.TextBody = "Hi there; this is a test from the web
server.";
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1;
objMail.Fields.Update();
objMail.();

'object' does not contain a definition for 'From'
'object' does not contain a definition for 'To'
'object' does not contain a definition for 'Subject'
and so on
......

but this works fine in vb.net and asp.net

Dim objMail As Object = Server.CreateObject("CDO.Message")
objMail.From = "ch***@hotmail.com"
objMail.To = "ch***@hotmail.com"
objMail.Subject = "Simple mail test"
objMail.TextBody = "Hi there; this is a test from the web
server."
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1
objMail.Fields.Update()
objMail.()

what do i do?
is it possible to use the cdo.message in c#?
cause everywhere on the net i have seen code for vb.net only and not c#

thanx
Chris


Jul 21 '05 #2
but there is no library called cdo.message in
project add reference. under .net tab
what do i do?
i added system.web.mail.but it cant find.
CDO.Message.
which is the library?

Chris

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:eK**************@TK2MSFTNGP11.phx.gbl...
Hi Chris,

C# does not support so called late binding - that is, when method names are not checked at design time but the methods are called by name at run time.
Therefore, you should add the CDO type library as a yet another project
reference, use the new operator to create a CDO.Message instance and then
use the created instance like you did in VB .NET:

CDO.MessageClass message = new CDO.MessageClass();

message.From = from;
message.Sender = sender;
message.To = to;
message.Subject = subject;

message.TextBody = body;

message.Send();

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"chris" <as**@hotmail.com> wrote in message
news:ez**************@TK2MSFTNGP10.phx.gbl...
hi i am trying to send a mail using C# and asp.net
but i get the following error,
object objMail = Server.CreateObject("CDO.Message");
objMail.From = "ch***@hotmail.com";
objMail.To = "ch***@hotmail.com";
objMail.Subject = "Simple mail test";
objMail.TextBody = "Hi there; this is a test from the web
server.";
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1;
objMail.Fields.Update();
objMail.();

'object' does not contain a definition for 'From'
'object' does not contain a definition for 'To'
'object' does not contain a definition for 'Subject'
and so on
......

but this works fine in vb.net and asp.net

Dim objMail As Object = Server.CreateObject("CDO.Message")
objMail.From = "ch***@hotmail.com"
objMail.To = "ch***@hotmail.com"
objMail.Subject = "Simple mail test"
objMail.TextBody = "Hi there; this is a test from the web
server."
objMail.Fields("urn:schemas:httpmail:importance"). Value = 1
objMail.Fields.Update()
objMail.()

what do i do?
is it possible to use the cdo.message in c#?
cause everywhere on the net i have seen code for vb.net only and not c#

thanx
Chris

Jul 21 '05 #3
The library is on the COM references tab. The IDE will automatically
generate the .NET Interop assembly for you when you reference the CDO
library from the "COM" tab.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"chris" <al**@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
but there is no library called cdo.message in
project add reference. under .net tab
what do i do?
i added system.web.mail.but it cant find.
CDO.Message.
which is the library?

Chris


Jul 21 '05 #4

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

Similar topics

11
by: mikey_boy | last post by:
Hello! Curious if anyone could give me a hand. I wrote this PHP script with makes a simple connection to a mysql database called firstdb and just pulls back the results and displays on the...
2
by: Trev | last post by:
SQL Server 2000 BE, Access 2002 FE. I want to write a stored procedure, that will among other things log errors to a table, I want to be able to report a summary of work done and errors to the...
10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
0
by: doli | last post by:
Hi, I have the following piece of code which iterates through the potential errors: i =0 For Each error_item in myConn.Errors DTSPackageLog.WriteStringToLog myConn.Errors(i).Description...
4
by: johnb41 | last post by:
I have a form with a bunch of textboxes. Each text box gets validated with the ErrorProvider. I want the form to process something ONLY when all the textboxes are valid. I found a solution,...
2
by: Samuel R. Neff | last post by:
Within the past few weeks we've been getting a lot of compiler errors in two classes when no errors actually exist. The error always reports as Name '_stepResizeRelocator' is not declared. ...
24
by: pat | last post by:
Hi everyone, I've got an exam in c++ in two days and one of the past questions is as follows. Identify 6 syntax and 2 possible runtime errors in this code: class demo {
8
by: ImOk | last post by:
I just have a question about trapping and retrying errors especially file locking or database locks or duplicate key errors. Is there a way after you trap an error to retry the same line that...
0
by: clemrock | last post by:
Help w/ errors.add_to_base between controller and model Hello, I'm having trouble in routing some errors between model and controller. The errors produced in the controller...
2
by: =?Utf-8?B?UmFuZHlz?= | last post by:
This just started when I updated to sp 1 working on a APS.net, Visual Studio 2008, c# Project. When I open a project, I get tons of Errors showing in the list 300+ if I double click on them I go...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.