Results 1 to 3 of 3

Thread: OpenObject fails with Appointment

  1. #1
    Bart Lagerweij Guest

    OpenObject fails with Appointment

    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/micro...evelopment/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.

  2. #2
    Blair Nygren Guest
    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.Record CreateOptionsEnum.adFailIfNotExists,interop.ADODB2 5.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:

    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/micro...evelopment/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.

  3. #3
    Bart Lagerweij Guest
    =?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.

    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.RecordCreateOptionsEnu m.adFailIfNotEx
    i
    sts,interop.ADODB25.RecordOpenOptionsEnum.adOpenSo urce,"","");
    return iAppt;
    }
    catch(Exception ex)
    {
    Trace.WriteLine(DateTime.Now + " GetAppointment = " + ex.Message
    + "
    StackTrace = " + ex.StackTrace);
    throw ex;
    }
    }

Similar Threads

  1. Appointment
    By letmeoutofhere in forum Administration
    Replies: 1
    Last Post: 08-18-2005, 09:58 AM
  2. NDR when sending an appointment
    By skip in forum Administration
    Replies: 10
    Last Post: 07-19-2005, 05:59 PM
  3. appointment in calendar
    By Walter in forum Clients
    Replies: 1
    Last Post: 06-29-2005, 09:59 AM
  4. OnSyncSave with Appointment
    By Chris McKay in forum Development
    Replies: 5
    Last Post: 06-19-2005, 07:42 AM
  5. can't delete appointment
    By Developa in forum Development
    Replies: 2
    Last Post: 03-28-2005, 06:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - CAD Forum