public static EmailRequest UpdateFrom(this EmailRequest thisObject, NotifyInviteRequest request) { if (thisObject == null) { thisObject = new EmailRequest(); } thisObject.Recipients.Add(new MailAddress(request.EmailId)); thisObject.IsHtml = true; // Update the body and the subject. thisObject.Subject = request.Subject; var replacements = new Dictionary <string, string> { { "@@Title@@", HttpUtility.UrlDecode(request.Subject) }, { "@@Body@@", HttpUtility.UrlDecode(request.Body) }, { "@@EntityName@@", HttpUtility.UrlDecode(request.CommunityName) }, { "@@EntityLink@@", HttpUtility.UrlDecode(request.CommunityLink) }, { "@@InviteLink@@", HttpUtility.UrlDecode(request.InviteLink) }, { "@@ContactUsLink@@", string.Format(CultureInfo.CurrentUICulture, "mailto:{0}", Constants.MicrosoftEmail) }, { "@@ForumsLink@@", Constants.WWTForumUrl } }; thisObject.MessageBody = FormatMailBodyUsingTemplate("communityinviterequest.html", replacements); return(thisObject); }
private void SendInviteRequestMail(IEnumerable <InviteRequestItem> invitedPeople, string communityName) { try { foreach (var item in invitedPeople) { // Update the body to include the token. var joinCommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Join/{1}/{2}", HttpContext.Request.Url.GetServerLink(), item.CommunityID, item.InviteRequestToken); var notifyInviteRequest = new NotifyInviteRequest() { EmailId = item.EmailIdList.ElementAt(0), CommunityID = item.CommunityID, CommunityName = communityName, CommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Index/{1}", HttpContext.Request.Url.GetServerLink(), item.CommunityID), Subject = item.Subject, Body = item.Body, InviteLink = joinCommunityLink }; // Send Mail for each invited people separately since the token is going to be unique for each user. _notificationService.NotifyCommunityInviteRequest(notifyInviteRequest); } } catch (Exception) { // Ignore all exceptions. } }
public static EmailRequest UpdateFrom(this EmailRequest thisObject, object request) { //// TODO: Need to Get the Email request from the content of the message. //// TODO: Also we need to write a static methods for converting from the input request to the Email Request. if (thisObject == null) { thisObject = new EmailRequest(); } JoinCommunityRequest joinRequest = request as JoinCommunityRequest; if (joinRequest != null) { return(thisObject.UpdateFrom(joinRequest)); } FlaggedRequest flaggedRequest = request as FlaggedRequest; if (flaggedRequest != null) { return(thisObject.UpdateFrom(flaggedRequest)); } EntityCommentRequest entityCommentRequest = request as EntityCommentRequest; if (entityCommentRequest != null) { return(thisObject.UpdateFrom(entityCommentRequest)); } ModeratorPermissionStatusRequest moderatorPermissionStatusRequest = request as ModeratorPermissionStatusRequest; if (moderatorPermissionStatusRequest != null) { return(thisObject.UpdateFrom(moderatorPermissionStatusRequest)); } UserPermissionStatusRequest userPermissionStatusRequest = request as UserPermissionStatusRequest; if (userPermissionStatusRequest != null) { return(thisObject.UpdateFrom(userPermissionStatusRequest)); } RemoveUserRequest removeUserRequest = request as RemoveUserRequest; if (removeUserRequest != null) { return(thisObject.UpdateFrom(removeUserRequest)); } UserPermissionChangedRequest userPermissionChangedRequest = request as UserPermissionChangedRequest; if (userPermissionChangedRequest != null) { return(thisObject.UpdateFrom(userPermissionChangedRequest)); } NotifyInviteRequest notifyInviteRequest = request as NotifyInviteRequest; if (notifyInviteRequest != null) { return(thisObject.UpdateFrom(notifyInviteRequest)); } EntityAdminActionRequest entityAdminDeleteRequest = request as EntityAdminActionRequest; if (entityAdminDeleteRequest != null) { return(thisObject.UpdateFrom(entityAdminDeleteRequest)); } NewEntityRequest newEntityRequest = request as NewEntityRequest; if (newEntityRequest != null) { return(thisObject.UpdateFrom(newEntityRequest)); } return(null); }
/// <summary> /// Notify the user about the invitation sent for joining a community. /// </summary> /// <param name="notification">Invitation request details</param> public void NotifyCommunityInviteRequest(NotifyInviteRequest notification) { SendMail(notification); }