/// <summary>
/// Generate property value on recipient.
/// </summary>
/// <param name="userName">Recipient user name.</param>
/// <param name="userDN">Recipient user dn.</param>
/// <returns>Property array value.</returns>
public static TaggedPropertyValue[] GenerateRecipientPropertiesBlock(string userName, string userDN)
{
TaggedPropertyValue[] recipientProperties = new TaggedPropertyValue[4];
// Add PidTagDisplayName
recipientProperties[0] = new TaggedPropertyValue();
PropertyTag pidTagDisplayNamePropertyTag = new PropertyTag
{
PropertyId = (ushort)PropertyId.PidTagDisplayName,
PropertyType = (ushort)PropertyType.PtypString
};
recipientProperties[0].PropertyTag = pidTagDisplayNamePropertyTag;
recipientProperties[0].Value = Encoding.Unicode.GetBytes(userName + "\0");
// Add PidTagEmailAddress
recipientProperties[1] = new TaggedPropertyValue();
PropertyTag pidTagEmailAddressPropertyTag = new PropertyTag
{
PropertyId = (ushort)PropertyId.PidTagEmailAddress,
PropertyType = (ushort)PropertyType.PtypString
};
recipientProperties[1].PropertyTag = pidTagEmailAddressPropertyTag;
recipientProperties[1].Value = Encoding.Unicode.GetBytes(userDN + "\0");
// Add PidTagRecipientType
recipientProperties[2] = new TaggedPropertyValue();
PropertyTag pidTagRecipientTypePropertyTag = new PropertyTag
{
PropertyId = (ushort)PropertyId.PidTagRecipientType,
PropertyType = (ushort)PropertyType.PtypInteger32
};
recipientProperties[2].PropertyTag = pidTagRecipientTypePropertyTag;
recipientProperties[2].Value = BitConverter.GetBytes(0x00000001);
AddressBookEntryID addressBookEntryID = new AddressBookEntryID(userDN);
// Add PidTagEntryID
recipientProperties[3] = new TaggedPropertyValue();
PropertyTag pidTagEntryIDPropertyTag = new PropertyTag
{
PropertyId = (ushort)PropertyId.PidTagEntryId,
PropertyType = (ushort)PropertyType.PtypBinary
};
recipientProperties[3].PropertyTag = pidTagEntryIDPropertyTag;
recipientProperties[3].Value = Common.AddInt16LengthBeforeBinaryArray(addressBookEntryID.Serialize());
return recipientProperties;
}