Ejemplo n.º 1
0
    private void add()
    {
        try
        {
            //Create Message
            Mailee.Message message = new Mailee.Message();
            message.Title = txTitle.Text;
            message.Subject = txtSubject.Text;
            message.FromName = txtFromName.Text;
            message.FromEmail = txtFromEmail.Text;
            message.ReplyEmail = txtReplyEmail.Text;
            message.Html = txtHtml.Text;
            message.TemplateId = Mailee.Util.parseInt(drpTemplate.SelectedValue);
            message.Analytics = chkAnalytics.Checked;
            message.Emails = txtEmails.Text;
            message.ListId = Mailee.Util.parseInt(drpLists.SelectedValue);
            message.SegmentId = Mailee.Util.parseInt(txtSegment.Text);

            //Save Message
            message.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);
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Find Message by ID
        /// </summary>
        /// <param name="id">Message ID</param>
        public static Mailee.Message findById(int id)
        {
            Mailee.Message message = new Mailee.Message();

            //Validation
            if (id == 0)
                return message;

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

            //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 Message
                XmlNodeList xmlMessages = xmlDoc.GetElementsByTagName("message");

                if (xmlMessages.Count > 0)
                {
                    XmlNode xmlMessage = xmlMessages[0];

                    //Set properties
                    message.Analytics = Mailee.Util.parseBool(xmlMessage.ChildNodes[0].InnerText);
                    message.Checkd = Mailee.Util.parseBool(xmlMessage.ChildNodes[1].InnerText);
                    message.ClientId = Mailee.Util.parseInt(xmlMessage.ChildNodes[2].InnerText);
                    message.ContentFrom = Mailee.Util.parseInt(xmlMessage.ChildNodes[3].InnerText);
                    message.CreatedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[4].InnerText);
                    message.DeletedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[5].InnerText);
                    message.FromEmail = xmlMessage.ChildNodes[6].InnerText;
                    message.FromName = xmlMessage.ChildNodes[7].InnerText;
                    message.Html = xmlMessage.ChildNodes[8].InnerText;
                    message.HtmlFromUrl = xmlMessage.ChildNodes[9].InnerText;
                    message.Id = Mailee.Util.parseInt(xmlMessage.ChildNodes[10].InnerText);
                    message.ListId = Mailee.Util.parseInt(xmlMessage.ChildNodes[11].InnerText);
                    message.Log = xmlMessage.ChildNodes[12].InnerText;
                    message.NewsletterId = Mailee.Util.parseInt(xmlMessage.ChildNodes[13].InnerText);
                    message.ReplyEmail = xmlMessage.ChildNodes[14].InnerText;
                    message.RSS = xmlMessage.ChildNodes[15].InnerText;
                    message.SegmentId = Mailee.Util.parseInt(xmlMessage.ChildNodes[16].InnerText);
                    message.SendAfter = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[17].InnerText);
                    message.SendWhen = xmlMessage.ChildNodes[18].InnerText;
                    message.Status = Mailee.Util.parseInt(xmlMessage.ChildNodes[19].InnerText);
                    message.Subject = xmlMessage.ChildNodes[20].InnerText;
                    message.TemplateId = Mailee.Util.parseInt(xmlMessage.ChildNodes[21].InnerText);
                    message.Text = xmlMessage.ChildNodes[22].InnerText;
                    message.ThumbContentType = xmlMessage.ChildNodes[23].InnerText;
                    message.ThumbFileName = xmlMessage.ChildNodes[24].InnerText;
                    message.ThumbFileSize = Mailee.Util.parseInt(xmlMessage.ChildNodes[25].InnerText);
                    message.ThumbUpdatedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[26].InnerText);
                    message.Title = xmlMessage.ChildNodes[27].InnerText;
                    message.Total = Mailee.Util.parseInt(xmlMessage.ChildNodes[28].InnerText);
                    message.Url = xmlMessage.ChildNodes[29].InnerText;
                }

            }

            return message;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Find all Messages
        /// </summary>
        public static List<Mailee.Message> findAll()
        {
            List<Mailee.Message> messages = new List<Mailee.Message>();

            //URL (GET) (api.XXXXXXXXXXXXX.subdomain.mailee.me/messages)
            string url = string.Concat(Mailee.Config.UrlAPI, "messages.xml");

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

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

            //Load XML
            xmlDoc.LoadXml(htmlReponse);

            //Get Messagess
            XmlNodeList xmlMessages = xmlDoc.GetElementsByTagName("message");

            //Each Messages
            foreach (XmlNode xmlMessage in xmlMessages)
            {
                //Create new Message
                Mailee.Message newMessage = new Mailee.Message();

                //Set properties
                newMessage.Analytics = Mailee.Util.parseBool(xmlMessage.ChildNodes[0].InnerText);
                newMessage.CreatedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[1].InnerText);
                newMessage.DeletedAt = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[2].InnerText);
                newMessage.FromEmail = xmlMessage.ChildNodes[3].InnerText;
                newMessage.FromName = xmlMessage.ChildNodes[4].InnerText;
                newMessage.Id = Mailee.Util.parseInt(xmlMessage.ChildNodes[5].InnerText);
                //newMessage.ListId = Mailee.Util.parseInt(xmlMessage.ChildNodes[6].InnerText);
                newMessage.Log = xmlMessage.ChildNodes[6].InnerText;
                newMessage.NewsletterId = Mailee.Util.parseInt(xmlMessage.ChildNodes[7].InnerText);
                newMessage.ReplyEmail = xmlMessage.ChildNodes[8].InnerText;
                newMessage.SegmentId = Mailee.Util.parseInt(xmlMessage.ChildNodes[9].InnerText);
                newMessage.SendAfter = Mailee.Util.parseDateTime(xmlMessage.ChildNodes[10].InnerText);
                newMessage.SendWhen = xmlMessage.ChildNodes[11].InnerText;
                newMessage.Status = Mailee.Util.parseInt(xmlMessage.ChildNodes[12].InnerText);
                newMessage.Subject = xmlMessage.ChildNodes[13].InnerText;
                newMessage.TemplateId = Mailee.Util.parseInt(xmlMessage.ChildNodes[14].InnerText);
                newMessage.Title = xmlMessage.ChildNodes[15].InnerText;
                newMessage.Total = Mailee.Util.parseInt(xmlMessage.ChildNodes[16].InnerText);

                //Add Message
                messages.Add(newMessage);
            }

            return messages;
        }