Migrate issues Event sink from Exchange 2003 Exchange 2007

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by bmljbGFzYW » Sat, 23 May 2009 18:28:03


Hi,

we have developed an OnSave Event sink for current Exchange 2003
environment. Now we want to migrate this to a Exchange 2007 environment.

The event sink fires when pubic folders receive mail and then sends the mail
to a distribution list for that particular public folder.

I have tried to update the project for a x64 environment following this blog
post:
http://www.yqcomputer.com/
I can see that the Event sink is triggered, but nothing happens after
MessageClass is created. Thus the message.DataSource.Open does not seem to
work.

Code is posted below.

Please help!

Regards
Niclas

Exchange 2003 Event sink code:
public void OnSave(IExStoreEventInfo eventInfo, string urlItem, int
flags)
{
Trace.WriteLineIf(_debugLevel.TraceVerbose, String.Format("{0}:
OnSave urlItem: {1} flags: {2} version: {3} ", DateTime.Now, urlItem, flags,
_version));
try
{
if ((flags & (int)EVT_SINK_FLAGS.EVT_IS_DELIVERED) > 0)
{
MessageClass message = new MessageClass();

// Get the message
message.DataSource.Open(urlItem,
null,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,
"", "");


....

// The CC and BCC are cleared to avoid duplicate
messages
message.CC = string.Empty;
message.BCC = string.Empty;

message.Send();


Edited code for Exchange 2007:
public void OnSave(IExStoreEventInfo eventInfo, string urlItem, int
flags)
{
try
{
if ((flags & (int)EVT_SINK_FLAGS.EVT_IS_DELIVERED) > 0)
{
MessageClass message = new MessageClass();


// Get the message
message.DataSource.Open(urlItem,
null,
Interop.msado28.ConnectModeEnum.adModeReadWrite,

Interop.msado28.RecordCreateOptionsEnum.adFailIfNotExists,
Interop.msado28.RecordOpenOptionsEnum.adOpenSource,
"", "");

....

// The CC and BCC are cleared to avoid duplicate
messages
message.CC = string.Empty;
message.BCC = string.Empty;

message.Send();
 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by Sven » Sat, 23 May 2009 20:23:29

Hi Niclas,


What exceptions to you catch?
Is any catch block executed? If yes, what exception details do you get?

 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by bmljbGFzYW » Sat, 23 May 2009 21:00:22

Hi SvenC,

there is a catch block, but the strange this is that I see no Event log
message or trace.

catch (Exception ex)
{
EventLog eventLog = new EventLog("Application", ".",
Properties.Resources.ApplicationName);

eventLog.Wri *** try(string.Format(Properties.Resources.OnSaveUnknownExceptionMessage, ex.Message), EventLogEntryType.Error, _OnSaveEventID);

Trace.WriteLineIf(_debugLevel.TraceError,
String.Format("{0}: Error [OnSave], Message={1}", DateTime.Now, ex.Message));
}

Regards
Niclaxs
 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by Sven » Sat, 23 May 2009 21:40:22

Hi Niclas,


Are you sure that you can access the event log at this time?


Try to use Trace.WriteLineIf before using the eventlog so that eventlog
problems
do not throw in the catch block and your trace code is not reached.
 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by bmljbGFzYW » Tue, 26 May 2009 14:43:02

Moved the Trace and got a message.

"5/25/2009 7:38:16 AM: Error [OnSave], Message=Access is denied."

Guess I need some kind of log in?

Regards
Niclas
 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by bmljbGFzYW » Tue, 26 May 2009 18:09:00

The compoent is regsitered as a COM+ app, using a specific user account for
this.

The access denied error is when opening the message in the code:
message.DataSource.Open(urlItem,
null,
ADODB.ConnectModeEnum.adModeReadWrite,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,
"", "");

I guess I have to check the access the user has to the public folder.

Regards
Niclas
 
 
 

Migrate issues Event sink from Exchange 2003 Exchange 2007

Post by bmljbGFzYW » Wed, 03 Jun 2009 17:50:01

I have gotten around the first error by setting up more permisions for the
user running the COM+ application.

The error I can't get around is the following. Pasted from the event log:
"An exception has occurred in the OnSave method. The error message is: The
"SendUsing" configuration value is invalid"

The event sink is running on different machine(s) than that of the Hub role.

How do I get around this roblem?

Regards
Niclas