Example #1
0
        private Banckle.Person OutlookToBanckleContact(Outlook.ContactItem contact)
        {
            Banckle.Person    person  = new Banckle.Person();
            Banckle.Email[]   emails  = new Email[3];
            Banckle.Phone[]   phone   = new Banckle.Phone[15];
            Banckle.Address[] address = new Banckle.Address[4];

            try
            {
                person.birthDay  = String.IsNullOrWhiteSpace(contact.Birthday.ToString("dd:MM:yyyy")) ? "" : contact.Birthday.ToString("dd:MM:yyyy");
                person.firstName = String.IsNullOrWhiteSpace(contact.FirstName) ? "" : contact.FirstName;
                person.lastName  = String.IsNullOrEmpty(contact.LastName) ? "" : contact.LastName;
                //person.lastName = "";

                /*
                 * Emails
                 */

                emails[0] = new Email {
                    type = "Primary", address = contact.Email1Address
                };
                emails[1] = new Email {
                    type = "Secondary", address = contact.Email2Address
                };
                emails[2] = new Email {
                    type = "Tertiary", address = contact.Email3Address
                };

                /*
                 * Phone Numbers
                 */

                phone[0] = new Phone {
                    type = "Business2TelephoneNumber", number = contact.Business2TelephoneNumber
                };
                phone[1] = new Phone {
                    type = "BusinessFaxNumber", number = contact.BusinessFaxNumber
                };
                phone[2] = new Phone {
                    type = "BusinessTelephoneNumber", number = contact.BusinessTelephoneNumber
                };
                phone[3] = new Phone {
                    type = "CallbackTelephoneNumber", number = contact.CallbackTelephoneNumber
                };
                phone[4] = new Phone {
                    type = "CarTelephoneNumber", number = contact.CarTelephoneNumber
                };
                phone[5] = new Phone {
                    type = "AssistantTelephoneNumber", number = contact.AssistantTelephoneNumber
                };
                phone[6] = new Phone {
                    type = "CompanyMainTelephoneNumber", number = contact.CompanyMainTelephoneNumber
                };
                phone[7] = new Phone {
                    type = "Home2TelephoneNumber", number = contact.Home2TelephoneNumber
                };
                phone[8] = new Phone {
                    type = "HomeFaxNumber", number = contact.HomeFaxNumber
                };
                phone[9] = new Phone {
                    type = "HomeTelephoneNumber", number = contact.HomeTelephoneNumber
                };
                phone[10] = new Phone {
                    type = "MobileTelephoneNumber", number = contact.MobileTelephoneNumber
                };
                phone[11] = new Phone {
                    type = "OtherFaxNumber", number = contact.OtherFaxNumber
                };
                phone[12] = new Phone {
                    type = "OtherTelephoneNumber", number = contact.OtherTelephoneNumber
                };
                phone[13] = new Phone {
                    type = "PrimaryTelephoneNumber", number = contact.PrimaryTelephoneNumber
                };
                phone[14] = new Phone {
                    type = "RadioTelephoneNumber", number = contact.RadioTelephoneNumber
                };

                /*
                 * addresses
                 */

                address[0] = new Address {
                    type = "Mailing", building = contact.MailingAddress, street = contact.MailingAddressStreet, city = contact.MailingAddressCity, state = contact.MailingAddressState, zip = contact.MailingAddressPostalCode, country = contact.MailingAddressCountry
                };
                address[1] = new Address {
                    type = "Home", building = contact.HomeAddress, street = contact.HomeAddressStreet, city = contact.HomeAddressCity, state = contact.HomeAddressState, zip = contact.HomeAddressPostalCode, country = contact.HomeAddressCountry
                };
                address[2] = new Address {
                    type = "Business", building = contact.BusinessAddress, street = contact.BusinessAddressStreet, city = contact.BusinessAddressCity, state = contact.BusinessAddressState, zip = contact.BusinessAddressPostalCode, country = contact.BusinessAddressCountry
                };
                address[3] = new Address {
                    type = "Other", building = contact.OtherAddress, street = contact.OtherAddressStreet, city = contact.OtherAddressCity, state = contact.OtherAddressState, zip = contact.OtherAddressPostalCode, country = contact.OtherAddressCountry
                };

                person.emails    = emails;
                person.phones    = phone;
                person.addresses = address;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("The new contact was not saved, because \r" + ex.Message + "\r" + ex.StackTrace);
            }
            return(person);
        }
        private void AddOutlookContact(Banckle.ContactDetails contact)
        {
            Outlook.ContactItem newContact = (Outlook.ContactItem)this.Application.CreateItem(Outlook.OlItemType.olContactItem);

            Banckle.Email[] emails = new Email[3];
            Banckle.Phone[] phone = new Banckle.Phone[2];
            Banckle.Address[] address = new Banckle.Address[3];
            try
            {
                newContact.FullName = String.IsNullOrWhiteSpace(contact.name) ? "" : contact.name;

                if (contact.emails.Length > 0)
                {
                    if (contact.emails.Length >= 3)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;

                        newContact.Email2AddressType = String.IsNullOrWhiteSpace(contact.emails[1].type) ? "" : contact.emails[1].type;
                        newContact.Email2Address = String.IsNullOrWhiteSpace(contact.emails[1].address) ? "" : contact.emails[1].address;

                        newContact.Email3AddressType = String.IsNullOrWhiteSpace(contact.emails[2].type) ? "" : contact.emails[2].type;
                        newContact.Email3Address = String.IsNullOrWhiteSpace(contact.emails[2].address) ? "" : contact.emails[2].address;

                    }
                    if (contact.emails.Length == 2)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;

                        newContact.Email2AddressType = String.IsNullOrWhiteSpace(contact.emails[1].type) ? "" : contact.emails[1].type;
                        newContact.Email2Address = String.IsNullOrWhiteSpace(contact.emails[1].address) ? "" : contact.emails[1].address;

                    }
                    if (contact.emails.Length == 1)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;

                    }
                }

                if (contact.phones.Length > 0)
                {
                    if (contact.phones.Length >= 2)
                    {
                        newContact.PrimaryTelephoneNumber = String.IsNullOrWhiteSpace(contact.phones[0].number) ? "" : contact.phones[0].number;
                        newContact.OtherTelephoneNumber = String.IsNullOrWhiteSpace(contact.phones[1].number) ? "" : contact.phones[1].number;
                    }
                    if (contact.phones.Length == 1)
                    {
                        newContact.PrimaryTelephoneNumber = String.IsNullOrWhiteSpace(contact.phones[0].number) ? "" : contact.phones[0].number;
                    }
                }

                if (contact.addresses.Length > 0)
                {
                    if (contact.addresses.Length >= 3)
                    {
                        newContact.MailingAddress = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;

                        newContact.HomeAddress = String.IsNullOrWhiteSpace(contact.addresses[1].building) ? "" : contact.addresses[1].building;
                        newContact.HomeAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[1].street) ? "" : contact.addresses[1].street;
                        newContact.HomeAddressCity = String.IsNullOrWhiteSpace(contact.addresses[1].city) ? "" : contact.addresses[1].city;
                        newContact.HomeAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[1].zip) ? "" : contact.addresses[1].zip;
                        newContact.HomeAddressState = String.IsNullOrWhiteSpace(contact.addresses[1].state) ? "" : contact.addresses[1].state;
                        newContact.HomeAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[1].country) ? "" : contact.addresses[1].country;

                        newContact.OtherAddress = String.IsNullOrWhiteSpace(contact.addresses[2].building) ? "" : contact.addresses[2].building;
                        newContact.OtherAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[2].street) ? "" : contact.addresses[2].street;
                        newContact.OtherAddressCity = String.IsNullOrWhiteSpace(contact.addresses[2].city) ? "" : contact.addresses[2].city;
                        newContact.OtherAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[2].zip) ? "" : contact.addresses[2].zip;
                        newContact.OtherAddressState = String.IsNullOrWhiteSpace(contact.addresses[2].state) ? "" : contact.addresses[2].state;
                        newContact.OtherAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[2].country) ? "" : contact.addresses[2].country;
                    }
                    if (contact.addresses.Length == 2)
                    {
                        newContact.MailingAddress = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;

                        newContact.HomeAddress = String.IsNullOrWhiteSpace(contact.addresses[1].building) ? "" : contact.addresses[1].building;
                        newContact.HomeAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[1].street) ? "" : contact.addresses[1].street;
                        newContact.HomeAddressCity = String.IsNullOrWhiteSpace(contact.addresses[1].city) ? "" : contact.addresses[1].city;
                        newContact.HomeAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[1].zip) ? "" : contact.addresses[1].zip;
                        newContact.HomeAddressState = String.IsNullOrWhiteSpace(contact.addresses[1].state) ? "" : contact.addresses[1].state;
                        newContact.HomeAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[1].country) ? "" : contact.addresses[1].country;
                    }
                    if (contact.addresses.Length == 1)
                    {
                        newContact.MailingAddress = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;
                    }
                }

                newContact.Save();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("The new contact was not saved, because \r" + ex.Message + "\r" + ex.StackTrace);
            }
        }
Example #3
0
        private void AddOutlookContact(Banckle.ContactDetails contact)
        {
            Outlook.ContactItem newContact = (Outlook.ContactItem) this.Application.CreateItem(Outlook.OlItemType.olContactItem);

            Banckle.Email[]   emails  = new Email[3];
            Banckle.Phone[]   phone   = new Banckle.Phone[2];
            Banckle.Address[] address = new Banckle.Address[3];
            try
            {
                newContact.FullName = String.IsNullOrWhiteSpace(contact.name) ? "" : contact.name;

                if (contact.emails.Length > 0)
                {
                    if (contact.emails.Length >= 3)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address     = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;

                        newContact.Email2AddressType = String.IsNullOrWhiteSpace(contact.emails[1].type) ? "" : contact.emails[1].type;
                        newContact.Email2Address     = String.IsNullOrWhiteSpace(contact.emails[1].address) ? "" : contact.emails[1].address;

                        newContact.Email3AddressType = String.IsNullOrWhiteSpace(contact.emails[2].type) ? "" : contact.emails[2].type;
                        newContact.Email3Address     = String.IsNullOrWhiteSpace(contact.emails[2].address) ? "" : contact.emails[2].address;
                    }
                    if (contact.emails.Length == 2)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address     = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;

                        newContact.Email2AddressType = String.IsNullOrWhiteSpace(contact.emails[1].type) ? "" : contact.emails[1].type;
                        newContact.Email2Address     = String.IsNullOrWhiteSpace(contact.emails[1].address) ? "" : contact.emails[1].address;
                    }
                    if (contact.emails.Length == 1)
                    {
                        newContact.Email1AddressType = String.IsNullOrWhiteSpace(contact.emails[0].type) ? "" : contact.emails[0].type;
                        newContact.Email1Address     = String.IsNullOrWhiteSpace(contact.emails[0].address) ? "" : contact.emails[0].address;
                    }
                }


                if (contact.phones.Length > 0)
                {
                    if (contact.phones.Length >= 2)
                    {
                        newContact.PrimaryTelephoneNumber = String.IsNullOrWhiteSpace(contact.phones[0].number) ? "" : contact.phones[0].number;
                        newContact.OtherTelephoneNumber   = String.IsNullOrWhiteSpace(contact.phones[1].number) ? "" : contact.phones[1].number;
                    }
                    if (contact.phones.Length == 1)
                    {
                        newContact.PrimaryTelephoneNumber = String.IsNullOrWhiteSpace(contact.phones[0].number) ? "" : contact.phones[0].number;
                    }
                }

                if (contact.addresses.Length > 0)
                {
                    if (contact.addresses.Length >= 3)
                    {
                        newContact.MailingAddress           = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState      = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;

                        newContact.HomeAddress           = String.IsNullOrWhiteSpace(contact.addresses[1].building) ? "" : contact.addresses[1].building;
                        newContact.HomeAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[1].street) ? "" : contact.addresses[1].street;
                        newContact.HomeAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[1].city) ? "" : contact.addresses[1].city;
                        newContact.HomeAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[1].zip) ? "" : contact.addresses[1].zip;
                        newContact.HomeAddressState      = String.IsNullOrWhiteSpace(contact.addresses[1].state) ? "" : contact.addresses[1].state;
                        newContact.HomeAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[1].country) ? "" : contact.addresses[1].country;

                        newContact.OtherAddress           = String.IsNullOrWhiteSpace(contact.addresses[2].building) ? "" : contact.addresses[2].building;
                        newContact.OtherAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[2].street) ? "" : contact.addresses[2].street;
                        newContact.OtherAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[2].city) ? "" : contact.addresses[2].city;
                        newContact.OtherAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[2].zip) ? "" : contact.addresses[2].zip;
                        newContact.OtherAddressState      = String.IsNullOrWhiteSpace(contact.addresses[2].state) ? "" : contact.addresses[2].state;
                        newContact.OtherAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[2].country) ? "" : contact.addresses[2].country;
                    }
                    if (contact.addresses.Length == 2)
                    {
                        newContact.MailingAddress           = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState      = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;

                        newContact.HomeAddress           = String.IsNullOrWhiteSpace(contact.addresses[1].building) ? "" : contact.addresses[1].building;
                        newContact.HomeAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[1].street) ? "" : contact.addresses[1].street;
                        newContact.HomeAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[1].city) ? "" : contact.addresses[1].city;
                        newContact.HomeAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[1].zip) ? "" : contact.addresses[1].zip;
                        newContact.HomeAddressState      = String.IsNullOrWhiteSpace(contact.addresses[1].state) ? "" : contact.addresses[1].state;
                        newContact.HomeAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[1].country) ? "" : contact.addresses[1].country;
                    }
                    if (contact.addresses.Length == 1)
                    {
                        newContact.MailingAddress           = String.IsNullOrWhiteSpace(contact.addresses[0].building) ? "" : contact.addresses[0].building;
                        newContact.MailingAddressStreet     = String.IsNullOrWhiteSpace(contact.addresses[0].street) ? "" : contact.addresses[0].street;
                        newContact.MailingAddressCity       = String.IsNullOrWhiteSpace(contact.addresses[0].city) ? "" : contact.addresses[0].city;
                        newContact.MailingAddressPostalCode = String.IsNullOrWhiteSpace(contact.addresses[0].zip) ? "" : contact.addresses[0].zip;
                        newContact.MailingAddressState      = String.IsNullOrWhiteSpace(contact.addresses[0].state) ? "" : contact.addresses[0].state;
                        newContact.MailingAddressCountry    = String.IsNullOrWhiteSpace(contact.addresses[0].country) ? "" : contact.addresses[0].country;
                    }
                }

                newContact.Save();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("The new contact was not saved, because \r" + ex.Message + "\r" + ex.StackTrace);
            }
        }
        private Banckle.Person OutlookToBanckleContact(Outlook.ContactItem contact)
        {
            Banckle.Person person = new Banckle.Person();
            Banckle.Email[] emails = new Email[3];
            Banckle.Phone[] phone = new Banckle.Phone[15];
            Banckle.Address[] address = new Banckle.Address[4];

            try
            {
                person.birthDay = String.IsNullOrWhiteSpace(contact.Birthday.ToString("dd:MM:yyyy")) ? "" : contact.Birthday.ToString("dd:MM:yyyy");
                person.firstName = String.IsNullOrWhiteSpace(contact.FirstName) ? "" : contact.FirstName;
                person.lastName = String.IsNullOrEmpty(contact.LastName) ? "" : contact.LastName;
                //person.lastName = "";

                /*
                 * Emails
                 */

                emails[0] = new Email { type = "Primary", address = contact.Email1Address };
                emails[1] = new Email { type = "Secondary", address = contact.Email2Address };
                emails[2] = new Email { type = "Tertiary", address = contact.Email3Address };

                /*
                 * Phone Numbers
                 */

                phone[0] = new Phone { type = "Business2TelephoneNumber", number = contact.Business2TelephoneNumber };
                phone[1] = new Phone { type = "BusinessFaxNumber", number = contact.BusinessFaxNumber };
                phone[2] = new Phone { type = "BusinessTelephoneNumber", number = contact.BusinessTelephoneNumber };
                phone[3] = new Phone { type = "CallbackTelephoneNumber", number = contact.CallbackTelephoneNumber };
                phone[4] = new Phone { type = "CarTelephoneNumber", number = contact.CarTelephoneNumber };
                phone[5] = new Phone { type = "AssistantTelephoneNumber", number = contact.AssistantTelephoneNumber };
                phone[6] = new Phone { type = "CompanyMainTelephoneNumber", number = contact.CompanyMainTelephoneNumber };
                phone[7] = new Phone { type = "Home2TelephoneNumber", number = contact.Home2TelephoneNumber };
                phone[8] = new Phone { type = "HomeFaxNumber", number = contact.HomeFaxNumber };
                phone[9] = new Phone { type = "HomeTelephoneNumber", number = contact.HomeTelephoneNumber };
                phone[10] = new Phone { type = "MobileTelephoneNumber", number = contact.MobileTelephoneNumber };
                phone[11] = new Phone { type = "OtherFaxNumber", number = contact.OtherFaxNumber };
                phone[12] = new Phone { type = "OtherTelephoneNumber", number = contact.OtherTelephoneNumber };
                phone[13] = new Phone { type = "PrimaryTelephoneNumber", number = contact.PrimaryTelephoneNumber };
                phone[14] = new Phone { type = "RadioTelephoneNumber", number = contact.RadioTelephoneNumber };

                /*
                 * addresses
                 */

                address[0] = new Address { type = "Mailing", building = contact.MailingAddress, street = contact.MailingAddressStreet, city = contact.MailingAddressCity, state = contact.MailingAddressState, zip = contact.MailingAddressPostalCode, country = contact.MailingAddressCountry };
                address[1] = new Address { type = "Home", building = contact.HomeAddress, street = contact.HomeAddressStreet, city = contact.HomeAddressCity, state = contact.HomeAddressState, zip = contact.HomeAddressPostalCode, country = contact.HomeAddressCountry };
                address[2] = new Address { type = "Business", building = contact.BusinessAddress, street = contact.BusinessAddressStreet, city = contact.BusinessAddressCity, state = contact.BusinessAddressState, zip = contact.BusinessAddressPostalCode, country = contact.BusinessAddressCountry };
                address[3] = new Address { type = "Other", building = contact.OtherAddress, street = contact.OtherAddressStreet, city = contact.OtherAddressCity, state = contact.OtherAddressState, zip = contact.OtherAddressPostalCode, country = contact.OtherAddressCountry };

                person.emails = emails;
                person.phones = phone;
                person.addresses = address;

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("The new contact was not saved, because \r" + ex.Message + "\r" + ex.StackTrace);
            }
            return person;
        }