我在MSDN上找到下面的资料http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_idatasource_open.aspSourceURL Specifies the URL of the existing item to open. New items cannot be created using the Open method. Use SaveTo or SaveToContainer. ActiveConnection Specifies the connection to use when opening. This is a reference to a Microsoft® ActiveX® Data Objects (ADO) Connection object. A new Connection object (session) is implicitly created if none is specified. Mode ADO-defined access mode enumeration. The specified value is always ORed with adModeRead (1). This means that at least read access is requested when opening an item, not that only read access is requested. CreateOptions Must be adFailIfNotExists. New items cannot be created using the Open method. Options This specifies options flag opening the source. The only supported open option is adOpenAsynch. Your setting is always ORed with adOpenSource. UserName Used to pass a user name if needed for authentication. Password Used to pass a password if needed for authentication. Return Value 根据这个我写了这样一段程序,懂的朋友们请看看CDO.Folder folder = new CDO.FolderClass();
ADODB.Connection Conn = new ADODB.Connection(); Conn.Provider = "ExOLEDB.DataSource"; Conn.Open(urlabc,strUser,strPass,16);
重载“open”的方法来获取“1”参数
“一般性拒绝访问错误 ”
folder.DataSource.Open(urlabc," ",ADODB.ConnectModeEnum.adModeRead,ADODB.RecordCreateOptionsEnum.adOpenIfExists,ADODB.RecordOpenOptionsEnum.adOpenSource,strMBXAlias,strMBXPass);第二个参数我不知道怎么写了,就是那个object ActiveConnection请多指教!
Specifies the URL of the existing item to open. New items cannot be created using the Open method. Use SaveTo or SaveToContainer.
ActiveConnection
Specifies the connection to use when opening. This is a reference to a Microsoft® ActiveX® Data Objects (ADO) Connection object. A new Connection object (session) is implicitly created if none is specified.
Mode
ADO-defined access mode enumeration. The specified value is always ORed with adModeRead (1). This means that at least read access is requested when opening an item, not that only read access is requested.
CreateOptions
Must be adFailIfNotExists. New items cannot be created using the Open method.
Options
This specifies options flag opening the source. The only supported open option is adOpenAsynch. Your setting is always ORed with adOpenSource.
UserName
Used to pass a user name if needed for authentication.
Password
Used to pass a password if needed for authentication.
Return Value
根据这个我写了这样一段程序,懂的朋友们请看看CDO.Folder folder = new CDO.FolderClass();
ADODB.Connection Conn = new ADODB.Connection();
Conn.Provider = "ExOLEDB.DataSource";
Conn.Open(urlabc,strUser,strPass,16);
folder.DataSource.Open(urlabc,XXXXXX,ADODB.ConnectModeEnum.adModeRead,ADODB.RecordCreateOptionsEnum.adFailIfNotExists,ADODB.RecordOpenOptionsEnum.adOpenAsync,strUser,strPass);
如果在XXXXXX的地方用了Conn 则系统显示“完成该操作所需的数据还不可使用。”。
如果在XXXXXX的地方用了null 则系统显示“验证失败”。出错行都是folder.DataSource.Open这一行,请高手指教
xxxxx的地方用Conn
至少在vb,asp历史这么用的
但是还是出现folder.DataSource.Open这一句提示“完成该操作所需的数据还不可使用。 ”用-1或0的话,则说Conn.Open这一句“验证不通过”
用其他的数字则全部显示“参数类型不正确,或不在可以接受的范围,或与其他参数冲突”简直没办法了!!!!!
这么写:
CDO.Folder folder = new CDO.FolderClass();
ADODB.Connection Conn = new ADODB.Connection();
Conn.Provider = "ExOLEDB.DataSource";
folder.DataSource.Open(urlabc,Conn,ADODB.ConnectModeEnum.adModeRead,ADODB.RecordCreateOptionsEnum.adFailIfNotExists,ADODB.RecordOpenOptionsEnum.adOpenAsync,strUser,strPass);
我这样写了,但是运行后说不能通过验证这后面的strUser和strPass你怎么写的??
strPass="密码"
CDO.Folder folder = new CDO.FolderClass();
strUser="域名\\用户名" //如:"dssweboa\\scgqq"
strPass="密码"
ADODB.Connection Conn = new ADODB.Connection();
Conn.Provider = "ExOLEDB.DataSource";
Conn.Open(urlabc,null,null,-1);
folder.DataSource.Open(urlabc,conn,ADODB.ConnectModeEnum.adModeReadWrite,ADODB.RecordCreateOptionsEnum.adCreateNonCollection,ADODB.RecordOpenOptionsEnum.adOpenSource,strUser,strPass);
怎么样!没问题吧!
给分!
string strMBXAlias = "777";
string strMBXPass = "777";
string strName = Dns.GetHostName();
string urlMailBox = "file://./backofficestorage/" + strName + "/MBX/" + strMBXAlias + "/收件箱";CDO.Folder folder = new CDO.FolderClass();
ADODB.Connection Conn = new ADODB.Connection();
Conn.Provider = "ExOLEDB.DataSource";
Conn.Open(urlMailBox,null,null,-1);folder.DataSource.Open(urlMailBox,Conn,ADODB.ConnectModeEnum.adModeReadWrite,ADODB.RecordCreateOptionsEnum.adCreateNonCollection,ADODB.RecordOpenOptionsEnum.adOpenSource,strMBXAlias,strMBXPass);
说明:目的,打开Exchange中信箱里的邮件
完整的计算机名:abc.hello.com
strMBXAlias 的地方用了777或者hello\777都不行提示错误如下:在此操作范围内,没有发现和目标,数据匹配的名称,范围,或选择条件。 就是下面这一行Conn.Open(urlMailBox,null,null,-1);