// // Contact.cs // // Author: Kees van Spelde // // Copyright (c) 2013-2018 Magic-Sessions. (www.magic-sessions.com) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // using System; namespace MsgReader.Outlook { public partial class Storage { /// /// Class used to contain all the contact information /// public sealed class Contact : Storage { #region Properties /// /// Returns the full name (e.g. De heer Kees van Spelde), null when not available /// public string DisplayName { get; } /// /// Returns the prefix of the name (e.g. De heer), null when not available /// public string Prefix { get; } /// /// Returns the initials, null when not available /// public string Initials { get; } /// /// Returns the sur name (e.g. Spelde), null when not available /// public string SurName { get; } /// /// Returns the given name (e.g. Kees), null when not available /// public string GivenName { get; } /// /// Returns the generation (e.g. Jr.), null when not available /// public string Generation { get; } /// /// Returns the function, null when not available /// public string Function { get; } /// /// Returns the department, null when not available /// public string Department { get; } /// /// Returns the name of the company, null when not available /// public string Company { get; } #region Business address information /// /// Returns the named propery work (business) address (Outlook 2007 or higher), null when not available /// public string WorkAddress { get; } /// /// Returns the street of the business address, null when not available /// public string BusinessAddressStreet { get; } /// /// Returns the city of the business address, null when not available /// public string BusinessAddressCity { get; } /// /// Returns the state of the business address, null when not available /// public string BusinessAddressState { get; } /// /// Returns the postal code of the business address, null when not available /// public string BusinessAddressPostalCode { get; } /// /// Returns the country of the business address, null when not available /// public string BusinessAddressCountry { get; } /// /// Returns the business telephone number, null when not available /// public string BusinessTelephoneNumber { get; } /// /// Returns the business second telephone number, null when not available /// public string BusinessTelephoneNumber2 { get; } /// /// Returns the business fax number, null when not available /// public string BusinessFaxNumber { get; } /// /// Returns the business home page, null when not available /// public string BusinessHomePage { get; } #endregion #region Home address information /// /// Returns the named propery home address (Outlook 2007 or higher) /// public string HomeAddress { get; } /// /// Returns the street of the home address, null when not available /// public string HomeAddressStreet { get; } /// /// Returns the city of the home address, null when not available /// public string HomeAddressCity { get; } /// /// Returns the state of the home address, null when not available /// public string HomeAddressState { get; } /// /// Returns the postal code of the home address, null when not available /// public string HomeAddressPostalCode { get; } /// /// Returns the country of the home address, null when not available /// public string HomeAddressCountry { get; } /// /// Returns the home telephone number, null when not available /// public string HomeTelephoneNumber { get; } /// /// Returns the home second telephone number, null when not available /// public string HomeTelephoneNumber2 { get; } /// /// Returns the home fax number, null when not available /// public string HomeFaxNumber { get; } #endregion #region Other address information /// /// Returns the named propery other address (Outlook 2007 or higher) /// public string OtherAddress { get; } /// /// Returns the street of the other address, null when not available /// public string OtherAddressStreet { get; } /// /// Returns the city of the other address, null when not available /// public string OtherAddressCity { get; } /// /// Returns the state of the other address, null when not available /// public string OtherAddressState { get; } /// /// Returns the postal code of the other address, null when not available /// public string OtherAddressPostalCode { get; } /// /// Returns the country of the other address, null when not available /// public string OtherAddressCountry { get; } /// /// Returns the other telephone number, null when not available /// public string OtherTelephoneNumber { get; } #endregion #region Primary information /// /// Returns the primary telephone number, null when not available /// public string PrimaryTelephoneNumber { get; } /// /// Returns the primary fax number, null when not available /// public string PrimaryFaxNumber { get; } #endregion #region Assistant information /// /// Returns the name of the assistant, null when not available /// public string AssistantName { get; } /// /// Returns the telephone number of the assistant, null when not available /// public string AssistantTelephoneNumber { get; } #endregion /// /// Return the instant messaging address, null when not available /// public string InstantMessagingAddress { get; } #region Telephone numbers /// /// Returns the company main telephone number, null when not available /// public string CompanyMainTelephoneNumber { get; } /// /// Returns the cellular telephone number, null when not available /// public string CellularTelephoneNumber { get; } /// /// Returns the car telephone number, null when not available /// public string CarTelephoneNumber { get; } /// /// Returns the radio telephone number, null when not available /// public string RadioTelephoneNumber { get; } /// /// Returns the beeper telephone number, null when not available /// public string BeeperTelephoneNumber { get; } /// /// Returns the callback telephone number, null when not available /// public string CallbackTelephoneNumber { get; } /// /// Returns the telex number, null when not available /// public string TelexNumber { get; } /// /// Returns the text telephone (TTYTDD), null when not available /// public string TextTelephone { get; } /// /// Returns the ISDN number, null when not available /// // ReSharper disable once InconsistentNaming public string ISDNNumber { get; } #endregion #region E-mail information /// /// Returns the name property e-mail address 1 (Outlook 2007 or higher), null when not available /// public string Email1EmailAddress { get; } /// /// Returns the name property e-mail displayname 1 (Outlook 2007 or higher), null when not available /// public string Email1DisplayName { get; } /// /// Returns the name property e-mail address 2 (Outlook 2007 or higher), null when not available /// public string Email2EmailAddress { get; } /// /// Returns the name property e-mail displayname 2 (Outlook 2007 or higher), null when not available /// public string Email2DisplayName { get; } /// /// Returns the name property e-mail address 3 (Outlook 2007 or higher), null when not available /// public string Email3EmailAddress { get; } /// /// Returns the name property e-mail displayname 3 (Outlook 2007 or higher), null when not available /// public string Email3DisplayName { get; } #endregion /// /// Returns the birthday, null when not available /// public DateTime? Birthday { get; } /// /// Returns the wedding/anniversary, null when not available /// public DateTime? WeddingAnniversary { get; } /// /// Returns the name of the spouse, null when not available /// public string SpouseName { get; } /// /// Returns the profession, null when not available /// public string Profession { get; } /// /// Returns the homepage (html), null when not available /// public string Html { get; } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The message. internal Contact(Storage message) : base(message._rootStorage) { GC.SuppressFinalize(message); _namedProperties = message._namedProperties; _propHeaderSize = MapiTags.PropertiesStreamHeaderTop; DisplayName = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME); Prefix = GetMapiPropertyString(MapiTags.PR_DISPLAY_NAME_PREFIX); Initials = GetMapiPropertyString(MapiTags.PR_INITIALS); SurName = GetMapiPropertyString(MapiTags.PR_SURNAME); GivenName = GetMapiPropertyString(MapiTags.PR_GIVEN_NAME); Generation = GetMapiPropertyString(MapiTags.PR_GENERATION); Function = GetMapiPropertyString(MapiTags.PR_TITLE); Department = GetMapiPropertyString(MapiTags.PR_DEPARTMENT_NAME); Company = GetMapiPropertyString(MapiTags.PR_COMPANY_NAME); #region Business address information WorkAddress = GetMapiPropertyString(MapiTags.WorkAddress); BusinessAddressStreet = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_STREET); BusinessAddressCity = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_CITY); BusinessAddressState = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_STATE_OR_PROVINCE); BusinessAddressPostalCode = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_POSTAL_CODE); BusinessAddressCountry = GetMapiPropertyString(MapiTags.PR_BUSINESS_ADDRESS_COUNTRY); BusinessTelephoneNumber = GetMapiPropertyString(MapiTags.PR_BUSINESS_TELEPHONE_NUMBER); BusinessTelephoneNumber2 = GetMapiPropertyString(MapiTags.PR_BUSINESS2_TELEPHONE_NUMBER); BusinessFaxNumber = GetMapiPropertyString(MapiTags.PR_BUSINESS_FAX_NUMBER); BusinessHomePage = GetMapiPropertyString(MapiTags.PR_BUSINESS_HOME_PAGE); // WorkAddress is only filled when the msg object is made with Outlook 2007 or higher. // So we fill it from code. if (string.IsNullOrEmpty(WorkAddress)) { var workAddress = string.Empty; if (!string.IsNullOrEmpty(BusinessAddressStreet)) workAddress += BusinessAddressStreet + Environment.NewLine; if (!string.IsNullOrEmpty(BusinessAddressPostalCode)) workAddress += BusinessAddressPostalCode + Environment.NewLine; if (!string.IsNullOrEmpty(BusinessAddressCity)) workAddress += BusinessAddressCity + Environment.NewLine; if (!string.IsNullOrEmpty(BusinessAddressCountry)) workAddress += BusinessAddressCountry + Environment.NewLine; if (!string.IsNullOrEmpty(workAddress)) WorkAddress = workAddress; } #endregion #region Home address information HomeAddress = GetMapiPropertyString(MapiTags.HomeAddress); HomeAddressStreet = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_STREET); HomeAddressCity = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_CITY); HomeAddressState = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_STATE_OR_PROVINCE); HomeAddressPostalCode = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_POSTAL_CODE); HomeAddressCountry = GetMapiPropertyString(MapiTags.PR_HOME_ADDRESS_COUNTRY); HomeTelephoneNumber = GetMapiPropertyString(MapiTags.PR_HOME_TELEPHONE_NUMBER); HomeTelephoneNumber2 = GetMapiPropertyString(MapiTags.PR_HOME2_TELEPHONE_NUMBER); HomeFaxNumber = GetMapiPropertyString(MapiTags.PR_HOME_FAX_NUMBER); // HomeAddress is only filled when the msg object is made with Outlook 2007 or higher. // So we fill it from code. if (string.IsNullOrEmpty(HomeAddress)) { var homeAddress = string.Empty; if (!string.IsNullOrEmpty(HomeAddressStreet)) homeAddress += HomeAddressStreet + Environment.NewLine; if (!string.IsNullOrEmpty(HomeAddressPostalCode)) homeAddress += HomeAddressPostalCode + Environment.NewLine; if (!string.IsNullOrEmpty(HomeAddressCity)) homeAddress += HomeAddressCity + Environment.NewLine; if (!string.IsNullOrEmpty(HomeAddressCountry)) homeAddress += HomeAddressCountry + Environment.NewLine; if (!string.IsNullOrEmpty(homeAddress)) HomeAddress = homeAddress; } #endregion #region Other address information OtherAddress = GetMapiPropertyString(MapiTags.OtherAddress); OtherAddressStreet = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_STREET); OtherAddressCity = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_CITY); OtherAddressState = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_STATE_OR_PROVINCE); OtherAddressPostalCode = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_POSTAL_CODE); OtherAddressCountry = GetMapiPropertyString(MapiTags.PR_OTHER_ADDRESS_COUNTRY); OtherTelephoneNumber = GetMapiPropertyString(MapiTags.PR_OTHER_TELEPHONE_NUMBER); // OtherAddress is only filled when the msg object is made with Outlook 2007 or higher. // So we fill it from code. if (string.IsNullOrEmpty(OtherAddress)) { var otherAddress = string.Empty; if (!string.IsNullOrEmpty(OtherAddressStreet)) otherAddress += OtherAddressStreet + Environment.NewLine; if (!string.IsNullOrEmpty(OtherAddressPostalCode)) otherAddress += OtherAddressPostalCode + Environment.NewLine; if (!string.IsNullOrEmpty(OtherAddressCity)) otherAddress += OtherAddressCity + Environment.NewLine; if (!string.IsNullOrEmpty(OtherAddressCountry)) otherAddress += OtherAddressCountry + Environment.NewLine; if (!string.IsNullOrEmpty(otherAddress)) OtherAddress = otherAddress; } #endregion #region Primary information PrimaryTelephoneNumber = GetMapiPropertyString(MapiTags.PR_PRIMARY_TELEPHONE_NUMBER); PrimaryFaxNumber = GetMapiPropertyString(MapiTags.PR_PRIMARY_FAX_NUMBER); #endregion #region Assistant information AssistantName = GetMapiPropertyString(MapiTags.PR_ASSISTANT); AssistantTelephoneNumber = GetMapiPropertyString(MapiTags.PR_ASSISTANT_TELEPHONE_NUMBER); #endregion InstantMessagingAddress = GetMapiPropertyString(MapiTags.InstantMessagingAddress); #region Telephone numbers CompanyMainTelephoneNumber = GetMapiPropertyString(MapiTags.PR_COMPANY_MAIN_PHONE_NUMBER); CellularTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CELLULAR_TELEPHONE_NUMBER); CarTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CAR_TELEPHONE_NUMBER); RadioTelephoneNumber = GetMapiPropertyString(MapiTags.PR_RADIO_TELEPHONE_NUMBER); BeeperTelephoneNumber = GetMapiPropertyString(MapiTags.PR_BEEPER_TELEPHONE_NUMBER); CallbackTelephoneNumber = GetMapiPropertyString(MapiTags.PR_CALLBACK_TELEPHONE_NUMBER); TextTelephone = GetMapiPropertyString(MapiTags.PR_TELEX_NUMBER); ISDNNumber = GetMapiPropertyString(MapiTags.PR_ISDN_NUMBER); TelexNumber = GetMapiPropertyString(MapiTags.PR_TELEX_NUMBER); #endregion #region E-mail information Email1EmailAddress = GetMapiPropertyString(MapiTags.Email1EmailAddress); Email1DisplayName = GetMapiPropertyString(MapiTags.Email1DisplayName); Email2EmailAddress = GetMapiPropertyString(MapiTags.Email2EmailAddress); Email2DisplayName = GetMapiPropertyString(MapiTags.Email2DisplayName); Email3EmailAddress = GetMapiPropertyString(MapiTags.Email3EmailAddress); Email3DisplayName = GetMapiPropertyString(MapiTags.Email3DisplayName); #endregion var birthday = GetMapiPropertyDateTime(MapiTags.PR_BIRTHDAY); if (birthday != null) Birthday = ((DateTime) birthday).ToLocalTime(); var weddingAnniversary = GetMapiPropertyDateTime(MapiTags.PR_WEDDING_ANNIVERSARY); if (weddingAnniversary != null) WeddingAnniversary = ((DateTime) weddingAnniversary).ToLocalTime(); SpouseName = GetMapiPropertyString(MapiTags.PR_SPOUSE_NAME); Profession = GetMapiPropertyString(MapiTags.PR_PROFESSION); Html = GetMapiPropertyString(MapiTags.Html); } #endregion } } }