Example #1
0
        private void SendFeedErrorEmail(Feed feed, Exception ex)
        {
            String emailBodyTxt = TextBlockCache.Get("FeedError", @"
Hello Herepin Admin,
	
	An error has occurred while scrapping [--FeedType--] Feed.
	
	Error details:
	[--ErrorMessage--]
	[--FeedURL--]

	<a href='[--RunFeedURL--]'>Run feed</a> | <a href='[--EditFeedURL--]'>Edit feed</a>

			"            ).BodyTextHtml;

            emailBodyTxt = emailBodyTxt.Replace("[--FeedType--]", feed.FeedType);
            emailBodyTxt = emailBodyTxt.Replace("[--ErrorMessage--]", ex.Message);
            emailBodyTxt = emailBodyTxt.Replace("[--FeedURL--]", feed.FeedUrl);
            emailBodyTxt = emailBodyTxt.Replace("[--RunFeedURL--]", Web.BaseUrl + "ScheduledTask/RunFeed?feedID=" + feed.FeedID);
            emailBodyTxt = emailBodyTxt.Replace("[--EditFeedURL--]", Web.BaseUrl + "Admin/FeedAdmin/Edit/" + feed.FeedID);
            emailBodyTxt = emailBodyTxt.Replace("\r\n", "<br>");

            if (Util.ServerIsDev)
            {
                SendEMail.SimpleSendHtmlEmail("*****@*****.**", "Herepin Feed error", emailBodyTxt);
            }
            else
            {
                SendEMail.SimpleSendHtmlEmail(Util.GetSetting("EmailToAddress", "localhost"), "Herepin Feed error", emailBodyTxt);
                SendEMail.SimpleSendHtmlEmail("*****@*****.**", "Herepin Feed error", emailBodyTxt);
                SendEMail.SimpleSendHtmlEmail("*****@*****.**", "Herepin Feed error", emailBodyTxt);
            }
        }
Example #2
0
        private static void SendEmail(string address, string subject, string heading, string htmlBody, bool showUnsubscribe = false)
        {
            var html   = FileSystem.GetFileContents(Web.MapPath("~/emailtemplate/template.htm"), false);
            var footer = "";

            if (showUnsubscribe)
            {
                footer = TextBlockCache.Get("Email Footer Outbid", "Sent to xxxemailxxx. You have been sent this email because you have registered for the New World Great Kiwi Christmas campaign. We will only send you these emails for auctions you are bidding on or watching, you can <a style=\"color:#ffffff;\" href=\"xxxunsubscribexxx\">unsubscribe</a> if you want to stop these. New World, Private Bag 4705, Christchurch.").BodyTextHtml;
            }
            else
            {
                footer = TextBlockCache.Get("Email Footer Normal", "Sent to xxxemailxxx. You have been sent this email because you have registered for the New World Great Kiwi Christmas campaign. We will only send you these emails for auctions you are bidding on or watching. New World, Private Bag 4705, Christchurch.").BodyTextHtml;
            }
            html = html.Replace("xxxtitlexxx", heading);
            html = html.Replace("xxxcontentxxx", htmlBody);
            html = html.Replace("xxxfooterxxx", footer);
            if (showUnsubscribe)
            {
                var pid = Person.LoadByEmail(address).ID;
                html = html.Replace("xxxunsubscribexxx", Web.BaseUrl + "Page/Unsubscribe?uid=" + Crypto.EncryptIDClassic(pid));
            }
            html = html.Replace("xxxemailxxx", address);
            html = html.Replace("images/", Web.BaseUrl + "emailtemplate/images/");
            try {
                Beweb.SendEMail.SimpleSendHTMLEmail(address, subject, html);
            } catch (System.FormatException formatException) {
                // The specified string is not in the form required for an e-mail address.
                // Send to webmaster instead

                html = "The following message was supposed to be sent to '" + address + "' but the email address is invalid.<br><br>" + htmlBody;
                Beweb.SendEMail.SimpleSendHTMLEmail(SendEMail.EmailToAddress, "Invalid email address for auction message", htmlBody);
            }
        }