protected void btUnsubscribeContact_Click(object sender, EventArgs e)
    {
        ///Contact ID
        int contactId = Mailee.Util.parseInt(Request.QueryString["id"]);

        //Unsubscribe
        try
        {
            //Fill Contact
            Mailee.Contact contact = new Mailee.Contact(contactId);

            //Unsubscribe contact
            contact.Unsubscribe();

            //Redirect
            Response.Redirect("View.aspx");
        }
        catch (Mailee.RestExcepction ex)
        {
            //Show http status
            Response.Write(string.Format("statusCode =  {0} <br /> statusDescription = {1}", ex.StatusCode, ex.StatusDesciption));

            //Show error messages
            foreach (string error in ex.ErrorMessages)
                Response.Write("<br />" + error);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Exemplo n.º 2
0
    private void add()
    {
        try
        {
            //Create Contact
            Mailee.Contact contact = new Mailee.Contact();
            contact.Email = txtEmail.Text;
            contact.Name = txtName.Text;
            contact.InternalId = Mailee.Util.parseInt(txtInternalId.Text);
            contact.Company = txtCompany.Text;
            contact.Position = txtPosition.Text;
            contact.Sex = txtSex.Text;
            contact.Birthday = Mailee.Util.parseDateTime(txtBirthday.Text);
            contact.Age = Mailee.Util.parseInt(txtAge.Text);
            contact.Phone = txtPhone.Text;
            contact.Mobile = txtMobile.Text;
            contact.Address = txtAddress.Text;
            contact.Notes = txtNotes.Text;

            //Save Contact
            contact.save();

            //Redirect
            Response.Redirect("View.aspx");

        }
        catch (Mailee.RestExcepction ex)
        {
            //Show http status
            Response.Write(string.Format("statusCode =  {0} <br /> statusDescription = {1}", ex.StatusCode, ex.StatusDesciption));

            //Show error messages
            foreach (string error in ex.ErrorMessages)
                Response.Write("<br />" + error);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Find Contact by Internal ID
        /// </summary>
        /// <param name="internalId">Contact ID</param>
        public static Mailee.Contact findByInternalId(int internalId)
        {
            Mailee.Contact contact = new Mailee.Contact();

            //Validation
            if (internalId == 0)
                return contact;

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts.xml?internal_id=X)
            string url = string.Format("{0}contacts.xml?internal_id={1}", Mailee.Config.UrlAPI, internalId);

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Checks if the xml is valid
            bool isValidXml = Mailee.Util.IsValidXML(htmlReponse);

            if (isValidXml == true)
            {
                //Create XML
                XmlDocument xmlDoc = new XmlDocument();

                //Load XML
                xmlDoc.LoadXml(htmlReponse);

                //Get Contact
                XmlNodeList xmlContacts = xmlDoc.GetElementsByTagName("contact");

                if (xmlContacts.Count > 0)
                {
                    XmlNode xmlContact = xmlContacts[0];

                    //Set properties
                    contact.Address = xmlContact.ChildNodes[0].InnerText;
                    contact.Age = Mailee.Util.parseInt(xmlContact.ChildNodes[1].InnerText);
                    contact.Birthday = Mailee.Util.parseDateTime(xmlContact.ChildNodes[2].InnerText);
                    contact.ClientId = Mailee.Util.parseInt(xmlContact.ChildNodes[3].InnerText);
                    contact.Company = xmlContact.ChildNodes[4].InnerText;
                    contact.ContactStatusId = Mailee.Util.parseInt(xmlContact.ChildNodes[5].InnerText);
                    contact.CreatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[6].InnerText);
                    contact.DeletedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[7].InnerText);
                    //contact.DynamicValues = xmlContact.ChildNodes[8].InnerText;
                    contact.Email = xmlContact.ChildNodes[9].InnerText;
                    contact.FacebookFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[10].InnerText);
                    contact.ForwardedBy = Mailee.Util.parseInt(xmlContact.ChildNodes[11].InnerText);
                    contact.GoodreadsConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[12].InnerText);
                    contact.Id = Mailee.Util.parseInt(xmlContact.ChildNodes[13].InnerText);
                    contact.ImportId = Mailee.Util.parseInt(xmlContact.ChildNodes[14].InnerText);
                    contact.InternalId = Mailee.Util.parseInt(xmlContact.ChildNodes[15].InnerText);
                    contact.Kscore = Mailee.Util.parseFloat(xmlContact.ChildNodes[16].InnerText);
                    contact.Latitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[17].InnerText);
                    contact.LinkedinFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[18].InnerText);
                    contact.LinkedinRecomendations = Mailee.Util.parseInt(xmlContact.ChildNodes[19].InnerText);
                    contact.Longitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[20].InnerText);
                    contact.Mobile = xmlContact.ChildNodes[21].InnerText;
                    contact.Name = xmlContact.ChildNodes[22].InnerText;
                    contact.Notes = xmlContact.ChildNodes[23].InnerText;
                    contact.OriginId = Mailee.Util.parseInt(xmlContact.ChildNodes[24].InnerText);
                    contact.OrkutFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[25].InnerText);
                    contact.Phone = xmlContact.ChildNodes[26].InnerText;
                    contact.PhotoContentType = xmlContact.ChildNodes[27].InnerText;
                    contact.PhotoFileName = xmlContact.ChildNodes[28].InnerText;
                    contact.PhotoFileSize = Mailee.Util.parseInt(xmlContact.ChildNodes[29].InnerText);
                    contact.PhotoUpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[30].InnerText);
                    contact.PlaxoConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[31].InnerText);
                    contact.Position = xmlContact.ChildNodes[32].InnerText;
                    contact.Sex = xmlContact.ChildNodes[33].InnerText;
                    contact.SkoobConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[34].InnerText);
                    contact.TwitterFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[35].InnerText);
                    contact.UpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[36].InnerText);
                }

            }

            return contact;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Find all Contacts with pagination
        /// </summary>
        /// <param name="page">Page</param>
        public static List<Mailee.Contact> findAll(int page)
        {
            List<Mailee.Contact> contacts = new List<Mailee.Contact>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/contacts)
            string url = string.Format("{0}contacts.xml?page={1}", Mailee.Config.UrlAPI, page);

            //Get data
            string htmlReponse = Mailee.Rest.get(url);

            //Create XML
            XmlDocument xmlDoc = new XmlDocument();

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Contacts
            XmlNodeList xmlContacts = xmlDoc.GetElementsByTagName("contact");

            //Each Contacts
            foreach (XmlNode xmlContact in xmlContacts)
            {
                //Create new Concat
                Mailee.Contact newContact = new Mailee.Contact();

                //Set properties
                newContact.Address = xmlContact.ChildNodes[0].InnerText;
                newContact.Age = Mailee.Util.parseInt(xmlContact.ChildNodes[1].InnerText);
                newContact.Birthday = Mailee.Util.parseDateTime(xmlContact.ChildNodes[2].InnerText);
                newContact.ClientId = Mailee.Util.parseInt(xmlContact.ChildNodes[3].InnerText);
                newContact.Company = xmlContact.ChildNodes[4].InnerText;
                newContact.ContactStatusId = Mailee.Util.parseInt(xmlContact.ChildNodes[5].InnerText);
                newContact.CreatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[6].InnerText);
                newContact.DeletedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[7].InnerText);
                //contact.DynamicValues = xmlContact.ChildNodes[8].InnerText;
                newContact.Email = xmlContact.ChildNodes[9].InnerText;
                newContact.FacebookFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[10].InnerText);
                newContact.ForwardedBy = Mailee.Util.parseInt(xmlContact.ChildNodes[11].InnerText);
                newContact.GoodreadsConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[12].InnerText);
                newContact.Id = Mailee.Util.parseInt(xmlContact.ChildNodes[13].InnerText);
                newContact.ImportId = Mailee.Util.parseInt(xmlContact.ChildNodes[14].InnerText);
                newContact.InternalId = Mailee.Util.parseInt(xmlContact.ChildNodes[15].InnerText);
                newContact.Kscore = Mailee.Util.parseFloat(xmlContact.ChildNodes[16].InnerText);
                newContact.Latitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[17].InnerText);
                newContact.LinkedinFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[18].InnerText);
                newContact.LinkedinRecomendations = Mailee.Util.parseInt(xmlContact.ChildNodes[19].InnerText);
                newContact.Longitude = Mailee.Util.parseDecimal(xmlContact.ChildNodes[20].InnerText);
                newContact.Mobile = xmlContact.ChildNodes[21].InnerText;
                newContact.Name = xmlContact.ChildNodes[22].InnerText;
                newContact.Notes = xmlContact.ChildNodes[23].InnerText;
                newContact.OriginId = Mailee.Util.parseInt(xmlContact.ChildNodes[24].InnerText);
                newContact.OrkutFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[25].InnerText);
                newContact.Phone = xmlContact.ChildNodes[26].InnerText;
                newContact.PhotoContentType = xmlContact.ChildNodes[27].InnerText;
                newContact.PhotoFileName = xmlContact.ChildNodes[28].InnerText;
                newContact.PhotoFileSize = Mailee.Util.parseInt(xmlContact.ChildNodes[29].InnerText);
                newContact.PhotoUpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[30].InnerText);
                newContact.PlaxoConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[31].InnerText);
                newContact.Position = xmlContact.ChildNodes[32].InnerText;
                newContact.Sex = xmlContact.ChildNodes[33].InnerText;
                newContact.SkoobConnections = Mailee.Util.parseInt(xmlContact.ChildNodes[34].InnerText);
                newContact.TwitterFollowers = Mailee.Util.parseInt(xmlContact.ChildNodes[35].InnerText);
                newContact.UpdatedAt = Mailee.Util.parseDateTime(xmlContact.ChildNodes[36].InnerText);

                //Add Contact
                contacts.Add(newContact);
            }

            return contacts;
        }