How to set the meeting organizer?

D

Dieter Verlaeckt

Hi, I'm developping a COM Addin (uses redemption) for Outlook 2000/XP/2003
using C++ and VS
..NET 2003.

How can I programatically set the meeting organizer of a meeting
appointment? When I create a new appointment, the current Outlook user is
automatically the meeting organizer..

TIA
Dieter
 
D

Dmitry Streblechenko

Outlook stores organizer info in a couple places:
1. the recipients table (that's what gets shown on the Scheduling tab when
you open the appointment). Organizer is a recipient with the
PR_RECIPIENT_FLAGS property == 3. If there is no such recipient (or rno
recipients at all), the current user is shown as thee organizer
2. Organizer text box on the "Appointment" tab - Outlook uses PR_SENDER_xxx
properties

You can try to set the organizer using
SafeAppointmentItem.Recipients(i).Fields(PR_RECIPIENT_FLAGS). To set the
sender, use the SentOnBehalfOfName property (you must have an explict
permission to send on behalf of that user)/

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
D

Dieter Verlaeckt

Dmitry

Thanks for replying. I have tried your suggestion but I have run into two
problems:

1) When I set PR_RECIPIENT_FLAGS to 3 for a recipient like this:

spSafeRecipient->PutFields(PR_RECIPIENT_FLAGS, _variant_t((long)3));

then the recipient is not made the organizer and OutlookSpy says that the
value of PR_RECIPIENT_FLAGS is MAPI_E_NOT_FOUND.

2) SentOnBehalfOfName does not appear to exist on appointment items? only on
mail items?

Dieter
 
D

Dieter Verlaeckt

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?
 
D

Dmitry Streblechenko

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top