sba
Guest
|
Posted:
Mon Aug 15, 2005 4:59 pm Post subject:
How to query for mails and obtain a stream from each mail |
|
|
Hi there
I want to query for mails that satisfy a certain condition, filling
them up in a recordset and iterate through them. For each mail I need
the stream and I want to modify the mail body. This should be done by a
standalone application written in C# that may be colocated on the same
server that hosts Exchange.
I understand that I can't modify mails using ADO.NET, apparently. I'm
using interop.adodb therefore. Is this still true?
I already managed to fetch single mails in a ADODB.Record and obtain a
stream in a web store handler. So, once I have a ADODB.Record I can
manage.
What I'm struggling is iterating through the ADODB.Recordset. The field
property contains one item that is a System.__ComObject and I've no
idea to what I can cast this object.
The questions are:
Is it naive to believe that the ADODB.Recordset contains
ADODB.Record's?
How can I make use of the System.__ComObject object in the recordset?
What is it? To what can I cast/wrap it?
Is there a different (better) way to implement my task?
Regards,
Stephan Bachofen
const String field= "urn:schemas.httpmail:subject";
const String strUrl=
"file://./backofficestorage/EXCHANGE.SVR/MBX/sba/";
const String strSql= "SELECT \"" + "*" + "\" FROM scope('\"" + strUrl +
"\"')";
ADODB.Connection conn=new ADODB.Connection();
ADODB.Recordset rs= null;
try
{
conn.Provider = "exoledb.datasource";
conn.Open(strUrl, "Administrator", "password", -1);
rs= new ADODB.RecordsetClass();
rs.Open(strSql, conn, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 1);
//rs.Open(null, strSql, ADODB.CursorTypeEnum.adOpenStatic,
ADODB.LockTypeEnum.adLockBatchOptimistic, 1);
if (rs.BOF && rs.EOF)
{
MessageBox.Show("No mails found", "Name Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (rs.BOF)
{
rs.MoveFirst();
}
while (!rs.EOF)
{
ADODB.Fields fields= rs.Fields;
WriteToLog("fields count " + fields.Count);
Object obj= fields[0];
// obj is a System.__ComObject. What can I do with it now?
WriteToLog(obj.GetType().ToString());
}
}
finally
{
if (null != rs)
{
try
{
rs.Close();
}
catch {}
}
try
{
conn.Close();
} catch {}
}
|
|