public Contact CreateContactFromUserInput(TextBox EmailAddress, TextBox PhoneNumber)
        {
            if (EmailAddress.Text.Length == 0 && PhoneNumber.Text.Length == 0)
            {
                NotifyUser("You must enter an email address and/or phone number.", NotifyType.ErrorMessage);
                return null;
            }

            Contact contact = new Contact();

            // Maximum length for email address is 321, enforced by XAML markup.
            if (EmailAddress.Text.Length > 0)
            {
                ContactEmail email = new ContactEmail() { Address = EmailAddress.Text };
                contact.Emails.Add(email);
            }

            // Maximum length for phone number is 50, enforced by XAML markup.
            if (PhoneNumber.Text.Length > 0)
            {
                ContactPhone phone = new ContactPhone() { Number = PhoneNumber.Text };
                contact.Phones.Add(phone);
            }

            return contact;
        }
        // GET: Contact
        public ActionResult Form()
        {
            ViewBag.Status = "We Are Still Working on the Admin Portal for Reviewing Messages!";
            ContactEmail email = new ContactEmail();

            return(View(email));
        }
Example #3
0
        public ActionResult _EmailContact(ContactEmail model)
        {
            if (ModelState.IsValid)
            {
                var body    = "Name: {0} <br />  Phone: {1} <br /> Email: {2} <br /> Website/Facebook: {3} <br /> Message: {4} <br /> Phone Contact: {5} <br /> Email Contact: {6}";
                var message = new SendGridMessage();
                message.AddTo("*****@*****.**");
                message.AddTo("*****@*****.**");                              // replace with valid value
                message.AddTo("*****@*****.**");
                message.From    = new MailAddress("*****@*****.**"); // replace with valid value
                message.Subject = "Pizza Solutions Contact Message";
                message.Html    = string.Format(body, model.Name, model.Phone, model.Email, model.Website, model.Message, model.PhoneContact, model.EmailContact);

                var username = ConfigurationManager.AppSettings["sendGridUser"];
                var pswd     = ConfigurationManager.AppSettings["sendGridPassword"];

                // variable to store azure credentials
                var credentials = new NetworkCredential(username, pswd);
                // Create an Web transport for sending email.
                var transportWeb = new Web(credentials);

                // Send the email, which returns an awaitable task.
                transportWeb.DeliverAsync(message);

                ModelState.Clear(); //clears form when page reload
                return(RedirectToAction("ConfirmationEmail", "Home", new { model.Name, model.Phone, model.Email, model.Website, model.Message }));
            }
            return(View(model));
        }
        public async Task <IActionResult> PutContactEmail(int id, ContactEmail contactEmail)
        {
            if (id != contactEmail.Id)
            {
                return(BadRequest());
            }

            _context.Entry(contactEmail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ContactEmailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #5
0
        public ErrorServiceTests()
        {
            // seed test app and contact
            using (var session = DocumentStore.OpenSession())
            {
                var contactEmail = new ContactEmail {
                    EmailAddress = "*****@*****.**", Confirmed = true
                };
                session.Store(contactEmail);

                var testApp = new App
                {
                    ApiKey          = "apikey",
                    ContactEmailIds = new List <string> {
                        contactEmail.Id
                    },
                    Name = "test app"
                };
                session.Store(testApp);

                session.SaveChanges();
                _TestAppId = testApp.Id;
            }

            _MockEmailService = new Mock <IEmailService>();
        }
Example #6
0
 /// <summary>
 /// Save Contact Email
 /// </summary>
 /// <param name="email">contact email.</param>
 /// <returns></returns>
 public int SaveContactEmail(ContactEmail email)
 {
     using (var service = new ServiceContext())
     {
         return(service.Save <ContactEmail>(email, true, false, new string[] { "EmailAddress" }));
     }
 }
Example #7
0
        public Contact MapConstantContactDataToContact(dynamic contactData)
        {
            Contact contact = new Contact();

            contact.ConstantContactID = contactData.id;
            contact.FirstName         = contactData.first_name;
            contact.LastName          = contactData.last_name;
            contact.Type = contactData.job_title;

            contact.ContactLists = new List <ContactList>();

            foreach (dynamic list in contactData.lists)
            {
                ContactList contactList = new ContactList();
                contactList.ListID = list.id;
                contact.ContactLists.Add(contactList);
            }

            contact.EmailAddresses = new List <ContactEmail>();

            foreach (dynamic email in contactData.email_addresses)
            {
                ContactEmail contactEmail = new ContactEmail();
                contactEmail.Address = email.email_address;
                contact.EmailAddresses.Add(contactEmail);
            }

            return(contact);
        }
Example #8
0
        public Result SendAndSaveContactQuestion(ContactEmail contactEmail)
        {
            _emailSenderService.SendContactQuestion(contactEmail);
            _emailStorageService.SaveEmail(contactEmail);

            return(new Result(true, null, ""));
        }
Example #9
0
        public IActionResult ContactStore()
        {
            try{
                Contact contact = new Contact();
                contact.Name  = HttpContext.Request.Form["name"];
                contact.Email = HttpContext.Request.Form["email"];
                contact.Text  = HttpContext.Request.Form["text"];

                var  messages = new List <ValidationResult>();
                var  contexto = new ValidationContext(contact);
                bool isValid  = Validator.TryValidateObject(contact, contexto, messages, true);
                if (isValid)
                {
                    ContactEmail.SedContact(contact);
                    ViewData["MSG_S"] = "Mensagem de contato enciado com sucesso!";
                }
                else
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (var message in messages)
                    {
                        stringBuilder.Append(message.ErrorMessage + "<br/>");
                    }
                    ViewData["MSG_E"]   = stringBuilder.ToString();
                    ViewData["contact"] = contact;
                }
            }catch (Exception e) {
                ViewData["MSG_E"] = "Ops! Tivemos um erro, tente novamente mais tarde!" + e;
            }
            return(View("Contact"));
        }
Example #10
0
        public IHttpActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Not a valid Contact id"));
            }

            Contact contact = entities.Contact.Where(c => c.Id == id).FirstOrDefault();

            if (contact == null)
            {
                return(BadRequest("Contact doesn't exist"));
            }

            ContactEmail  contactEmail  = entities.ContactEmail.Where(c => c.ContactId == id).FirstOrDefault();
            ContactNumber contactNumber = entities.ContactNumber.Where(c => c.ContactId == id).FirstOrDefault();
            ContactTag    contactTag    = entities.ContactTag.Where(c => c.ContactId == id).FirstOrDefault();


            entities.ContactEmail.Remove(contactEmail);
            entities.ContactNumber.Remove(contactNumber);
            entities.ContactTag.Remove(contactTag);
            entities.Contact.Remove(contact);

            entities.SaveChanges();


            return(Ok("Contact successfully deleted!"));
        }
        public ActionResult ManageContact(Contact contact)
        {
            contact.UserID = ProjectSession.UserID;
            var contactID = _contactBL.SaveContact(contact);

            if (contactID > 0)
            {
                if (!string.IsNullOrEmpty(contact.MobileNo))
                {
                    var contactMobile = new ContactMobile();
                    contactMobile.ContactID = contactID;
                    contactMobile.MobileNo  = contact.MobileNo;
                    _contactBL.SaveContactMobile(contactMobile);
                }

                if (!string.IsNullOrEmpty(contact.EmailAddress))
                {
                    var contactEmail = new ContactEmail();
                    contactEmail.ContactID    = contactID;
                    contactEmail.EmailAddress = contact.EmailAddress;
                    _contactBL.SaveContactEmail(contactEmail);
                }
                if (contact.ID == 0)
                {
                    return(RedirectToAction("manage-contact", new { id = contactID }));
                }
                else
                {
                    return(RedirectToAction("index"));
                }
            }
            return(View("ManageContact", contact));
        }
        /// <summary>
        /// Add Contact Email
        /// </summary>
        /// <param name="contactID">contactID</param>
        /// <returns>action result</returns>
        public ActionResult AddContactEmail(int contactID)
        {
            var contactEmail = new ContactEmail();

            contactEmail.ContactID = contactID;
            return(PartialView("_AddContactEmail", contactEmail));
        }
Example #13
0
 public async Task <bool> Delete(ContactEmail ContactEmail)
 {
     if (await ValidateId(ContactEmail))
     {
     }
     return(ContactEmail.IsValidated);
 }
Example #14
0
        public ActionResult Show(ContactEmail contactEmail, string key)
        {
            var admin = User.Identity.IsAuthenticated;

            if (ModelState.IsValid)
            {
                _emailService.SendAndSaveOfferQuestion(contactEmail);
                return(View("ConfirmMail"));
            }

            var parsedSearch = _searchService.ParseKey(key);

            if (parsedSearch.Id > 0)
            {
                var advert = _showAdvertService.GetAdvert(parsedSearch.AdType, parsedSearch.Id, admin);
                if (advert.Success)
                {
                    if (parsedSearch.AdType == AdType.Flat)
                    {
                        advert.Data.Flat.ContactEmail = contactEmail;
                    }
                    else if (parsedSearch.AdType == AdType.House)
                    {
                        advert.Data.House.ContactEmail = contactEmail;
                    }
                    else
                    {
                        advert.Data.Land.ContactEmail = contactEmail;
                    }
                    return(View(advert.Data));
                }
                return(RedirectToAction("NotFound"));
            }
            return(RedirectToAction("NotFound"));
        }
        public ActionResult Contact(ContactViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        ViewBag.ShowSuccessMessage = string.Empty;
                        var contactDetail = new ContactEmail
                        {
                            To                 = model.ContactEmail,
                            ContactName        = model.ContactName,
                            ContactPhoneNumber = model.ContactPhoneNumber,
                            ContactDescription = model.ContactDescription
                        };

                        var result = EmailManager.SendMail(contactDetail);
                        TempData["shortMessage"] = result ? "Thank you for contacting me!" : "Arrf, something wrong happened.";
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Example #16
0
        public ActionResult Contact(ContactFormModel cfm)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    ContactEmail email = new ContactEmail()
                    {
                        FirstName = cfm.FromFirstName,
                        LastName = cfm.FromLastName,
                        EmailFrom = cfm.FromEmail,
                        EmailTo = ConfigurationManager.AppSettings["EmailTo"],
                        SmtpFrom = ConfigurationManager.AppSettings["SmtpFrom"],
                        Subject = cfm.Subject,
                        Message = cfm.Message
                    };
                    email.Send();

                    return RedirectToAction("Index");
                }
            }
            catch (RulesException ex)
            {
                this.ModelState.AddRuleErrors(ex);
            }
            return View(cfm);
        }
Example #17
0
        public ActionResult Contact(ContactEmailModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    String subject  = model.Subject;
                    String contents = model.Contents;

                    ContactEmail es = new ContactEmail();
                    es.Send(subject, contents);

                    ViewBag.Result = "Email has been send.";

                    ModelState.Clear();

                    return(View(new ContactEmailModel()));
                }
                catch
                {
                    return(View());
                }
            }

            return(View());
        }
Example #18
0
        void SaveItem()
        {
            var    item     = new ContactEmail();
            bool   isInsert = false;
            string url      = "";

            if (!IsInsert <ContactEmail>())
            {
                item = GetCurrentItemReference <ContactEmail>();
            }
            else
            {
                item.DateCreated = DateTime.Now;
                item.EnteredBy   = _view.EnteredBy;
                isInsert         = true;
                url = SecurityContextManager.Current.CurrentURL.Replace("New", "ID=");
            }
            item.ChangedBy         = SecurityContextManager.Current.CurrentUser.ID;
            item.Email             = _view.Email;
            item.EmailTypeID       = _view.EmailTypeID;
            item.ContactID         = _view.ContactID;
            item.LastUpdated       = DateTime.Now;
            item.MarkedForDeletion = _view.MarkedForDeletion;
            new AccountServices().SaveContactEmail(item);
            if (isInsert)
            {
                _view.NavigateTo(url + item.ID.ToString());
            }
        }
Example #19
0
        public async Task <ContactEmail> Create(ContactEmail ContactEmail)
        {
            if (!await ContactEmailValidator.Create(ContactEmail))
            {
                return(ContactEmail);
            }

            try
            {
                ContactEmail.CreatorId     = CurrentContext.UserId;
                ContactEmail.EmailStatusId = EmailStatusEnum.NOT_DONE.Id;
                await UOW.ContactEmailRepository.Create(ContactEmail);

                ContactEmail = await UOW.ContactEmailRepository.Get(ContactEmail.Id);

                await Logging.CreateAuditLog(ContactEmail, new { }, nameof(ContactEmailService));

                return(ContactEmail);
            }
            catch (Exception ex)
            {
                await Logging.CreateSystemLog(ex, nameof(ContactEmailService));
            }
            return(null);
        }
Example #20
0
        public Contact CreateContactFromUserInput(TextBox EmailAddress, TextBox PhoneNumber)
        {
            if (EmailAddress.Text.Length == 0 && PhoneNumber.Text.Length == 0)
            {
                NotifyUser("You must enter an email address and/or phone number.", NotifyType.ErrorMessage);
                return(null);
            }

            Contact contact = new Contact();

            // Maximum length for email address is 321, enforced by XAML markup.
            if (EmailAddress.Text.Length > 0)
            {
                ContactEmail email = new ContactEmail()
                {
                    Address = EmailAddress.Text
                };
                contact.Emails.Add(email);
            }

            // Maximum length for phone number is 50, enforced by XAML markup.
            if (PhoneNumber.Text.Length > 0)
            {
                ContactPhone phone = new ContactPhone()
                {
                    Number = PhoneNumber.Text
                };
                contact.Phones.Add(phone);
            }

            return(contact);
        }
        //
        // GET: /Contact/
        public ActionResult Index()
        {
            //var db = new educationEntities();
            //ViewBag.SubjectName = new SelectList(db.menus, "id", "title");
            var model = new ContactEmail();

            return(View(model));
        }
Example #22
0
 /// <summary>
 /// Transforms an email address into the URL of a sitewide form used to send an email.
 /// </summary>
 /// <param name="email">The email.</param>
 /// <returns></returns>
 /// <exception cref="System.ArgumentNullException"></exception>
 public string TransformEmailAddress(ContactEmail email)
 {
     if (email == null)
     {
         throw new ArgumentNullException("email");
     }
     return(GetWebsiteEmailFormUri(email.EmailAddress, email.DisplayName, _baseUrl).ToString());
 }
Example #23
0
 private Abstractions.Email Convert(ContactEmail contactEmail)
 {
     Abstractions.Email email = new Abstractions.Email();
     email.Address = contactEmail.Address;
     email.Label   = contactEmail.Description;
     email.Type    = Convert(contactEmail.Kind);
     return(email);
 }
Example #24
0
 public async Task <bool> Update(ContactEmail ContactEmail)
 {
     if (await ValidateId(ContactEmail))
     {
         await ValidateReciepient(ContactEmail);
     }
     return(ContactEmail.IsValidated);
 }
Example #25
0
        public static ContactEmail UpdateEmailAddress(this ContactEmail baseEmail, ContactEmail updatedEmail)
        {
            baseEmail.Address     = updatedEmail.Address;
            baseEmail.Description = updatedEmail.Description;
            baseEmail.IsPrimary   = updatedEmail.IsPrimary;

            return(baseEmail);
        }
 public EmailResponse ConvertEmailFromRequest(ContactEmail email)
 {
     return(new EmailResponse
     {
         Email = email.Email,
         Type = email.Type
     });
 }
Example #27
0
        public async Task <bool> Delete(ContactEmail ContactEmail)
        {
            await DataContext.ContactEmail.Where(x => x.Id == ContactEmail.Id).UpdateFromQueryAsync(x => new ContactEmailDAO {
                DeletedAt = StaticParams.DateTimeNow, UpdatedAt = StaticParams.DateTimeNow
            });

            return(true);
        }
Example #28
0
        public void Transform_bad_address_returns_null()
        {
            var email       = new ContactEmail("Health%20and%20Safety%20");
            var transformer = new WebsiteFormEmailAddressTransformer(new Uri("https://example.org"));

            var result = transformer.TransformEmailAddress(email);

            Assert.Null(result);
        }
Example #29
0
 public ActionResult Contact(ContactEmail contactEmail)
 {
     if (ModelState.IsValid)
     {
         _emailService.SendAndSaveContactQuestion(contactEmail);
         return(View("ConfirmMail"));
     }
     return(View(contactEmail));
 }
        public Result SaveEmail(ContactEmail contactEmail)
        {
            var mail = AutoMapper.Mapper.Map <Mail>(contactEmail);

            _applicationContext.Mails.Add(mail);
            _applicationContext.SaveChanges();

            return(new Result(true, null, ""));
        }
Example #31
0
        public void Transform_address_returns_form_URL_with_email_as_display_name()
        {
            var email       = new ContactEmail("*****@*****.**");
            var transformer = new WebsiteFormEmailAddressTransformer(new Uri("https://example.org"));

            var result = transformer.TransformEmailAddress(email);

            Assert.Equal("https://example.org/contactus/emailus/email.aspx?n=first.last%40example.org&e=first.last&d=example.org", result);
        }
Example #32
0
 public void Validate()
 {
     Name.ValidateRequired("Name");
     BirthDate.ValidateRequired("BirthDate");
     ContactEmail.ValidateRequired("ContactEmail");
     PreferredCulture.ValidateRequired("PreferredCulture");
     PreferredUICulture.ValidateOptional("PreferredUICulture");
     Location.ValidateOptional("Location");
 }
        private static Contact CreatePlaceholderContact()
        {
            // Create contact object with small set of initial data to display.
            Contact contact = new Contact();
            contact.FirstName = "Kim";
            contact.LastName = "Abercrombie";

            ContactEmail email = new ContactEmail();
            email.Address = "*****@*****.**";
            contact.Emails.Add(email);

            return contact;
        }
 private void BindAdvanceDetails(ContactEmail objEmail)
 {
     divBody.InnerHtml = objEmail.Body;
     //attachments
     if (objEmail.HasAttachments)
     {
         lblAttachmentCount.Text = objEmail.Attachments.Count.ToString();
         // objEmail.Attachments.First().RefId
         rptAttachment.DataSource = objEmail.Attachments;
         rptAttachment.DataBind();
     }
     else
         divAttachment.Visible = false;
 }
        /// <summary>
        /// This is the click handler for the 'Show contact card' button.  
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowContactCardButton_Click(object sender, RoutedEventArgs e)
        {
            if ((this.EmailAddress.Text.Length == 0) && (this.PhoneNumber.Text.Length == 0))
            {
                this.rootPage.NotifyUser("You must enter an email address and/or phone number of the contact for the system to search and show the contact card.", NotifyType.ErrorMessage);
            }
            else
            {
                Contact contact = new Contact();
                if (this.EmailAddress.Text.Length > 0)
                {
                    if (this.EmailAddress.Text.Length <= MAX_EMAIL_ADDRESS_LENGTH)
                    {
                        ContactEmail email = new ContactEmail();
                        email.Address = this.EmailAddress.Text;
                        contact.Emails.Add(email);
                    }
                    else
                    {
                        this.rootPage.NotifyUser("The email address you entered is too long.", NotifyType.ErrorMessage);
                        return;
                    }
                }

                if (this.PhoneNumber.Text.Length > 0)
                {
                    if (this.PhoneNumber.Text.Length <= MAX_PHONE_NUMBER_LENGTH)
                    {
                        ContactPhone phone = new ContactPhone();
                        phone.Number = this.PhoneNumber.Text;
                        contact.Phones.Add(phone);
                    }
                    else
                    {
                        this.rootPage.NotifyUser("The phone number you entered is too long.", NotifyType.ErrorMessage);
                        return;
                    }
                }

                // Get the selection rect of the button pressed to show contact card.
                Rect rect = Helper.GetElementRect(sender as FrameworkElement);

                ContactManager.ShowContactCard(contact, rect, Windows.UI.Popups.Placement.Default);
                this.rootPage.NotifyUser("ContactManager.ShowContactCard() was called.", NotifyType.StatusMessage);
            }
        }
        /// <summary>
        /// Create and send an activation email for a service subscription.
        /// </summary>
        /// <param name="serviceName">The name of the service being subscribed to</param>
        /// <param name="fromAddress">The address to send the email from.</param>
        /// <param name="subscriberAddress">The subscriber address.</param>
        /// <param name="activationUrl">The activation URL, including a {0} token to be replaced by the activation code.</param>
        /// <param name="activationCode">The code which must be supplied to activate the subscription</param>
        public static void SendActivationEmail(string serviceName, ContactEmail fromAddress, ContactEmail subscriberAddress, Uri activationUrl, string activationCode)
        {
            // get email body and replace variables
            StringBuilder body = new StringBuilder(Resources.ActivationEmailBody);
            body.Replace("{ServiceName}", serviceName);
            body.Replace("{Activation URL}", String.Format(activationUrl.ToString(), activationCode));
            body.Replace("{Email address}", subscriberAddress.EmailAddress);

            // build the email
            MailMessage message = new MailMessage();
            message.To.Add(new MailAddress(subscriberAddress.EmailAddress, subscriberAddress.DisplayName));
            message.From = new MailAddress(fromAddress.EmailAddress, fromAddress.DisplayName);
            message.Subject = String.Format(Resources.ActivationEmailSubject, serviceName);
            message.IsBodyHtml = false;
            message.Body = body.ToString();

            SmtpClient client = new SmtpClient();
            client.Send(message);
        }
        private async Task<Contact> DownloadContactDataAsync(Contact contact)
        {
            // Simulate the download latency by delaying the execution by 2 seconds.
            await Task.Delay(2000);

            if (!DownloadSucceeded.IsChecked.Value)
            {
                return null;
            }

            // Add more data to the contact object.
            ContactEmail workEmail = new ContactEmail();
            workEmail.Address = "*****@*****.**";
            workEmail.Kind = ContactEmailKind.Work;
            contact.Emails.Add(workEmail);

            ContactPhone homePhone = new ContactPhone();
            homePhone.Number = "(444) 555-0101";
            homePhone.Kind = ContactPhoneKind.Home;
            contact.Phones.Add(homePhone);

            ContactPhone workPhone = new ContactPhone();
            workPhone.Number = "(245) 555-0123";
            workPhone.Kind = ContactPhoneKind.Work;
            contact.Phones.Add(workPhone);

            ContactPhone mobilePhone = new ContactPhone();
            mobilePhone.Number = "(921) 555-0187";
            mobilePhone.Kind = ContactPhoneKind.Mobile;
            contact.Phones.Add(mobilePhone);

            ContactAddress address = new ContactAddress();
            address.StreetAddress = "123 Main St";
            address.Locality = "Redmond";
            address.Region = "WA";
            address.Country = "USA";
            address.PostalCode = "00000";
            address.Kind = ContactAddressKind.Home;
            contact.Addresses.Add(address);

            return contact;
        }
        /// <summary>
        /// This is the click handler for the 'Show contact card with delayed data loader' button.  
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ShowContactCardDelayLoadButton_Click(object sender, RoutedEventArgs e)
        {
            // Create contact object with small set of initial data to display.
            Contact contact = new Contact();
            contact.FirstName = "Kim";
            contact.LastName = "Abercrombie";

            ContactEmail email = new ContactEmail();
            email.Address = "*****@*****.**";
            contact.Emails.Add(email);

            // Get the selection rect of the button pressed to show contact card.
            Rect rect = Helper.GetElementRect(sender as FrameworkElement);
            using (ContactCardDelayedDataLoader dataLoader = ContactManager.ShowDelayLoadedContactCard(
                contact, 
                rect,
                Windows.UI.Popups.Placement.Below // The contact card placement can change when it is updated with more data. For improved user experience, specify placement 
                                                  // of the card so that it has space to grow and will not need to be repositioned. In this case, default placement first places 
                                                  // the card above the button because the card is small, but after the card is updated with more data, the operating system moves 
                                                  // the card below the button to fit the card's expanded size. Specifying that the contact card is placed below at the beginning 
                                                  // avoids this repositioning.
                ))
            {
                string message = "ContactManager.ShowDelayLoadedContactCard() was called.\r\n";
                this.rootPage.NotifyUser(message, NotifyType.StatusMessage);

                // Simulate downloading more data from the network for the contact.
                message += "Downloading data ...\r\n";
                this.rootPage.NotifyUser(message, NotifyType.StatusMessage);

                Contact fullContact = await DownloadContactDataAsync(contact);
                if (fullContact != null)
                {
                    // We get more data - update the contact card with the full set of contact data.
                    dataLoader.SetData(fullContact);

                    message += "ContactCardDelayedDataLoader.SetData() was called.\r\n";
                    this.rootPage.NotifyUser(message, NotifyType.StatusMessage);
                }
            }
        }
        /// <summary>
        /// Adds a contact to ContactPickerUI.
        /// </summary>
        /// <param name="sampleContact">Sample contact to add</param>
        private void AddSampleContact(SampleContact sampleContact)
        {
            Contact contact = new Contact();
            contact.Id = sampleContact.Id;
            contact.FirstName = sampleContact.FirstName;
            contact.LastName = sampleContact.LastName;

            if (!string.IsNullOrEmpty(sampleContact.HomeEmail))
            {
                ContactEmail homeEmail = new ContactEmail();
                homeEmail.Address = sampleContact.HomeEmail;
                homeEmail.Kind = ContactEmailKind.Personal;
                contact.Emails.Add(homeEmail);
            }

            if (!string.IsNullOrEmpty(sampleContact.WorkEmail))
            {
                ContactEmail workEmail = new ContactEmail();
                workEmail.Address = sampleContact.WorkEmail;
                workEmail.Kind = ContactEmailKind.Work;
                contact.Emails.Add(workEmail);
            }

            if (!string.IsNullOrEmpty(sampleContact.HomePhone))
            {
                ContactPhone homePhone = new ContactPhone();
                homePhone.Number = sampleContact.HomePhone;
                homePhone.Kind = ContactPhoneKind.Home;
                contact.Phones.Add(homePhone);
            }

            if (!string.IsNullOrEmpty(sampleContact.MobilePhone))
            {
                ContactPhone mobilePhone = new ContactPhone();
                mobilePhone.Number = sampleContact.MobilePhone;
                mobilePhone.Kind = ContactPhoneKind.Mobile;
                contact.Phones.Add(mobilePhone);
            }

            if (!string.IsNullOrEmpty(sampleContact.WorkPhone))
            {
                ContactPhone workPhone = new ContactPhone();
                workPhone.Number = sampleContact.WorkPhone;
                workPhone.Kind = ContactPhoneKind.Work;
                contact.Phones.Add(workPhone);
            }

            switch (this.contactPickerUI.AddContact(contact))
            {
                case AddContactResult.Added:
                    // Notify the user that the contact was added
                    OutputText.Text = contact.DisplayName + " was added to the basket";
                    break;
                case AddContactResult.AlreadyAdded:
                    // Notify the user that the contact is already added
                    OutputText.Text = contact.DisplayName + " is already in the basket";
                    break;
                case AddContactResult.Unavailable:
                default:
                    // Notify the user that the basket is unavailable
                    OutputText.Text = contact.DisplayName + " could not be added to the basket";
                    break;
            }
        }
Example #40
0
		public void FillProviderCreatedItem(Microsoft.Communications.Contacts.Contact contact, Microsoft.LiveFX.Client.Contact c)
		{
			if (c == null) return;

			c.Resource.FamilyName = contact.Names[0].FamilyName;
			c.Resource.MiddleName = contact.Names[0].MiddleName;
			c.Resource.GivenName = contact.Names[0].GivenName;

			//foreach (PhoneNumber pn in contact.PhoneNumbers)
			{
				
				if (contact.PhoneNumbers[PhoneLabels.Cellular] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Mobile;
					cp.Value = contact.PhoneNumbers[PhoneLabels.Cellular].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}

				if (contact.PhoneNumbers[PropertyLabels.Personal] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Personal;
					cp.Value = contact.PhoneNumbers[PropertyLabels.Personal].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}
				
				if (contact.PhoneNumbers[PropertyLabels.Business] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Business;
					cp.Value = contact.PhoneNumbers[PropertyLabels.Business].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}
				
				if (contact.PhoneNumbers[PhoneLabels.Fax] != null)
				{
					ContactPhone cp = new ContactPhone();
					cp.Type = ContactPhone.ContactPhoneType.Fax;
					cp.Value = contact.PhoneNumbers[PhoneLabels.Fax].Number;
					c.Resource.PhoneNumbers.Add(cp);
				}

			}

			if (contact.Positions["Business"] != null)
			{
				c.Resource.JobTitle = contact.Positions["Business"].JobTitle;
			}

			
			if (contact.EmailAddresses.Count > 0)
			{
				ContactEmail ce = new ContactEmail();	
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[0].Address;
				c.Resource.Emails.Add(ce);
			}
			if (contact.EmailAddresses.Count > 1)
			{
				ContactEmail ce = new ContactEmail();
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[1].Address;
				c.Resource.Emails.Add(ce);
			}
			if (contact.EmailAddresses.Count > 2)
			{
				ContactEmail ce = new ContactEmail();
				ce.Type = ContactEmail.ContactEmailType.Personal;
				ce.Value = contact.EmailAddresses[2].Address;
				c.Resource.Emails.Add(ce);
			}
		}
    private bool ProcessMailItem(ContactEmail mItem)
    {
        try
        {
            var objEx = new ExchangeProcessor();
            EmailMessage message = null;
            var service = objEx.CreateExchangeConnection();

            if (service != null)
            {
                try
                {

                    //get the message from unique id
                    if (!string.IsNullOrEmpty(mItem.ExchangeUniqueId))
                    {
                        message = objEx.GetMailItemByUniqueId(ref service, mItem.ExchangeUniqueId) as EmailMessage;
                    }
                }
                catch (Exception)
                {
                    //ignore
                }

                if (message != null)
                {
                    var body = message.Body;
                    if (message.HasAttachments)
                    {
                        // create directory to save the attachments
                        var attDir = objEx.MailBoxFolderPath + mItem.EmailId + "\\";
                        //delete the directory if exists
                        if (Directory.Exists(attDir))
                            Directory.Delete(attDir, true);
                        //create the directory
                        if (!Directory.Exists(attDir))
                            Directory.CreateDirectory(attDir);

                        //create attachments
                        foreach (var attachment in message.Attachments)
                        {
                            try
                            {
                                if (attachment is FileAttachment)
                                {
                                    var fileAttachment = attachment as FileAttachment;

                                    //Stream attachment contents into a file.
                                    var theStream = new FileStream(attDir + fileAttachment.Name, FileMode.OpenOrCreate,
                                        FileAccess.ReadWrite);
                                    fileAttachment.Load(theStream);
                                    theStream.Close();
                                    theStream.Dispose();
                                }
                            }
                            catch (ServiceRequestException)
                            {
                                //ignore
                            }
                            catch (ServiceResponseException)
                            {
                                //ignore
                            }
                        }
                    }
                    // done message has been successfully downloaded
                    // fully synced - update the sync field 
                    Emails.UpdateEmail(mItem.EmailId, message.HasAttachments, body);
                    return true;
                }
                return false;
            }
            return false;
        }
        catch (ServiceResponseException)
        {
            return false;
        }
    }
        private async void CreateTestContacts()
        {
            //
            // Creating two test contacts with email address and phone number.
            //

            Contact contact1 = new Contact();
            contact1.FirstName = "TestContact1";

            ContactEmail email1 = new ContactEmail();
            email1.Address = "*****@*****.**";
            contact1.Emails.Add(email1);

            ContactPhone phone1 = new ContactPhone();
            phone1.Number = "4255550100";
            contact1.Phones.Add(phone1);

            Contact contact2 = new Contact();
            contact2.FirstName = "TestContact2";

            ContactEmail email2 = new ContactEmail();
            email2.Address = "*****@*****.**";
            email2.Kind = ContactEmailKind.Other;
            contact2.Emails.Add(email2);

            ContactPhone phone2 = new ContactPhone();
            phone2.Number = "4255550101";
            phone2.Kind = ContactPhoneKind.Mobile;
            contact2.Phones.Add(phone2);

            // Save the contacts
            ContactList contactList = await _GetContactList();
            if (null == contactList)
            {
                return;
            }

            await contactList.SaveContactAsync(contact1);
            await contactList.SaveContactAsync(contact2);

            //
            // Create annotations for those test contacts.
            // Annotation is the contact meta data that allows People App to generate deep links
            // in the contact card that takes the user back into this app.
            //

            ContactAnnotationList annotationList = await _GetContactAnnotationList();
            if (null == annotationList)
            {
                return;
            }

            ContactAnnotation annotation = new ContactAnnotation();
            annotation.ContactId = contact1.Id;

            // Remote ID: The identifier of the user relevant for this app. When this app is
            // launched into from the People App, this id will be provided as context on which user
            // the operation (e.g. ContactProfile) is for.
            annotation.RemoteId = "user12";

            // The supported operations flags indicate that this app can fulfill these operations
            // for this contact. These flags are read by apps such as the People App to create deep
            // links back into this app. This app must also be registered for the relevant
            // protocols in the Package.appxmanifest (in this case, ms-contact-profile).
            annotation.SupportedOperations = ContactAnnotationOperations.ContactProfile;

            if (!await annotationList.TrySaveAnnotationAsync(annotation))
            {
                rootPage.NotifyUser("Failed to save annotation for TestContact1 to the store.", NotifyType.ErrorMessage);
                return;
            }

            annotation = new ContactAnnotation();
            annotation.ContactId = contact2.Id;
            annotation.RemoteId = "user22";

            // You can also specify multiple supported operations for a contact in a single
            // annotation. In this case, this annotation indicates that the user can be
            // communicated via VOIP call, Video Call, or IM via this application.
            annotation.SupportedOperations = ContactAnnotationOperations.Message |
                ContactAnnotationOperations.AudioCall |
                ContactAnnotationOperations.VideoCall;

            if (!await annotationList.TrySaveAnnotationAsync(annotation))
            {
                rootPage.NotifyUser("Failed to save annotation for TestContact2 to the store.", NotifyType.ErrorMessage);
                return;
            }

            rootPage.NotifyUser("Sample data created successfully.", NotifyType.StatusMessage);
        }
Example #43
0
 /// <summary>
 /// Utility method to convert email information from the vCard library to a
 /// WinRT ContactEmail instance.
 /// No 1:1 matching is possible between both classes, the method tries to
 /// keep the conversion as accurate as possible.
 /// </summary>
 /// <param name="email">Email information from the vCard library.</param>
 /// <returns>The email information from the vCard library converted to a 
 /// WinRT ContactEmail instance.</returns>
 private ContactEmail ConvertVcardToEmail(vCardEmailAddress email)
 {
     var ce = new ContactEmail
     {
         Address = email.Address,
         Kind = ContactEmailKind.Other   // No useful types supported by vCard library
     };
     return ce;
 }
Example #44
0
        private void HandleContactClicked(AttendeeViewModel attendee)
        {
            var contact = new Windows.ApplicationModel.Contacts.Contact();

            contact.YomiGivenName = attendee.User.Name;
            contact.Name = attendee.User.Name;

            ContactEmail workEmail = new ContactEmail();
            workEmail.Address = attendee.User.Email;
            workEmail.Kind = ContactEmailKind.Work;
            contact.Emails.Add(workEmail);

            // Try to share the screen half/half with the full contact card.
            FullContactCardOptions options = new FullContactCardOptions();
            options.DesiredRemainingView = ViewSizePreference.UseHalf;

            // Show the full contact card.
            ContactManager.ShowFullContactCard(contact, options);
        }
Example #45
0
        private void BtnWriteBusinessCard_Click(object sender, RoutedEventArgs e)
        {
            var contact = new Contact
            {
                FirstName = "Andreas",
                LastName = "Jakl"
            };
            // Add the personal email address to the Contact object’s emails vector
            var personalEmail = new ContactEmail { Address = "*****@*****.**", Kind = ContactEmailKind.Work };
            contact.Emails.Add(personalEmail);

            // Adds the home phone number to the Contact object’s phones vector
            var homePhone = new ContactPhone { Number = "+1234", Kind = ContactPhoneKind.Home };
            contact.Phones.Add(homePhone);

            // Adds the address to the Contact object’s addresses vector
            var workAddress = new ContactAddress
            {
                StreetAddress = "Street 1",
                Locality = "Vienna",
                Region = "Austria",
                PostalCode = "1234",
                Kind = ContactAddressKind.Work
            };
            contact.Addresses.Add(workAddress);

            contact.Websites.Add(new ContactWebsite { Uri = new Uri("http://www.nfcinteractor.com/") });

            contact.JobInfo.Add(new ContactJobInfo
            {
                CompanyName = "Andreas Jakl",
                Title = "Mobility Evangelist"
            });
            contact.Notes = "Developer of the NFC Library";

            //var record = new NdefVcardRecord(contact);

            //// Publish the record using the proximity device
            //PublishRecord(record, true);
        }