Below is the simplified relevant code that gets executed in my problem case
(a meeting appointment with organizer different from the current Outlook
user).
note: m_cXmlResponse is an XML document containing information about
appointments, my addin recreates appointments in Outlook based on this
information.
*** BEGIN CODE ***
// create an appointment in a calendar folder in Outlook
_AppointmentItemPtr spAppointment = NULL;.
_ItemsPtr spItems = m_spCalendarFolder->GetItems();
spAppointment = spItems->Add(_variant_t((long)olAppointmentItem));
// create a safe appointment for the appointment.
ISafeAppointmentItemPtr spSafeAppointment;
HRESULT hr =
spSafeAppointment.CreateInstance(_T("SafeOutlook.SoAppointmentItem"));
spSafeAppointment->PutAuthKey(_bstr_t((LPCTSTR)REDEMPTION_AUTH_KEY));
spSafeAppointment->PutItem(spAppointment);
// set some properties of the appointment.
spAppointment->PutSensitivity((OlSensitivity)m_cXmlResponse.GetInt(TAG_SENSITIVITY));
spAppointment->PutReminderMinutesBeforeStart(m_cXmlResponse.GetLong(TAG_REMINDER_MINUTES_BEFORE_START));
spAppointment->PutReminderSet(m_cXmlResponse.GetBool(TAG_REMINDER_SET));
spAppointment->PutUnRead(m_cXmlResponse.GetBool(TAG_UNREAD));
spAppointment->PutBillingInformation(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_BILLING_INFORMATION)));
spSafeAppointment->PutBody(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_BODY)));
spAppointment->PutCategories(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_CATEGORIES)));
spAppointment->PutCompanies(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_COMPANIES)));
spAppointment->PutImportance((OlImportance)m_cXmlResponse.GetInt(TAG_IMPORTANCE));
spAppointment->PutLocation(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_LOCATION)));
spAppointment->PutMileage(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_MILEAGE)));
spAppointment->PutSubject(_bstr_t((LPCTSTR)m_cXmlResponse.GetString(TAG_SUBJECT)));
// handle meeting information.
OlMeetingStatus MeetingStatus;
ISafeRecipientsPtr spSafeRecipients = NULL;
ISafeRecipientPtr spSafeRecipient = NULL;
IAddressEntryPtr spSafeAddressEntry = NULL;
CString csName, csAddress, csNameAddress;
BOOL bIsOrganizer = FALSE;
MeetingStatus = (OlMeetingStatus)m_cXmlResponse.GetInt(TAG_MEETING_STATUS,
olNonMeeting);
spAppointment->PutMeetingStatus(MeetingStatus);
if (MeetingStatus != olNonMeeting)
{
spAppointment->PutIsOnlineMeeting(m_cXmlResponse.GetBool(TAG_IS_ONLINE_MEETING));
spAppointment->PutResponseRequested(m_cXmlResponse.GetBool(TAG_RESPONSE_REQUESTED));
spSafeRecipients = spSafeAppointment->GetRecipients();
// remove the existing recipients from the meeting appointment.
long nMemberCount = spSafeRecipients->GetCount();
for (int i = nMemberCount; i > 0; --i)
spSafeRecipients->Remove(i);
// read the meeting appointment's recipients.
if (m_cXmlResponse.SelectChild(TAG_RECIPIENTS))
{
m_cXmlResponse.SelectChildren(TAG_ITEM);
// get the next recipient from the XML document.
while (m_cXmlResponse.NextSelectedChild())
{
// read the recipient's name and adress.
csName = m_cXmlResponse.GetString(TAG_NAME);
csAddress = m_cXmlResponse.GetString(TAG_ADDRESS);
csNameAddress = csName + _T(" (") + csAddress + _T(")");
// check if the recipient is the meeting organizer.
bIsOrganizer = m_cXmlResponse.GetBool(TAG_IS_ORGANIZER);
spSafeRecipient =
spSafeRecipients->Add(_bstr_t((LPCTSTR)csNameAddress));
spSafeRecipient->Resolve(FALSE);
spSafeRecipient->PutType(m_cXmlResponse.GetInt(TAG_TYPE));
spSafeRecipient->PutFields(PR_RECIPIENT_FLAGS, bIsOrganizer ?
_variant_t((long)3) : _variant_t((long)1));
spSafeRecipient->PutFields(PR_RECIPIENT_TRACKSTATUS,
_variant_t((long)m_cXmlResponse.GetInt(TAG_TRACKING_STATUS)));
spSafeRecipient->PutFields(PR_RECIPIENT_TRACKSTATUS_TIME,
_variant_t(m_cXmlResponse.GetDateTime(TAG_TRACKING_STATUS_TIME)));
}
m_cXmlResponse.SelectParent();
}
m_cXmlResponse.SelectParent();
}
// add scheduling properties of the appointment.
spAppointment->PutStart(m_cXmlResponse.GetDateTime(TAG_START));
spAppointment->PutEnd(m_cXmlResponse.GetDateTime(TAG_END));
spAppointment->PutAllDayEvent(m_cXmlResponse.GetBool(TAG_ALL_DAY_EVENT));
spAppointment->PutBusyStatus((OlBusyStatus)m_cXmlResponse.GetInt(TAG_BUSY_STATUS));}
// save the appointment.
spAppointment->Save();
*** END CODE ***
Any ideas to what I might be doing wrong?
> Do you save the appointment afterwards? What is the rest of your code?
>
[quoted text clipped - 48 lines]
>>>> TIA
>>>> Dieter
Dmitry Streblechenko - 31 Oct 2005 19:18 GMT
But all thee other recipient props ((PR_RECIPIENT_TRACKSTATUS etc) get set
Ok, right?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Below is the simplified relevant code that gets executed in my problem
> case (a meeting appointment with organizer different from the current
[quoted text clipped - 161 lines]
>>>>> TIA
>>>>> Dieter