473,378 Members | 1,393 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,378 software developers and data experts.

System.Runtime.InteropServices.COMException (0xC0048108)

hi ,

i am very new to .net world.

I wrote a code using c# ,which trys to access the emails from exchange server public folder i am getting the below exception:

System.Runtime.InteropServices.COMException (0xC0048108)
at ADODB.RecordsetClass.Open(Object Source, Object ActiveConnection, CursorTypeEnum CursorType, LockTypeEnum LockType, Int32 Options)

and i tried the sample code as shown below. exception is caused at
recordset open request.


using System;

namespace Samples
{
class Class1
{
static void Main(string[] args)
{
try
{
ADODB.Connection oCn = new ADODB.Connection();
ADODB.Recordset oRs = new ADODB.Recordset();

ADODB.Fields oFields;
ADODB.Field oField;

// TODO:
string sFdUrl = "http://ExchServer/Exchange/UserAlias/Inbox";

oCn.Provider = "exoledb.datasource";
oCn.Open(sFdUrl, "", "", -1);

if(oCn.State == 1)
{
Console.WriteLine("Good Connection");
}
else
{
Console.WriteLine("Bad Connection");
}


string strSql;
strSql = "";
strSql = "select ";
strSql = strSql + " \"urn:schemas:mailheader:content-class\"";
strSql = strSql + ", \"DAV:href\" ";
strSql = strSql + ", \"urn:schemas:mailheader:content-class\" ";
strSql = strSql + ", \"DAV:displayname\"";
strSql = strSql + " from scope ('shallow traversal of " + "\"";
strSql = strSql + sFdUrl + "\"') ";
strSql = strSql + " WHERE \"DAV:ishidden\" = false";
strSql = strSql + " AND \"DAV:isfolder\" = false";


oRs.Open(strSql, oCn,
ADODB.CursorTypeEnum.adOpenUnspecified,
ADODB.LockTypeEnum.adLockOptimistic, 1);

// As an example, you only retrieve the first message.
// You can use a while loop through each message.

// Get the first message.
oRs.MoveFirst();

// Get Recordset fields.
oFields = oRs.Fields;

string sUrl;
oField = oFields["DAV:href"];
sUrl = oField.Value.ToString();

CDO.Message iMsg = new CDO.Message();
iMsg.DataSource.Open(sUrl, oRs.ActiveConnection,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,
"", "");

Console.WriteLine("{0}", iMsg.Sender);
Console.WriteLine("{0}", iMsg.Subject);
Console.WriteLine("{0}", iMsg.TextBody);

// Get message fields.
oFields = iMsg.Fields;


for(int i = 0; i < oFields.Count; i++)
{
oField = oFields[i];
Console.WriteLine("{0} : {1}", oField.Name, oField.Value);
}


oRs.Close();
oCn.Close();

oCn = null;
oRs = null;
oFields = null;
oField = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}

can any one help me please ???
Thanks
Anand.
Oct 2 '07 #1
0 1454

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Brian Henry | last post by:
To use the SMTP mail service from System.Web.Mail do you have to have IIS installed on the client machien? I wanted my app to email any errors that may of occured to me on the clients machines in...
8
by: marcmc | last post by:
Trying to send an eMail frommy vb.net App. Is there anybody out there that has successfully done this? I am having major problems and need a step by step guide into the world of system.web and...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
0
by: Yong | last post by:
I have a COM DLL written in C++ which worked fine when called from VB6. But we have now moved to Visual Studio 2005 - .NET Framework v2 and Windows XP Pro. In total there are 4 methods in this DLL...
1
by: umeshatpromact | last post by:
Hello!, I got following exception when using COM component for EXCEL object in ASP .Net. I have added reference of "Microsoft.Office.Interop.Excel.dll" I deployed an application on local...
1
by: sasikumarks | last post by:
Hi, Im using the following code to retrieve the user details from the AD server. But when i execute the code,it throws me the error. Please help me in this...
3
by: bharathreddy | last post by:
Hi, Why do we get System.Runtime.InteropServices.COMException. Simple terms exception is thrown when an unrecognized HRESULT is returned from a COM method call. Apart from this is there any...
2
by: sriregu | last post by:
Hi, i am trying the exe file in .net environment and am getting the following error.Any idea how i can resolve it? System.Runtime.InteropServices.COMException (0x80040154): Class not registered ...
0
by: =?Utf-8?B?am1hZ2FyYW0=?= | last post by:
I have a Windows service written in C# that is configured to automatically start. Sometimes - maybe 20% of the time - the service fails to start due to an exception in WMI code. I haven't made my...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.