I have an async OnStore event written in c# and registered in exchange 2003.
Everything seems to be working fine other than the SaveToFile().
If there is an error in the iMessage.DataSource.Open ( ie. the message has
moved ) the expected exception is raised and caught.
However when the strm.SaveToFile() is executed the process just seems to
die - no output file is generated , no exceptions raised , no system log
entries , no more log() entries are written - nothing.
If I comment this line out , the method runs to completion as it should.
The log() method writes to a log in the same target directory as the
SaveToFile so this is not a permissions problem on the destination file.
any insights here would be appreciated
gerry
void IExStoreAsyncEvents.OnSave( IExStoreEventInfo info , string url , int
flags )
{
pid=System.DateTime.Now.Ticks;
IExStoreDispEventInfo dinfo = (IExStoreDispEventInfo)info;
log("OnSave",String.Format("url:{0}\n\tflags:0x{1: x4}\n\tsource URL :
{2}",url,flags,dinfo.SourceURL));
// if ( ( flags & 0x08 ) != 0x00 ) return;
// sleep here to let system filters/rules etc take effect
// if message is moved elsewhere - Open will fail
log("OnSave","Sleep(1)");
System.Threading.Thread.Sleep(4000);
log("OnSave","1");
try
{
log("OnSave","iMessage=new CDO.Message()");
CDO.Message iMessage=new CDO.MessageClass();
log("OnSave","iMessage.DataSource.Open");
iMessage.DataSource.Open(url,null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,"","");
try
{
String dstFile=String.Format("{0}\\m{1}.eml",appRoot,pid) ;
log("OnSave",dstFile);
log("OnSave","strm = iMessage.GetStream()");
ADODB.Stream strm = iMessage.GetStream();
log("OnSave","strm.SaveToFile");
strm.SaveToFile(dstFile,ADODB.SaveOptionsEnum.adSa veCreateOverWrite);
log("OnSave","saved");
strm.Close();
}
catch (Exception e)
{
log("Exc1",e.ToString());
}
}
catch (Exception e)
{
log("Exc2",e.ToString());
}
log("OnSave","Done");
}