In this example, the contact list is called to allow a user to select multiple contacts and initiate a single conference IM session with all of the contacts. The contact list form is myContactList in this example. The ListView control in myContactList uses tooltip functionality to display the presence notes of individual contacts. A good way to be sure that the tooltip displays properly is to move the myContactList dialog off of the top of the zOrder by setting the myContactList.TopMost property to false.

The contacts that the user selects on the myContactList dialog are returned to the calling code in the form of a property called SignInName. This property is a comma-delimited string of IMessengerContact::SigninName values. The string must be parsed and returned in an array to be usable by Office Communicator Automation API. This is done by calling parseSelectedContacts(myContactList.SignInName). The code listing for this method can be found in the code sample file OC_API_tester.cs.

Because the user can select any number of the contacts to be included in the conference, the method creates and returns contactArray, a type of ArrayList. An ArrayList does not have to be initiated with a dimension at design time but can be expanded to hold any number of objects as your code is running.

contactArray is iterated over to load sipUris, an array of object. sipUris is ultimately passed as an argument to IMessengerAdvanced::StartConversation. The following code can be found in OC_API_tester.cs.

[C#]

Copy Code
		private void startConversationButtonClick(object sender, EventArgs e)
		{

			if (myContactList != null)
				myContactList = new contactList(communicator);

			myContactList.SelectMode = true;
			myContactList.TopMost = false;
			try
			{
				myContactList.ShowDialog();
		}
			catch (Exception)
			{
				myContactList.SignInName = ""; 
		}
			if (myContactList.SignInName.Length > 0)
			{
				//load selected contacts into ArrayList.
				ArrayList contactArray = parseSelectedContacts(myContactList.SignInName);


				//dimension object array to the number of contacts selected
				object[] sipUris = new object[contactArray.Count];
				int currentObject = 0;

				//iterate over contactArray and load each individual
				//contact into object array element.
				foreach (object contactObject in contactArray)
				{
					sipUris[currentObject] = contactObject;
					currentObject ++;
			}

				long windowHandle;

				CommunicatorAPI.IMessengerAdvanced msgrAdv =
					communicator as CommunicatorAPI.IMessengerAdvanced;
				if (msgrAdv != null)
				{
					try
					{
						object obj = msgrAdv.StartConversation(
								 CONVERSATION_TYPE.CONVERSATION_TYPE_IM,
								 sipUris,
								 null,
								 "Testing",
								 "1",
								 null);
						windowHandle = long.Parse(obj.ToString());
				}
					catch (COMException ex)
					{
						writeToTextBox(formReturnErrors.returnComError(ex.ErrorCode));
				}
			}
		}
	}

See Also