예제 #1
0
        private void SendApprovalEmail(Page record)
        {
            Person toPerson = Person.LoadByPersonID((int)record.RequestApprovalForPersonID);

            var email = new ElectronicMail();

            email.ToAddress = toPerson.Email;

            var textBlock = new Beweb.TextBlock("Email: Page Approval Request", "Page Approval Request",
                                                @"Dear [--publisherName--],

[--editorName--] requested approval on a page. Please click [--url--] to review.

Thanks.");

            email.Subject = textBlock.Title;

            var body = textBlock.RawBody;

            body = body.Replace("[--publisherName--]", toPerson.FirstName);
            body = body.Replace("[--editorName--]", UserSession.Person.FirstName);
            body = body.Replace("[--url--]", record.GetAdminFullUrl());

            email.FromAddress = Util.GetSetting("EmailFromAddress", "*****@*****.**");
            email.BodyPlain   = body;
            email.Send(true);
        }
예제 #2
0
        public void Unsubscribe(string refID)
        {
            //get member ref
            string url = "/database/contacts/" + refID;

            var collection = new WebHeaderCollection();

            collection.Add("Authorization", string.Format("Engage {0}", APIToken));
            var obj = new {
                ReferenceID = refID,
                Data        = new object[] {
                    new {
                        FieldID = GetFieldID("Opted Out"),
                        Name    = "Opted Out",
                        Value   = "true"
                    },
                    new {
                        FieldID = GetFieldID("Email Permission"),
                        Name    = "Email Permission",
                        Value   = "false"
                    }
                },
                ItemXml    = (string)null,
                Source     = (string)null,
                FormAction = (string)null
            };

            try {
                var response = Http.Request(Http.PUT, "https://api.ubiquity.co.nz" + url, new JsonSerializer().Serialize(obj), collection);
            } catch (Exception e) {
                var email = new ElectronicMail();
                email.Subject = "Engage Error - Unsubscribing member " + refID;
                string body = "";
                body             += @"
	ReferenceID: "     + refID + @"
	Action Taken: Unsubscribing"     + @"
	Errors as follows: "     + e.Message + @"
	Data:
	"     + new JsonSerializer().Serialize(obj);
                email.BodyPlain   = body;
                email.ToAddress   = "*****@*****.**";
                email.FromAddress = SendEMail.EmailFromAddress;
                email.FromName    = SendEMail.EmailFromName;
                email.Send(false);
            }
        }