public void AddRecipient(PSTFile file, string displayName, string emailAddress, bool isOrganizer) { // http://social.msdn.microsoft.com/Forums/en-US/os_binaryfile/thread/a5f9c653-40f5-4638-85d3-00c54607d984/ // dwRowID must be > 0: uint rowID = (uint)RowCount + 1; // good enough for now int rowIndex = AddRow(rowID); SetStringProperty(rowIndex, PropertyID.PidTagDisplayName, displayName); SetStringProperty(rowIndex, PropertyID.PidTagAddressType, "SMTP"); SetStringProperty(rowIndex, PropertyID.PidTagEmailAddress, emailAddress); SetBytesProperty(rowIndex, PropertyID.PidTagSearchKey, LittleEndianConverter.GetBytes(Guid.NewGuid())); SetInt32Property(rowIndex, PropertyID.PidTagRecipientType, (int)RecipientType.To); SetInt32Property(rowIndex, PropertyID.PidTagObjectType, (int)ObjectType.MailUser); SetInt32Property(rowIndex, PropertyID.PidTagDisplayType, 0); SetStringProperty(rowIndex, PropertyID.PidTagRecipientDisplayName, displayName); int recipientFlags = (int)RecipientFlags.SendableAttendee; if (isOrganizer) { recipientFlags |= (int)RecipientFlags.MeetingOrganizer; } SetInt32Property(rowIndex, PropertyID.PidTagRecipientFlags, recipientFlags); SetInt32Property(rowIndex, PropertyID.PidTagRecipientTrackStatus, 0); byte[] recipientEntryID = RecipientEntryID.GetEntryID(displayName, emailAddress).GetBytes(); SetBytesProperty(rowIndex, PropertyID.PidTagEntryId, recipientEntryID); SetBytesProperty(rowIndex, PropertyID.PidTagRecipientEntryId, recipientEntryID); SetInt32Property(rowIndex, PropertyID.PidTagLtpRowId, (int)rowID); SetInt32Property(rowIndex, PropertyID.PidTagLtpRowVer, (int)file.Header.AllocateNextUniqueID()); }
public static RecipientEntryID GetEntryID(string displayName, string emailAddress) { RecipientEntryID entryID = new RecipientEntryID(); entryID.DisplayName = displayName; entryID.AddressType = "SMTP"; entryID.EmailAddress = emailAddress; entryID.AvoidAddressBookLookup = true; entryID.PureMime = true; entryID.UTF16 = true; return(entryID); }