/// <summary> /// Send email to administrator of the page about posting to wall /// </summary> /// /// <param name="localBusiness"> /// local business for which the email should be sent /// </param> /// /// <param name="songName"> /// name of the song posted to the wall /// </param> private void SendEmail(LocalBusiness localBusiness, string songName) { var body = String.Format( App_GlobalResources.Strings.adminEmailSentBody, songName); var eml = new Email( localBusiness.EmailOnAdminPost, localBusiness.Owners[0].FullName, App_GlobalResources.Strings.adminEmailSentFromAddress, App_GlobalResources.Strings.adminEmailSentFromName, App_GlobalResources.Strings.adminEmailSentSubject, body); if (eml.Send()) { Logger.InfoFormat("Sent email to administrator"); } else { Logger.WarnFormat( "Failed to send email to administrator of {0} ({1})", localBusiness.Name, localBusiness.FanPageId); } }
public virtual ActionResult SendFeedback( string feedback, long playlistId = 0) { /* was the email sent? */ bool isEmailSent; /* post to wall result */ string postResult = null; /* helper for building feedback email message */ var body = new StringBuilder(); /* image URL for the post on the wall */ string imgUrl; /* URL of the post on the wall */ string url; body.AppendFormat( "<span style='font-weight:bold'> Mail from: </span> <br/> name: {0} </t> id: {1} ", (CurrentUser == null) ? string.Empty : CurrentUser.Name, (CurrentUser == null) ? 0 : CurrentUser.Id); body.AppendFormat( "<span style='font-weight:bold'> Content: </span> <br/> {0}", feedback); var eml = new Email( App_GlobalResources.Strings.adminEmailSentFromAddress, App_GlobalResources.Strings.adminEmailSentFromName, App_GlobalResources.Strings.adminEmailSentFromAddress, App_GlobalResources.Strings.adminEmailSentFromName, App_GlobalResources.Strings.feedbackTitle, body.ToString()); isEmailSent = eml.Send(); if (!isEmailSent) { /* failed to send email */ Logger.WarnFormat("Failed to email feedback: {0}", feedback); } var pls = Repository.Get<Playlist>(playlistId); var plsFeedback = String.Format( App_GlobalResources.Strings.FeedbackForPlaylist, (pls != null) ? pls.Name : string.Empty); if (pls != null) { url = string.Format("{0}?sk=app_{1}", pls.LocalBusiness.FacebookUrl, FacebookApp.GetAppId()); imgUrl = pls.LocalBusiness.ImageUrl; } else { imgUrl = UrlUtils.BuildAbsoluteImageUrl( HttpContext.Request.Url, DEFAULT_FEEDBACK_POST_IMAGE, string.Empty, string.Empty); url = null; } try { postResult = Dror.Common.Utils.Facebook.PostToWall( FacebookApp, Dror.Common.Utils.Facebook.APP_FAN_PAGE_ID, plsFeedback, feedback, imgUrl, url, null, null, Dror.Common.Utils.Facebook.WallPostType.post.ToString(), null); } catch (FacebookApiException e) { Logger.Error("Failed to post to wall", e); } if (!isEmailSent || string.IsNullOrEmpty(postResult)) { var result = string.Format( "Failed to post feedback: Email: {0}. Wall: {1}", isEmailSent, postResult); BuildFailureResult(-1, result); } return BuildSuccessResult(0, null); }