public static void Run()
        {
            // ExStart:RenderingContactInformationToMhtml
            string dataDir = RunExamples.GetDataDir_Outlook();

            //Load VCF Contact and convert to MailMessage for rendering to MHTML
            MapiContact contact = MapiContact.FromVCard(dataDir + "Contact.vcf");

            MemoryStream ms = new MemoryStream();

            contact.Save(ms, ContactSaveFormat.Msg);
            ms.Position = 0;
            MapiMessage           msg = MapiMessage.FromStream(ms);
            MailConversionOptions op  = new MailConversionOptions();
            MailMessage           eml = msg.ToMailMessage(op);

            //Prepare the MHT format options
            MhtSaveOptions mhtSaveOptions = new MhtSaveOptions();

            mhtSaveOptions.CheckBodyContentEncoding   = true;
            mhtSaveOptions.PreserveOriginalBoundaries = true;
            MhtFormatOptions formatOp = MhtFormatOptions.WriteHeader | MhtFormatOptions.RenderVCardInfo;

            mhtSaveOptions.RenderedContactFields = ContactFieldsSet.NameInfo | ContactFieldsSet.PersonalInfo | ContactFieldsSet.Telephones | ContactFieldsSet.Events;
            mhtSaveOptions.MhtFormatOptions      = formatOp;
            eml.Save(dataDir + "ContactMhtml_out.mhtml", mhtSaveOptions);
            // ExEnd:RenderingContactInformationToMhtml
        }
예제 #2
0
        public static void Run()
        {
            // ExStart:AccessContactInformation
            // Load the Outlook file
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook PST file
            PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir + "SampleContacts.pst");
            // Get the Contacts folder
            FolderInfo folderInfo = personalStorage.RootFolder.GetSubFolder("Contacts");
            // Loop through all the contacts in this folder
            MessageInfoCollection messageInfoCollection = folderInfo.GetContents();

            foreach (MessageInfo messageInfo in messageInfoCollection)
            {
                // Get the contact information
                MapiMessage mapi = personalStorage.ExtractMessage(messageInfo);

                MapiContact contact = (MapiContact)mapi.ToMapiMessageItem();

                // Display some contents on screen
                Console.WriteLine("Name: " + contact.NameInfo.DisplayName);
                // Save to disk in MSG format
                if (contact.NameInfo.DisplayName != null)
                {
                    MapiMessage message = personalStorage.ExtractMessage(messageInfo);
                    // Get rid of illegal characters that cannot be used as a file name
                    string messageName = message.Subject.Replace(":", " ").Replace("\\", " ").Replace("?", " ").Replace("/", " ");
                    message.Save(dataDir + "Contacts\\" + messageName + "_out.msg");
                }
            }
            // ExEnd:AccessContactInformation
        }
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:CreateNewMapiContactAndAddToContactsSubfolder
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create three Contacts 
            MapiContact contact1 = new MapiContact("Sebastian Wright", "*****@*****.**");
            MapiContact contact2 = new MapiContact("Wichert Kroos", "*****@*****.**", "Grade A Investment");
            MapiContact contact3 = new MapiContact("Christoffer van de Meeberg", "*****@*****.**", "Krauses Sofa Factory", "046-630-4614046-630-4614");

            // Contact #4
            MapiContact contact4 = new MapiContact();
            contact4.NameInfo = new MapiContactNamePropertySet("Margaret", "J.", "Tolle");
            contact4.PersonalInfo.Gender = MapiContactGender.Female;
            contact4.ProfessionalInfo = new MapiContactProfessionalPropertySet("Adaptaz", "Recording engineer");
            contact4.PhysicalAddresses.WorkAddress.Address = "4 Darwinia Loop EIGHTY MILE BEACH WA 6725";
            contact4.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("Hisen1988", "SMTP", "*****@*****.**");
            contact4.Telephones.BusinessTelephoneNumber = "(08)9080-1183";
            contact4.Telephones.MobileTelephoneNumber = "(925)599-3355(925)599-3355";

            // Contact #5
            MapiContact contact5 = new MapiContact();
            contact5.NameInfo = new MapiContactNamePropertySet("Matthew", "R.", "Wilcox");
            contact5.PersonalInfo.Gender = MapiContactGender.Male;
            contact5.ProfessionalInfo = new MapiContactProfessionalPropertySet("Briazz", "Psychiatric aide");
            contact5.PhysicalAddresses.WorkAddress.Address = "Horner Strasse 12 4421 SAASS";
            contact5.Telephones.BusinessTelephoneNumber = "0650 675 73 300650 675 73 30";
            contact5.Telephones.HomeTelephoneNumber = "(661)387-5382(661)387-5382";

            // Contact #6
            MapiContact contact6 = new MapiContact();
            contact6.NameInfo = new MapiContactNamePropertySet("Bertha", "A.", "Buell");
            contact6.ProfessionalInfo = new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant");
            contact6.PersonalInfo.PersonalHomePage = "B2BTies.com";
            contact6.PhysicalAddresses.WorkAddress.Address = "Im Astenfeld 59 8580 EDELSCHROTT";
            contact6.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("Experwas", "SMTP", "*****@*****.**");
            contact6.Telephones = new MapiContactTelephonePropertySet("06605045265");

            // Load the Outlook file
            string path = dataDir + "SampleContacts_out.pst";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (PersonalStorage personalStorage = PersonalStorage.Create(dataDir + "SampleContacts_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo contactFolder = personalStorage.CreatePredefinedFolder("Contacts", StandardIpmFolder.Contacts);
                contactFolder.AddMapiMessageItem(contact1);
                contactFolder.AddMapiMessageItem(contact2);
                contactFolder.AddMapiMessageItem(contact3);
                contactFolder.AddMapiMessageItem(contact4);
                contactFolder.AddMapiMessageItem(contact5);
                contactFolder.AddMapiMessageItem(contact6);
            }
            // ExEnd:CreateNewMapiContactAndAddToContactsSubfolder
        }
예제 #4
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:LoadingContactFromVCardWithSpecifiedEncoding
            var contactReadFromFile = MapiContact.FromVCard(dataDir + @"Contact.vcf", Encoding.UTF8);
            // ExEnd:LoadingContactFromVCardWithSpecifiedEncoding
        }
예제 #5
0
        static void Main(string[] args)
        {
            var vcfTest = VCardContact.Load(@"E:\Aspose\Aspose Vs VSTO\Aspose.Emails Vs VSTO Outlook v 1.1\Sample Files\Jon.vcf");

            MapiContact contact = MapiContact.FromVCard(@"E:\Aspose\Aspose Vs VSTO\Aspose.Emails Vs VSTO Outlook v 1.1\Sample Files\Jon.vcf");

            Console.WriteLine(contact.NameInfo.DisplayName);
        }
예제 #6
0
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:LoadingContactFromMSG
            MapiMessage msg         = MapiMessage.FromFile(dataDir + "Contact.msg");
            MapiContact mapiContact = (MapiContact)msg.ToMapiMessageItem();
            // ExEnd:LoadingContactFromMSG
        }
        public static void Run()
        {
            string dataDir = RunExamples.GetDataDir_Outlook();

            // ExStart:LoadingContactFromVCard
            var         vcfTest = VCardContact.Load(dataDir + "Contact.vcf");
            MapiContact contact = MapiContact.FromVCard(dataDir + "Contact.vcf");
            // ExEnd:LoadingContactFromVCard
        }
예제 #8
0
        public static void Run()
        {
            // ExStart:CreateAndSaveOutlookContact
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiContact contact = new MapiContact();

            contact.NameInfo         = new MapiContactNamePropertySet("Bertha", "A.", "Buell");
            contact.ProfessionalInfo = new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant");
            contact.PersonalInfo.PersonalHomePage         = "B2BTies.com";
            contact.PhysicalAddresses.WorkAddress.Address = "Im Astenfeld 59 8580 EDELSCHROTT";
            contact.ElectronicAddresses.Email1            = new MapiContactElectronicAddress("Experwas", "SMTP", "*****@*****.**");
            contact.Telephones            = new MapiContactTelephonePropertySet("06605045265");
            contact.PersonalInfo.Children = new string[] { "child1", "child2", "child3" };
            contact.Categories            = new string[] { "category1", "category2", "category3" };
            contact.Mileage                   = "Some test mileage";
            contact.Billing                   = "Test billing information";
            contact.OtherFields.Journal       = true;
            contact.OtherFields.Private       = true;
            contact.OtherFields.ReminderTime  = new DateTime(2014, 1, 1, 0, 0, 55);
            contact.OtherFields.ReminderTopic = "Test topic";
            contact.OtherFields.UserField1    = "ContactUserField1";
            contact.OtherFields.UserField2    = "ContactUserField2";
            contact.OtherFields.UserField3    = "ContactUserField3";
            contact.OtherFields.UserField4    = "ContactUserField4";

            // Add a photo
            using (FileStream fs = File.OpenRead(dataDir + "Desert.jpg"))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                contact.Photo = new MapiContactPhoto(buffer,
                                                     MapiContactPhotoImageFormat.Jpeg);
            }
            // Save the Contact in MSG format
            contact.Save(dataDir + "MapiContact_out.msg", ContactSaveFormat.Msg);

            // Save the Contact in VCF format
            contact.Save(dataDir + "MapiContact_out.vcf", ContactSaveFormat.VCard);
            // ExEnd:CreateAndSaveOutlookContact
        }
        public static void Run()
        {
            // ExStart:CreateAndSaveOutlookContact
            // The path to the File directory.
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiContact contact = new MapiContact();
            contact.NameInfo = new MapiContactNamePropertySet("Bertha", "A.", "Buell");
            contact.ProfessionalInfo = new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant");
            contact.PersonalInfo.PersonalHomePage = "B2BTies.com";
            contact.PhysicalAddresses.WorkAddress.Address = "Im Astenfeld 59 8580 EDELSCHROTT";
            contact.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("Experwas", "SMTP", "*****@*****.**");
            contact.Telephones = new MapiContactTelephonePropertySet("06605045265");
            contact.PersonalInfo.Children = new string[] { "child1", "child2", "child3" };
            contact.Categories = new string[] { "category1", "category2", "category3" };
            contact.Mileage = "Some test mileage";
            contact.Billing = "Test billing information";
            contact.OtherFields.Journal = true;
            contact.OtherFields.Private = true;
            contact.OtherFields.ReminderTime = new DateTime(2014, 1, 1, 0, 0, 55);
            contact.OtherFields.ReminderTopic = "Test topic";
            contact.OtherFields.UserField1 = "ContactUserField1";
            contact.OtherFields.UserField2 = "ContactUserField2";
            contact.OtherFields.UserField3 = "ContactUserField3";
            contact.OtherFields.UserField4 = "ContactUserField4";

            // Add a photo
            using (FileStream fs = File.OpenRead(dataDir + "Desert.jpg"))
            {
                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);
                contact.Photo = new MapiContactPhoto(buffer,
                    MapiContactPhotoImageFormat.Jpeg);
            }
            // Save the Contact in MSG format
            contact.Save(dataDir + "MapiContact_out.msg",ContactSaveFormat.Msg);

            // Save the Contact in VCF format
            contact.Save(dataDir + "MapiContact_out.vcf", ContactSaveFormat.VCard);
            // ExEnd:CreateAndSaveOutlookContact
        }
예제 #10
0
        public static void Run()
        {
            // ExStart:1
            // Outlook directory
            string dataDir = RunExamples.GetDataDir_Outlook();

            MapiContact contact = new MapiContact();

            contact.NameInfo         = new MapiContactNamePropertySet("Jane", "A.", "Buell");
            contact.ProfessionalInfo = new MapiContactProfessionalPropertySet("Aspose Pty Ltd", "Social work assistant");
            contact.PersonalInfo.PersonalHomePage  = "Aspose.com";
            contact.ElectronicAddresses.Email1     = new MapiContactElectronicAddress("*****@*****.**");
            contact.Telephones.HomeTelephoneNumber = "06605040000";

            VCardSaveOptions opt = new VCardSaveOptions();

            opt.Version = VCardVersion.V30;
            contact.Save(dataDir + "V30.vcf", opt);
            // ExEnd:1

            Console.WriteLine("CreateV30Contact executed successfully.");
        }
예제 #11
0
        static void Main(string[] args)
        {
            //Create a new MapiContact Object
            MapiContact mapiContact = new MapiContact();

            //Set different properties of this Contact object
            mapiContact.NameInfo = new MapiContactNamePropertySet("Mellissa", "", "MacBeth");
            mapiContact.ProfessionalInfo.Title                        = "Account Representative";
            mapiContact.ProfessionalInfo.CompanyName                  = "Contoso Ltd.";
            mapiContact.ProfessionalInfo.OfficeLocation               = "36/2529";
            mapiContact.Telephones.BusinessTelephoneNumber            = "4255551212 x432";
            mapiContact.PhysicalAddresses.WorkAddress.Street          = "1 Microsoft Way";
            mapiContact.PhysicalAddresses.WorkAddress.City            = "Redmond";
            mapiContact.PhysicalAddresses.WorkAddress.StateOrProvince = "WA";
            mapiContact.PhysicalAddresses.WorkAddress.PostalCode      = "98052";
            mapiContact.PhysicalAddresses.WorkAddress.Country         = "United States of America";
            mapiContact.ElectronicAddresses.Email1.EmailAddress       = "*****@*****.**";
            mapiContact.ElectronicAddresses.Email1.AddressType        = "SMTP";
            mapiContact.ElectronicAddresses.Email1.DisplayName        = "Melissa MacBeth ([email protected])";

            //Save the Contact object to disc
            mapiContact.Save("Contact.vcf", ContactSaveFormat.VCard);
        }
예제 #12
0
        static void Main(string[] args)
        {
            //Create a new MapiContact Object
            MapiContact mapiContact = new MapiContact();

            //Set different properties of this Contact object
            mapiContact.NameInfo = new MapiContactNamePropertySet("Mellissa", "", "MacBeth");
            mapiContact.ProfessionalInfo.Title = "Account Representative";
            mapiContact.ProfessionalInfo.CompanyName = "Contoso Ltd.";
            mapiContact.ProfessionalInfo.OfficeLocation = "36/2529";
            mapiContact.Telephones.BusinessTelephoneNumber = "4255551212 x432";
            mapiContact.PhysicalAddresses.WorkAddress.Street = "1 Microsoft Way";
            mapiContact.PhysicalAddresses.WorkAddress.City = "Redmond";
            mapiContact.PhysicalAddresses.WorkAddress.StateOrProvince = "WA";
            mapiContact.PhysicalAddresses.WorkAddress.PostalCode = "98052";
            mapiContact.PhysicalAddresses.WorkAddress.Country = "United States of America";
            mapiContact.ElectronicAddresses.Email1.EmailAddress = "*****@*****.**";
            mapiContact.ElectronicAddresses.Email1.AddressType = "SMTP";
            mapiContact.ElectronicAddresses.Email1.DisplayName = "Melissa MacBeth ([email protected])";

            //Save the Contact object to disc
            mapiContact.Save("Contact.vcf", ContactSaveFormat.VCard);
        }
예제 #13
0
        public static void Run()
        {
            // ExStart:SaveContactInformation
            // Load the Outlook file
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Load the Outlook PST file
            PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir + "Outlook.pst");
            // Get the Contacts folder
            FolderInfo folderInfo = personalStorage.RootFolder.GetSubFolder("Contacts");
            // Loop through all the contacts in this folder
            MessageInfoCollection messageInfoCollection = folderInfo.GetContents();

            foreach (MessageInfo messageInfo in messageInfoCollection)
            {
                // Get the contact information
                MapiContact contact = (MapiContact)personalStorage.ExtractMessage(messageInfo).ToMapiMessageItem();
                // Display some contents on screen
                Console.WriteLine("Name: " + contact.NameInfo.DisplayName + " - " + messageInfo.EntryIdString);
                // Save to disk in vCard VCF format
                contact.Save(dataDir + "Contacts\\" + contact.NameInfo.DisplayName + ".vcf", ContactSaveFormat.VCard);
            }
            // ExEnd:SaveContactInformation
        }
예제 #14
0
        public static void Run()
        {
            // The path to the File directory.
            // ExStart:CreateNewMapiContactAndAddToContactsSubfolder
            string dataDir = RunExamples.GetDataDir_Outlook();

            // Create three Contacts
            MapiContact contact1 = new MapiContact("Sebastian Wright", "*****@*****.**");
            MapiContact contact2 = new MapiContact("Wichert Kroos", "*****@*****.**", "Grade A Investment");
            MapiContact contact3 = new MapiContact("Christoffer van de Meeberg", "*****@*****.**", "Krauses Sofa Factory", "046-630-4614046-630-4614");

            // Contact #4
            MapiContact contact4 = new MapiContact();

            contact4.NameInfo            = new MapiContactNamePropertySet("Margaret", "J.", "Tolle");
            contact4.PersonalInfo.Gender = MapiContactGender.Female;
            contact4.ProfessionalInfo    = new MapiContactProfessionalPropertySet("Adaptaz", "Recording engineer");
            contact4.PhysicalAddresses.WorkAddress.Address = "4 Darwinia Loop EIGHTY MILE BEACH WA 6725";
            contact4.ElectronicAddresses.Email1            = new MapiContactElectronicAddress("Hisen1988", "SMTP", "*****@*****.**");
            contact4.Telephones.BusinessTelephoneNumber    = "(08)9080-1183";
            contact4.Telephones.MobileTelephoneNumber      = "(925)599-3355(925)599-3355";

            // Contact #5
            MapiContact contact5 = new MapiContact();

            contact5.NameInfo            = new MapiContactNamePropertySet("Matthew", "R.", "Wilcox");
            contact5.PersonalInfo.Gender = MapiContactGender.Male;
            contact5.ProfessionalInfo    = new MapiContactProfessionalPropertySet("Briazz", "Psychiatric aide");
            contact5.PhysicalAddresses.WorkAddress.Address = "Horner Strasse 12 4421 SAASS";
            contact5.Telephones.BusinessTelephoneNumber    = "0650 675 73 300650 675 73 30";
            contact5.Telephones.HomeTelephoneNumber        = "(661)387-5382(661)387-5382";

            // Contact #6
            MapiContact contact6 = new MapiContact();

            contact6.NameInfo         = new MapiContactNamePropertySet("Bertha", "A.", "Buell");
            contact6.ProfessionalInfo = new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant");
            contact6.PersonalInfo.PersonalHomePage         = "B2BTies.com";
            contact6.PhysicalAddresses.WorkAddress.Address = "Im Astenfeld 59 8580 EDELSCHROTT";
            contact6.ElectronicAddresses.Email1            = new MapiContactElectronicAddress("Experwas", "SMTP", "*****@*****.**");
            contact6.Telephones = new MapiContactTelephonePropertySet("06605045265");

            // Load the Outlook file
            string path = dataDir + "SampleContacts_out.pst";

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            using (PersonalStorage personalStorage = PersonalStorage.Create(dataDir + "SampleContacts_out.pst", FileFormatVersion.Unicode))
            {
                FolderInfo contactFolder = personalStorage.CreatePredefinedFolder("Contacts", StandardIpmFolder.Contacts);
                contactFolder.AddMapiMessageItem(contact1);
                contactFolder.AddMapiMessageItem(contact2);
                contactFolder.AddMapiMessageItem(contact3);
                contactFolder.AddMapiMessageItem(contact4);
                contactFolder.AddMapiMessageItem(contact5);
                contactFolder.AddMapiMessageItem(contact6);
            }
            // ExEnd:CreateNewMapiContactAndAddToContactsSubfolder
        }
        private string GetUserEmailAddress(MapiContact contact)
        {
            string emailAddress = string.Empty;

            emailAddress = contact.ElectronicAddresses.Email1.EmailAddress;
            if (!string.IsNullOrEmpty(emailAddress)) return emailAddress;

            emailAddress = contact.ElectronicAddresses.Email2.EmailAddress;
            if (!string.IsNullOrEmpty(emailAddress)) return emailAddress;

            emailAddress = contact.ElectronicAddresses.Email3.EmailAddress;
            if (!string.IsNullOrEmpty(emailAddress)) return emailAddress;

            return emailAddress;
        }
        private UserCreateStatus CreateDNNUser(MapiContact contact)
        {
            UserInfo user = new UserInfo();
            user.Email = GetUserEmailAddress(contact);
            user.Username = user.Email;
            user.FirstName = contact.NameInfo.GivenName;
            user.LastName = contact.NameInfo.Surname;
            user.DisplayName = contact.NameInfo.DisplayName;

            user.Membership.Password = UserController.GeneratePassword(12).ToString();
            user.PortalID = PortalId;
            user.IsSuperUser = false;

            UserCreateStatus createStatus = UserCreateStatus.AddUser;

            //Create the User
            createStatus = UserController.CreateUser(ref user);

            if (createStatus == UserCreateStatus.Success)
            {
                ProfileController.GetUserProfile(ref user);

                user.Profile.FirstName = contact.NameInfo.GivenName;
                user.Profile.SetProfileProperty("MiddleName", contact.NameInfo.MiddleName);
                user.Profile.LastName = contact.NameInfo.Surname;

                user.Profile.Telephone = string.IsNullOrEmpty(contact.Telephones.BusinessTelephoneNumber) ? contact.Telephones.HomeTelephoneNumber : contact.Telephones.BusinessTelephoneNumber;
                user.Profile.Cell = contact.Telephones.MobileTelephoneNumber;
                user.Profile.Website = string.IsNullOrEmpty(contact.PersonalInfo.BusinessHomePage) ? contact.PersonalInfo.Html : contact.PersonalInfo.BusinessHomePage;
                user.Profile.IM = contact.PersonalInfo.InstantMessagingAddress;

                user.Profile.Street = contact.PhysicalAddresses.HomeAddress.Street;
                user.Profile.City = contact.PhysicalAddresses.HomeAddress.City;
                user.Profile.Region = contact.PhysicalAddresses.HomeAddress.StateOrProvince;
                user.Profile.PostalCode = contact.PhysicalAddresses.HomeAddress.PostalCode;
                user.Profile.Country = contact.PhysicalAddresses.HomeAddress.Country;

                user.Profile.Street = string.IsNullOrEmpty(user.Profile.Street) ? contact.PhysicalAddresses.WorkAddress.Street : user.Profile.Street;
                user.Profile.City = string.IsNullOrEmpty(user.Profile.City) ? contact.PhysicalAddresses.WorkAddress.City : user.Profile.City;
                user.Profile.Region = string.IsNullOrEmpty(user.Profile.Region) ? contact.PhysicalAddresses.WorkAddress.StateOrProvince : user.Profile.Region;
                user.Profile.PostalCode = string.IsNullOrEmpty(user.Profile.PostalCode) ? contact.PhysicalAddresses.WorkAddress.PostalCode : user.Profile.PostalCode;
                user.Profile.Country = string.IsNullOrEmpty(user.Profile.Country) ? contact.PhysicalAddresses.WorkAddress.Country : user.Profile.Country;

                user.Profile.Street = string.IsNullOrEmpty(user.Profile.Street) ? contact.PhysicalAddresses.OtherAddress.Street : user.Profile.Street;
                user.Profile.City = string.IsNullOrEmpty(user.Profile.City) ? contact.PhysicalAddresses.OtherAddress.City : user.Profile.City;
                user.Profile.Region = string.IsNullOrEmpty(user.Profile.Region) ? contact.PhysicalAddresses.OtherAddress.StateOrProvince : user.Profile.Region;
                user.Profile.PostalCode = string.IsNullOrEmpty(user.Profile.PostalCode) ? contact.PhysicalAddresses.OtherAddress.PostalCode : user.Profile.PostalCode;
                user.Profile.Country = string.IsNullOrEmpty(user.Profile.Country) ? contact.PhysicalAddresses.OtherAddress.Country : user.Profile.Country;

                ProfileController.UpdateUserProfile(user);

                DataCache.ClearPortalCache(user.PortalID, false);

                RoleController objRoles = new RoleController();

                List<int> rolesList = new List<int>();

                foreach (int roleID in rolesList)
                {
                    objRoles.AddUserRole(user.PortalID, user.UserID, roleID, Null.NullDate, Null.NullDate);
                }
            }

            return createStatus;
        }
        private MapiContact BuildNewExchangeContact(UserInfo user)
        {
            MapiContact contact = new MapiContact();
            contact.ElectronicAddresses.Email1.EmailAddress = user.Email;
            contact.NameInfo.GivenName = user.FirstName;
            contact.NameInfo.Surname = user.LastName;
            contact.NameInfo.DisplayName = user.DisplayName;

            ProfileController.GetUserProfile(ref user);

            contact.Telephones.HomeTelephoneNumber = user.Profile.Telephone;
            contact.NameInfo.MiddleName = user.Profile.GetProperty("MiddleName").PropertyValue;
            contact.Telephones.BusinessTelephoneNumber = user.Profile.Telephone;
            contact.Telephones.MobileTelephoneNumber = user.Profile.Cell;
            contact.PersonalInfo.BusinessHomePage = user.Profile.Website;
            contact.PersonalInfo.InstantMessagingAddress = user.Profile.IM;

            contact.PhysicalAddresses.HomeAddress.Street = user.Profile.Street;
            contact.PhysicalAddresses.HomeAddress.City = user.Profile.City;
            contact.PhysicalAddresses.HomeAddress.StateOrProvince = user.Profile.Region;
            contact.PhysicalAddresses.HomeAddress.PostalCode = user.Profile.PostalCode;
            contact.PhysicalAddresses.HomeAddress.Country = user.Profile.Country;

            return contact;
        }