public static IDictionary <AddressFormatTable.AddressPart, AddressComponent> GetAddressInfo(Item item, PhysicalAddressType type) { if (item == null) { throw new ArgumentNullException("item"); } if (type != PhysicalAddressType.Business && type != PhysicalAddressType.Home && type != PhysicalAddressType.Other) { throw new ArgumentOutOfRangeException("type", "type must be Business, Home or Other"); } IDictionary <AddressFormatTable.AddressPart, AddressComponent> dictionary = new Dictionary <AddressFormatTable.AddressPart, AddressComponent>(); AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID); foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap) { PropertyDefinition propertyDefinition = AddressFormatTable.LookupAddressProperty(addressPart, type); string property = ItemUtility.GetProperty <string>(item, propertyDefinition, string.Empty); if (property.Length > 0) { AddressComponent value = ContactUtilities.ProcessAddressPartInternal(property, addressPart); dictionary[addressPart] = value; } } return(dictionary); }
public static ContactBase AddADRecipientToContacts(UserContext userContext, ADRecipient adRecipient) { if (userContext == null) { throw new ArgumentNullException("userContext"); } if (adRecipient == null) { throw new ArgumentNullException("adRecipient"); } Participant primaryParticipant = ContactUtilities.GetPrimaryParticipant(adRecipient); if (primaryParticipant == null) { return(null); } if (adRecipient is IADDistributionList) { DistributionList distributionList = DistributionList.Create(userContext.MailboxSession, userContext.ContactsFolderId); distributionList.Add(new Participant(adRecipient)); distributionList.DisplayName = (string)adRecipient[ADRecipientSchema.DisplayName]; distributionList.Save(SaveMode.ResolveConflicts); return(distributionList); } Contact contact = Contact.Create(userContext.MailboxSession, userContext.ContactsFolderId); ContactUtilities.AddContactProperties(userContext, contact, adRecipient, primaryParticipant); contact.Save(SaveMode.ResolveConflicts); return(contact); }
public static List <ContactPropertyInfo> GetAddressInfo(PhysicalAddressType type) { if (type != PhysicalAddressType.Business && type != PhysicalAddressType.Home && type != PhysicalAddressType.Other) { throw new ArgumentOutOfRangeException("type", "type must be Business, Home or Other"); } List <ContactPropertyInfo> list = new List <ContactPropertyInfo>(); AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID); foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap) { ContactPropertyInfo item = ContactUtilities.LookupAddressProperty(addressPart, type); list.Add(item); } return(list); }
public static IDictionary <AddressFormatTable.AddressPart, AddressComponent> GetAddressInfo(IADOrgPerson orgPerson) { if (orgPerson == null) { throw new ArgumentNullException("orgPerson"); } IDictionary <AddressFormatTable.AddressPart, AddressComponent> dictionary = new Dictionary <AddressFormatTable.AddressPart, AddressComponent>(); AddressFormatTable.AddressPart[] cultureAddressMap = AddressFormatTable.GetCultureAddressMap(Culture.GetUserCulture().LCID); foreach (AddressFormatTable.AddressPart addressPart in cultureAddressMap) { PropertyDefinition property = AddressFormatTable.LookupAddressPropertyAd(addressPart); string adorgPersonStringPropertyValue = ContactUtilities.GetADOrgPersonStringPropertyValue(orgPerson, property); if (!string.IsNullOrEmpty(adorgPersonStringPropertyValue)) { AddressComponent value = ContactUtilities.ProcessAddressPartInternal(adorgPersonStringPropertyValue, addressPart); dictionary[addressPart] = value; } } return(dictionary); }
public static FileAsMapping GetFileAs(Item item) { FileAsMapping fileAsMapping = FileAsMapping.None; if (item == null) { fileAsMapping = ContactUtilities.GetDefaultFileAs(); } else { object obj = item.TryGetProperty(ContactSchema.FileAsId); if (obj is int) { fileAsMapping = (FileAsMapping)obj; } if (fileAsMapping == FileAsMapping.None || !ContactUtilities.fileAsEnumToStringMap.ContainsKey(fileAsMapping)) { fileAsMapping = ContactUtilities.GetDefaultFileAs(); } } return(fileAsMapping); }
private static void AddContactProperties(UserContext userContext, Contact contact, ADRecipient adRecipient, Participant participant) { IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext); contact.JobTitle = (string)adRecipient[ADOrgPersonSchema.Title]; contact.Company = (string)adRecipient[ADOrgPersonSchema.Company]; contact.Department = (string)adRecipient[ADOrgPersonSchema.Department]; contact.OfficeLocation = (string)adRecipient[ADOrgPersonSchema.Office]; if (adRecipient[ADOrgPersonSchema.Manager] != null) { ADRecipient adrecipient = recipientSession.Read((ADObjectId)adRecipient[ADOrgPersonSchema.Manager]); if (adrecipient != null && !string.IsNullOrEmpty(adrecipient.DisplayName)) { contact[ContactSchema.Manager] = adrecipient.DisplayName; } } contact[ContactSchema.AssistantName] = (string)adRecipient[ADRecipientSchema.AssistantName]; contact.DisplayName = (string)adRecipient[ADRecipientSchema.DisplayName]; contact[ContactSchema.GivenName] = (string)adRecipient[ADOrgPersonSchema.FirstName]; contact[ContactSchema.Surname] = (string)adRecipient[ADOrgPersonSchema.LastName]; contact[ContactSchema.YomiFirstName] = (string)adRecipient[ADRecipientSchema.PhoneticFirstName]; contact[ContactSchema.YomiLastName] = (string)adRecipient[ADRecipientSchema.PhoneticLastName]; contact[ContactSchema.YomiCompany] = (string)adRecipient[ADRecipientSchema.PhoneticCompany]; contact[ContactSchema.FileAsId] = ContactUtilities.GetDefaultFileAs(); contact.EmailAddresses[EmailAddressIndex.Email1] = participant; contact[ContactSchema.PrimaryTelephoneNumber] = (string)adRecipient[ADOrgPersonSchema.Phone]; contact[ContactSchema.BusinessPhoneNumber] = (string)adRecipient[ADOrgPersonSchema.Phone]; contact[ContactSchema.HomePhone] = (string)adRecipient[ADOrgPersonSchema.HomePhone]; contact[ContactSchema.HomePhone2] = DirectoryAssistance.GetFirstResource((MultiValuedProperty <string>)adRecipient[ADOrgPersonSchema.OtherHomePhone]); contact[ContactSchema.WorkFax] = (string)adRecipient[ADOrgPersonSchema.Fax]; contact[ContactSchema.OtherFax] = DirectoryAssistance.GetFirstResource((MultiValuedProperty <string>)adRecipient[ADOrgPersonSchema.OtherFax]); contact[ContactSchema.Pager] = (string)adRecipient[ADOrgPersonSchema.Pager]; contact[ContactSchema.MobilePhone] = (string)adRecipient[ADOrgPersonSchema.MobilePhone]; contact[ContactSchema.WorkAddressStreet] = (string)adRecipient[ADOrgPersonSchema.StreetAddress]; contact[ContactSchema.WorkAddressState] = (string)adRecipient[ADOrgPersonSchema.StateOrProvince]; contact[ContactSchema.WorkAddressPostalCode] = (string)adRecipient[ADOrgPersonSchema.PostalCode]; contact[ContactSchema.WorkAddressCity] = (string)adRecipient[ADOrgPersonSchema.City]; contact[ContactSchema.WorkAddressCountry] = (string)adRecipient[ADOrgPersonSchema.Co]; }
internal static void SetContactEmailAddress(Contact contact, EmailAddressIndex emailIndex, string email, string displayName) { if (Utilities.WhiteSpaceOnlyOrNullEmpty(email)) { email = null; } if (Utilities.WhiteSpaceOnlyOrNullEmpty(displayName)) { displayName = null; } Participant copyFrom = contact.EmailAddresses[emailIndex]; string strB = null; string text = null; ContactUtilities.GetContactEmailAddress(contact, emailIndex, out strB, out text); Participant.Builder builder; if (email != null && string.CompareOrdinal(email, strB) == 0) { builder = new Participant.Builder(copyFrom); } else if (email != null) { builder = new Participant.Builder(Participant.Parse(email)); if (builder.RoutingType == null) { builder[ParticipantSchema.EmailAddressForDisplay] = email; } } else { builder = new Participant.Builder(); } builder.DisplayName = displayName; Participant value = builder.ToParticipant(); contact.EmailAddresses[emailIndex] = value; }
// Token: 0x06000B30 RID: 2864 RVA: 0x0004F208 File Offset: 0x0004D408 public static void GetItemIMInfo(OwaStoreObjectId itemId, bool getNormalizedSubject, UserContext userContext, out string displayName, out string emailAddress, out string sipUri, out string subject) { if (itemId == null) { throw new ArgumentNullException("itemId"); } if (userContext == null) { throw new ArgumentNullException("userContext"); } PropertyDefinition[] prefetchProperties = new PropertyDefinition[] { MessageItemSchema.SenderDisplayName, getNormalizedSubject ? ItemSchema.NormalizedSubject : ItemSchema.Subject, MessageItemSchema.SenderEmailAddress, MessageItemSchema.SenderAddressType }; sipUri = string.Empty; using (Item item = Utilities.GetItem <Item>(userContext, itemId, prefetchProperties)) { string text = string.Empty; object obj = item.TryGetProperty(MessageItemSchema.SenderAddressType); if (!(obj is PropertyError)) { text = (string)obj; } emailAddress = string.Empty; obj = item.TryGetProperty(MessageItemSchema.SenderEmailAddress); if (!(obj is PropertyError)) { emailAddress = (string)obj; } if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(emailAddress)) { if (string.CompareOrdinal(text, "EX") == 0) { try { IRecipientSession recipientSession = Utilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, userContext); ADRecipient adrecipient = recipientSession.FindByLegacyExchangeDN(emailAddress); if (adrecipient != null) { sipUri = InstantMessageUtilities.GetSipUri(adrecipient); } goto IL_12E; } catch (NonUniqueRecipientException ex) { ExTraceGlobals.InstantMessagingTracer.TraceDebug <string>(0L, "IntantMessageUtilities.GetItemIMInfo: NonUniqueRecipientException was thrown by User: {0}", ex.Message); goto IL_12E; } } if (string.CompareOrdinal(text, "SMTP") == 0 && emailAddress != null) { sipUri = ContactUtilities.GetContactRecipientIMAddress(emailAddress, userContext, true); } } IL_12E: subject = string.Empty; obj = item.TryGetProperty(getNormalizedSubject ? ItemSchema.NormalizedSubject : ItemSchema.Subject); if (!(obj is PropertyError)) { subject = (string)obj; } displayName = string.Empty; obj = item.TryGetProperty(MessageItemSchema.SenderDisplayName); if (!(obj is PropertyError)) { displayName = (string)obj; } } }
internal static void GetContactEmailAddress(Contact contact, EmailAddressIndex emailIndex, out string email, out string displayName) { ContactUtilities.GetContactEmailAddress(contact, emailIndex, out email, out displayName, true); }
internal static void GetContactEmailAddress(Contact contact, EmailAddressIndex emailIndex, out string email, out string displayName, bool appendRoutingType) { Participant participant = contact.EmailAddresses[emailIndex]; ContactUtilities.GetParticipantEmailAddress(participant, out email, out displayName, appendRoutingType); }
internal static void GetParticipantEmailAddress(Participant participant, out string email, out string displayName) { ContactUtilities.GetParticipantEmailAddress(participant, out email, out displayName, true); }