Поделиться через


EWS: BillingInformation is available only to TaskType

If you have ever tried to update BillingInformation of any item, other than tasks, using EWS then you may already know that BillingInformation is missing from Exchange Web Services object model and available only to TaskType. Although if you check the Outlook 2007 object model, it is available for MailItem, TaskItem, AppointmentItem, and to many others.

It may be a bug or a design decision made by product group, I am still researching and trying to find out the answer behind this. But you may not want to wait that long and still want to update your BillingInformation using EWS.

I have written the following sample code to update BillingInformation using EWS. I am using ExtendedProperty to update this named property

CODE:

//get the calendar folder ID

DistinguishedFolderIdType[] dfita = new DistinguishedFolderIdType[1];

dfita[0] = new DistinguishedFolderIdType();

dfita[0].Id = DistinguishedFolderIdNameType.calendar;

TargetFolderIdType tfidt = new TargetFolderIdType();

tfidt.Item = dfita[0];

//create the appt

BodyType bt = new BodyType();

bt.BodyType1 = BodyTypeType.Text;

bt.Value = "This is the appointment Body";

CalendarItemType[] calita = new CalendarItemType[1];

calita[0] = new CalendarItemType();

calita[0].ExtendedProperty = new ExtendedPropertyType[1];

calita[0].ExtendedProperty[0] = new ExtendedPropertyType();

calita[0].ExtendedProperty[0].ExtendedFieldURI = new PathToExtendedFieldType();

calita[0].ExtendedProperty[0].ExtendedFieldURI.DistinguishedPropertySetId = DistinguishedPropertySetType.Common;

calita[0].ExtendedProperty[0].ExtendedFieldURI.DistinguishedPropertySetIdSpecified = true;

//NOTE: This PropertyID is equal to PropertyTag "0x8535" but you have to use PropertyID any not PropertyTag otherwise it will NOT work as expected and this billinginformation will not be visible via OOM or WebDAV, you have to specify it as Integer value in PropertyID field

calita[0].ExtendedProperty[0].ExtendedFieldURI.PropertyId = 34101;

calita[0].ExtendedProperty[0].ExtendedFieldURI.PropertyIdSpecified = true;

calita[0].ExtendedProperty[0].ExtendedFieldURI.PropertyType = MapiPropertyTypeType.String;

calita[0].ExtendedProperty[0].Item = "Billing Information Here";

calita[0].Subject = txtSubject.Text;

calita[0].Body = bt;

calita[0].IsAllDayEvent = false;

calita[0].Location = "Let's meet here";

calita[0].ReminderIsSet = true;

calita[0].ReminderMinutesBeforeStart = "60";

calita[0].LegacyFreeBusyStatus = LegacyFreeBusyType.Busy;

calita[0].Start = DateTime.Parse("15 October 2007");

calita[0].StartSpecified = true;

calita[0].End = DateTime.Parse("16 October 2007");

calita[0].EndSpecified = true;

NonEmptyArrayOfAllItemsType neaoait = new NonEmptyArrayOfAllItemsType();

neaoait.Items = calita;

CreateItemType cit = new CreateItemType();

cit.SavedItemFolderId = tfidt;

cit.SendMeetingInvitations =

CalendarItemCreateOrDeleteOperationType.SendToNone;

cit.SendMeetingInvitationsSpecified = true;

cit.Items = neaoait;

CreateItemResponseType cirt = esb.CreateItem(cit);

…I will update this blog as soon as will get the answer to "Why BillingInformation is available only to TaskType?"

 

Keywords: Exchange Web Services, Exchange 2007, BillingInformation not available for MessageType, TaskType

Comments

  • Anonymous
    September 02, 2008
    This creates the "User-defined fields in folder" field fine when I put this in my app.  But how do you set the value of that field?