OpenObject fails with Appointment
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
OpenObject fails with Appointment

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





Posted: Fri Sep 09, 2005 4:02 pm    Post subject: OpenObject fails with Appointment Reply with quote

Hi,

I want to change something to an Appointment before it is saved.
The place todo this is in the OnSyncSave event when EVT_SYNC_BEGIN flag
is set, at this point the record is not yet in the database and you can
update fields and outlook will not complain about it.
When using the OpenObject method on an appointment it fails, using the
same method on a message goes OK.
I'm using an exchange 2003/sp1 server with Exchange 2003 SDK.
Because I need to update something, I cannot "bypass" this problem by
using a stream!
Because I want to update the Attendees Property I cannot update by using
the Record object, I must use the Appointment interface.

Does anyone know why it is failing? And how to fix it?

Below is the function in C++

Other user with simular problem:
OnSyncSave with Appointment
http://groups.google.com/group/microsoft.public.exchange.development/bro
wse_frm/thread/c62f1756ef8eb0ba/e16565131ea803b3
(long link, sorry)

Regards,
Bart.

STDMETHODIMP CExEv::OnSyncSave(IExStoreEventInfo *pEventInfo, BSTR
bstrURLItem, LONG lFlags) {

CString s;
HRESULT hr= S_OK;
CComVariant varTmp;
IMessagePtr iMsg(__uuidof(Message));
IAppointmentPtr Appt(__uuidof(Appointment));
IExStoreDispEventInfoPtr pItem= pEventInfo;
_RecordPtr rs;

message(EV|2, L"OnSyncSave event bstrURLItem=%s lFlags=%lX",
bstrURLItem, lFlags);

if (lFlags & EVT_SYNC_BEGIN) {
message(EV, L"sync-begin");
hr = pItem->get_EventRecord((IDispatch**)&rs);
if (hr== S_OK) {
// Print the subject field from rs
varTmp= rs->Fields->GetItem(szSubjectField)->Value;
if (varTmp.vt!= VT_EMPTY)
s= varTmp.bstrVal;
else
s= L"";
message(EV|2, L"Subject from rs: \"%s\"", (const TCHAR
*)s);

// OpenObject by Message goes OK!
try {
hr= iMsg->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"iMsg->DataSource->
OpenObject");
}
// It prints the subject field OK!
if (hr== S_OK) {
message(EV|2, L"Subject from iMsg: \"%s\"",
(const TCHAR *)iMsg->Subject);
}

// OpenObject by Appointment fails!
// it returns error code 80070057
// meaning: The parameter is incorrect.
try {
hr= Appt->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"Appt->DataSource->
OpenObject");
}
if (hr== S_OK) {
message(EV|2, L"Subject from Appt: \"%s\"",
(const TCHAR *)Appt->Subject);
}
}
}
if (lFlags & EVT_SYNC_COMMITTED) {
message(EV, L"sync-committed");
hr= pItem->get_EventRecord((IDispatch**)&rs);
if (hr== S_OK) {
varTmp= rs->Fields->GetItem(szSubjectField)->Value;
if (varTmp.vt!= VT_EMPTY)
s= varTmp.bstrVal;
else
s= L"";
message(EV|2, L"Subject from rs: \"%s\"", (const TCHAR
*)s);

// OpenObject by Appointment fails!
try {
hr= Appt->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"Appt->DataSource->
OpenObject");
}
if (hr== S_OK) {
message(EV|2, L"Subject from Appt: \"%s\"",
(const TCHAR *)Appt->Subject);
}
}
}
return S_OK;
}

This is printed in the log file by the message() function:

[3] 12:40:33: CExEv class startup
[2] 12:40:33: OnSyncSave event
bstrURLItem=file://./backofficestorage/ad.cts-
devexch.cts/MBX/Administrator/Calendar/Testing subject!.EML lFlags=
1000041
[0] 12:40:34: sync-begin
[2] 12:40:34: Subject from rs: "Testing subject!"
[2] 12:40:34: Subject from iMsg: "Testing subject!"
[0] 12:40:34: COM-ERROR: Appt->DataSource->OpenObject!
[0] 12:40:34: Code = 80070057
[0] 12:40:34: Code meaning = The parameter is incorrect.
[0] 12:40:34: Source = CDO.Appointment.1
[0] 12:40:34: Description = The parameter is incorrect.


[2] 12:40:34: OnSyncSave event
bstrURLItem=file://./backofficestorage/ad.cts-
devexch.cts/MBX/Administrator/Calendar/Testing subject!.EML lFlags=
2000001
[0] 12:40:34: sync-committed
[2] 12:40:34: Subject from rs: "Testing subject!"
[0] 12:40:34: COM-ERROR: Appt->DataSource->OpenObject!
[0] 12:40:34: Code = 80070057
[0] 12:40:34: Code meaning = The parameter is incorrect.
[0] 12:40:34: Source = CDO.Appointment.1
[0] 12:40:34: Description = The parameter is incorrect.

Back to top
Blair Nygren
Guest





Posted: Thu Dec 01, 2005 5:58 pm    Post subject: RE: OpenObject fails with Appointment Reply with quote

Don't know if this helps. but I do the same thing but from C# and it works
fine. I don't open the object openobject but open via the URL.

see below
public interop.CDOEX.AppointmentClass GetAppointment(string bstrurl)
{
try
{ Trace.WriteLine(DateTime.Now + " GetAppointment: Open: " + bstrurl);
interop.CDOEX.AppointmentClass iAppt = new interop.CDOEX.AppointmentClass();
iAppt.DataSource.Open(bstrurl,null,interop.ADODB25.ConnectModeEnum.adModeRead,interop.ADODB25.RecordCreateOptionsEnum.adFailIfNotExists,interop.ADODB25.RecordOpenOptionsEnum.adOpenSource,"","");
return iAppt;
}
catch(Exception ex)
{
Trace.WriteLine(DateTime.Now + " GetAppointment = " + ex.Message + "
StackTrace = " + ex.StackTrace);
throw ex;
}
}
--
Blair Nygren
Client Profiles Inc.


"Bart Lagerweij" wrote:

Quote:
Hi,

I want to change something to an Appointment before it is saved.
The place todo this is in the OnSyncSave event when EVT_SYNC_BEGIN flag
is set, at this point the record is not yet in the database and you can
update fields and outlook will not complain about it.
When using the OpenObject method on an appointment it fails, using the
same method on a message goes OK.
I'm using an exchange 2003/sp1 server with Exchange 2003 SDK.
Because I need to update something, I cannot "bypass" this problem by
using a stream!
Because I want to update the Attendees Property I cannot update by using
the Record object, I must use the Appointment interface.

Does anyone know why it is failing? And how to fix it?

Below is the function in C++

Other user with simular problem:
OnSyncSave with Appointment
http://groups.google.com/group/microsoft.public.exchange.development/bro
wse_frm/thread/c62f1756ef8eb0ba/e16565131ea803b3
(long link, sorry)

Regards,
Bart.

STDMETHODIMP CExEv::OnSyncSave(IExStoreEventInfo *pEventInfo, BSTR
bstrURLItem, LONG lFlags) {

CString s;
HRESULT hr= S_OK;
CComVariant varTmp;
IMessagePtr iMsg(__uuidof(Message));
IAppointmentPtr Appt(__uuidof(Appointment));
IExStoreDispEventInfoPtr pItem= pEventInfo;
_RecordPtr rs;

message(EV|2, L"OnSyncSave event bstrURLItem=%s lFlags=%lX",
bstrURLItem, lFlags);

if (lFlags & EVT_SYNC_BEGIN) {
message(EV, L"sync-begin");
hr = pItem->get_EventRecord((IDispatch**)&rs);
if (hr== S_OK) {
// Print the subject field from rs
varTmp= rs->Fields->GetItem(szSubjectField)->Value;
if (varTmp.vt!= VT_EMPTY)
s= varTmp.bstrVal;
else
s= L"";
message(EV|2, L"Subject from rs: \"%s\"", (const TCHAR
*)s);

// OpenObject by Message goes OK!
try {
hr= iMsg->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"iMsg->DataSource-
OpenObject");
}
// It prints the subject field OK!
if (hr== S_OK) {
message(EV|2, L"Subject from iMsg: \"%s\"",
(const TCHAR *)iMsg->Subject);
}

// OpenObject by Appointment fails!
// it returns error code 80070057
// meaning: The parameter is incorrect.
try {
hr= Appt->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"Appt->DataSource-
OpenObject");
}
if (hr== S_OK) {
message(EV|2, L"Subject from Appt: \"%s\"",
(const TCHAR *)Appt->Subject);
}
}
}
if (lFlags & EVT_SYNC_COMMITTED) {
message(EV, L"sync-committed");
hr= pItem->get_EventRecord((IDispatch**)&rs);
if (hr== S_OK) {
varTmp= rs->Fields->GetItem(szSubjectField)->Value;
if (varTmp.vt!= VT_EMPTY)
s= varTmp.bstrVal;
else
s= L"";
message(EV|2, L"Subject from rs: \"%s\"", (const TCHAR
*)s);

// OpenObject by Appointment fails!
try {
hr= Appt->DataSource->OpenObject(rs, L"_Record"
);
}
catch(_com_error e) {
hr= -1;
dump_com_error(e, L"Appt->DataSource-
OpenObject");
}
if (hr== S_OK) {
message(EV|2, L"Subject from Appt: \"%s\"",
(const TCHAR *)Appt->Subject);
}
}
}
return S_OK;
}

This is printed in the log file by the message() function:

[3] 12:40:33: CExEv class startup
[2] 12:40:33: OnSyncSave event
bstrURLItem=file://./backofficestorage/ad.cts-
devexch.cts/MBX/Administrator/Calendar/Testing subject!.EML lFlags=
1000041
[0] 12:40:34: sync-begin
[2] 12:40:34: Subject from rs: "Testing subject!"
[2] 12:40:34: Subject from iMsg: "Testing subject!"
[0] 12:40:34: COM-ERROR: Appt->DataSource->OpenObject!
[0] 12:40:34: Code = 80070057
[0] 12:40:34: Code meaning = The parameter is incorrect.
[0] 12:40:34: Source = CDO.Appointment.1
[0] 12:40:34: Description = The parameter is incorrect.


[2] 12:40:34: OnSyncSave event
bstrURLItem=file://./backofficestorage/ad.cts-
devexch.cts/MBX/Administrator/Calendar/Testing subject!.EML lFlags=
2000001
[0] 12:40:34: sync-committed
[2] 12:40:34: Subject from rs: "Testing subject!"
[0] 12:40:34: COM-ERROR: Appt->DataSource->OpenObject!
[0] 12:40:34: Code = 80070057
[0] 12:40:34: Code meaning = The parameter is incorrect.
[0] 12:40:34: Source = CDO.Appointment.1
[0] 12:40:34: Description = The parameter is incorrect.
Back to top
Bart Lagerweij
Guest





Posted: Mon Dec 12, 2005 5:13 pm    Post subject: RE: OpenObject fails with Appointment Reply with quote

=?Utf-8?B?QmxhaXIgTnlncmVu?= <BlairNygren@discussions.microsoft.com>
wrote in news:9CA5A9F9-F196-4134-AEBE-6311CDD54236@microsoft.com:

Yes, opening by URL works also OK with C++.
But I wanna change an item (appointment) in the "begin" phase of the
event. At this stage the item does not exist in the store yet, this is
nice because I can change properties to the item without outlook
conplaining about it and so on...

Regards,
Bart.

Quote:
Don't know if this helps. but I do the same thing but from C# and it
works fine. I don't open the object openobject but open via the URL.

see below
public interop.CDOEX.AppointmentClass GetAppointment(string bstrurl)
{
try
{ Trace.WriteLine(DateTime.Now
+ " GetAppointment: Open: " + bstrurl);
interop.CDOEX.AppointmentClass iAppt = new
interop.CDOEX.AppointmentClass();
iAppt.DataSource.Open
(bstrurl,null,interop.ADODB25.ConnectModeEnum
.adModeRead,interop.ADODB25.RecordCreateOptionsEnum.adFailIfNotEx
i
sts,interop.ADODB25.RecordOpenOptionsEnum.adOpenSource,"","");
return iAppt;
}
catch(Exception ex)
{
Trace.WriteLine(DateTime.Now + " GetAppointment = " + ex.Message
+ "
StackTrace = " + ex.StackTrace);
throw ex;
}
}


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
New Topics Powered by phpBB