How to query for mails and obtain a stream from each mail
Exchange Server Forum Index Exchange Server
Discussion forums for Microsoft Exchange Server users.
Microsoft Outlook
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web ExchangeServerHelp.com
How to query for mails and obtain a stream from each mail

 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development
Author Message
sba
Guest





Posted: Mon Aug 15, 2005 4:59 pm    Post subject: How to query for mails and obtain a stream from each mail Reply with quote

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 {}
}

Back to top
 
Post new topic   Reply to topic    Exchange Server Forum Index -> Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server Dedicated Servers
Contact Us
New Topics Powered by phpBB