private void sendEmailAsync(Message message)
        {
            string emailBody = string.Empty;

            emailBody += "Subject: \"" + message.Subject + "\"\n\n";
            emailBody += message.Text + "\n\n";
            emailBody += "To see reply to the message, follow the link below:\n";
            emailBody += "http://" + Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/Inbox.aspx") + "?m=" + message.Id;

            aqufitEntities entities = new aqufitEntities();
            UserSettings   sender   = entities.UserSettings.FirstOrDefault(us => us.UserKey == message.UserSetting.UserKey && us.PortalKey == message.UserSetting.PortalKey);

            Affine.Utils.GmailUtil email = new Utils.GmailUtil();
            foreach (MessageRecipiant r in message.MessageRecipiants)
            {
                if (message.UserSetting.UserKey != r.UserSettingsKey)
                {
                    // TODO: cache
                    UserSettings settings = entities.UserSettings.FirstOrDefault(us => us.UserKey == r.UserSettingsKey && us.PortalKey == message.UserSetting.PortalKey);
                    if (settings != null)
                    {
                        email.Send(settings.UserEmail, "New message from " + sender.UserName, "New message from " + sender.UserName + "\n\n" + emailBody);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void sendContactNotificationEmailAsync(BugReport bug)
        {
            string emailBody = "Contact Request\n\n";

            emailBody += "Email: " + bug.Email + "\n";
            emailBody += "PortalName: " + bug.PortalName + "\n";
            emailBody += "PortalId: " + bug.PortalId + "\n";
            emailBody += "AbsoluteUrl: " + bug.AbsoluteUrl + "\n";
            emailBody += "AbsoluteUrlReferrer: " + bug.AbsoluteUrlReferrer + "\n";
            emailBody += "DateTime: " + bug.DateTime.ToShortDateString() + "\n";
            emailBody += "\nDescription: \n" + bug.Description + "\n\n";
            emailBody += "To see the message thread, follow the link below:\n";
            emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/Admin/ContactRequests.aspx") + "?b=" + bug.Id;

            string subject = "CONTACT: A contact request from '" + bug.PortalName + "'";

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();

            aqufitEntities entities = new aqufitEntities();

            gmail.Send("*****@*****.**", subject, emailBody);
        }
Ejemplo n.º 3
0
        private void sendContactNotificationEmailAsync(BugReport bug)
        {
            string emailBody = "Contact Request\n\n";
            emailBody += "Email: " + bug.Email + "\n";
            emailBody += "PortalName: " + bug.PortalName + "\n";
            emailBody += "PortalId: " + bug.PortalId + "\n";
            emailBody += "AbsoluteUrl: " + bug.AbsoluteUrl + "\n";
            emailBody += "AbsoluteUrlReferrer: " + bug.AbsoluteUrlReferrer + "\n";
            emailBody += "DateTime: " + bug.DateTime.ToShortDateString() + "\n";
            emailBody += "\nDescription: \n" + bug.Description + "\n\n";
            emailBody += "To see the message thread, follow the link below:\n";
            emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/Admin/ContactRequests.aspx") + "?b=" + bug.Id;

            string subject = "CONTACT: A contact request from '" + bug.PortalName + "'";

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();

            aqufitEntities entities = new aqufitEntities();
            gmail.Send("*****@*****.**", subject, emailBody);
        }
Ejemplo n.º 4
0
        private void sendUserFollowEmailAsync(UserSettings src, UserSettings dst)
        {
            string emailBody = "Friend Request: " + src.UserName + " Accepted\n\n";
            emailBody += "\"" + src.UserFirstName + " " + src.UserLastName + " has accepted your friend request.\"\n\n";
            // Send an email to the owner of the post

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
            gmail.Send(dst.UserEmail, "Friend Request: " + src.UserName + " accepted", emailBody);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Helper method
        /// </summary>
        /// <param name="us"></param>
        /// <param name="settings"></param>
        /// <param name="comment"></param>
        private void sendStreamEmailAsync(UserStream us, UserSettings settings, UserComment comment)
        {
            string emailBody = settings.UserName + " commented.\n\n";
            emailBody += "\"" + Affine.Utils.Web.WebUtils.FromWebSafeString( comment.Text ) + "\"\n\n";
            emailBody += "To see the comment thread, follow the link below:\n";

            string ts = Convert.ToString(DateTime.Now.Ticks);
            if (us is Recipe)
            {
                emailBody += "http://" + HttpContext.Current.Request.Url.Host.Replace("www.","") + System.Web.VirtualPathUtility.ToAbsolute("~/Search.aspx") + "?r="+us.Id + "&ts="+ts;
            }
            else
            {
                emailBody += "http://" + HttpContext.Current.Request.Url.Host.Replace("www.", "") + "/" + us.UserSetting.UserName + "?s=" + us.Id + "&ts=" + ts;
            }
            string subject = settings.UserName + " commented on your post...";

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
            // Send an email to the owner of the post
            if (us.UserSetting.Id != settings.Id)
            {
                gmail.Send(us.UserSetting.UserEmail, subject, emailBody);
            }

            aqufitEntities entities = new aqufitEntities();
            IQueryable<UserComment> comments = entities.UserComment.Include("UserSetting").Where(uc => uc.UserStream.Id == us.Id);
            string[] emails = comments.Select(uc => uc.UserSetting.UserEmail).Distinct().ToArray();
            foreach (string email in emails)
            {
                if (email != us.UserSetting.UserEmail && email != settings.UserEmail)
                {
                    gmail.Send(email, settings.UserName + " commented.", emailBody);
                }
            }
        }
Ejemplo n.º 6
0
        private void sendReplyEmailAsync(Message m, UserSettings settings)
        {
            string emailBody = settings.UserName + " Replyed to your message\n\n";
            emailBody += "\"" + Affine.Utils.Web.WebUtils.FromWebSafeString( m.LastText ) + "\"\n\n";
            emailBody += "To see the message thread, follow the link below:\n";

            string ts = Convert.ToString(DateTime.Now.Ticks);
            long mId = m.ParentKey > 0 ? m.ParentKey : m.Id;
            emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/Profile/Inbox") + "?m=" + mId + "&ts="+ts;

            string subject = settings.UserName + " Replyed to your message...";

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
            long[] idArray = m.MessageRecipiants.Select(mr => mr.UserSettingsKey).ToArray();

            aqufitEntities entities = new aqufitEntities();
            string[] emails = entities.UserSettings.Where(us => us.PortalKey == settings.PortalKey).Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression<UserSettings, long>(us => us.UserKey, idArray)).Select(us => us.UserEmail).Distinct().ToArray();
            foreach (string email in emails)
            {
                if (email != settings.UserEmail)
                {
                    gmail.Send(email, subject, emailBody);
                }
            }
        }
Ejemplo n.º 7
0
        private void sendEmailAsync(Message message)
        {
            string ts = Convert.ToString(DateTime.Now.Ticks);
            string emailBody = string.Empty;
            emailBody += "Subject: \"" + Affine.Utils.Web.WebUtils.FromWebSafeString(message.Subject) + "\"\n\n";
            emailBody += Affine.Utils.Web.WebUtils.FromWebSafeString(message.Text) + "\n\n";
            emailBody += "To see reply to the message, follow the link below:\n";
            emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/") +"Profile/Inbox?m=" + message.Id+"&ts="+ts;

            aqufitEntities entities = new aqufitEntities();
            UserSettings sender = entities.UserSettings.FirstOrDefault(us => us.Id == message.UserSetting.Id);
            Affine.Utils.GmailUtil email = new Utils.GmailUtil();
            foreach (MessageRecipiant r in message.MessageRecipiants)
            {
                if (message.UserSetting.Id != r.UserSettingsKey)
                {
                    // TODO: cache
                    UserSettings settings = entities.UserSettings.FirstOrDefault(us => us.Id == r.UserSettingsKey );
                    if (settings != null)
                    {
                        email.Send(settings.UserEmail, "New message from " + sender.UserName, "New message from " + sender.UserName + "\n\n" + emailBody);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void sendContactEmailAsync(UserSettings src, string email, string txt)
        {
            //From: [email protected]
            //Subject: Host has invited you to join Aqufit
            //Hi,

            //Come join in... it's free!
            //http://dev.aqufit.com/www.aqufit.com/Home/Register

            //Check out my profile:
            //http://dev.aqufit.com/www.aqufit.com/host

            string emailBody = "Hi,\n" + txt + "\n\n";
            string subject = string.Empty;
            if (src is User)
            {
                emailBody += "Come join in... it's free!\n";
                emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/") + "Home/Register\n\n";
                emailBody += "Check out my profile:\n";
                emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/") + src.UserName + "\n\n";
                subject = src.UserFirstName + " " + src.UserLastName + " (" + src.UserName + ") has invited you to join FlexFWD";
            }
            else
            {   // group invite
                emailBody += "Come join in... it's free!\n";
                emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/") + "Home/Register?g="+src.Id+"&ts="+DateTime.Now.Ticks+"\n\n";
                emailBody += "Check out the group page:\n";
                emailBody += "http://" + HttpContext.Current.Request.Url.Host + System.Web.VirtualPathUtility.ToAbsolute("~/") + "group/"+ src.UserName + "\n\n";
                subject = src.UserFirstName + " has invited you to join their group on FlexFWD";
            }
            // Send an email to the owner of the post

            Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
            gmail.Send(email, subject, emailBody);
        }
Ejemplo n.º 9
0
        private bool Register()
        {
            //Try
            // Only attempt a save/update if all form fields on the page are valid
            if (Page.IsValid)
            {
                // check required fields
                int UID = -1;
                UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiUserName.Text);
                // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser.
                if (objUserInfo != null)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the User Name.\"}');");
                    return false;
                }
                Affine.WebService.RegisterService regService = new WebService.RegisterService();
                double? timezone = null;
                if (!string.IsNullOrEmpty(atiSlimControl.LocLat))
                {
               //         timezone = regService.GetTimeZone(Convert.ToDouble(atiSlimControl.LocLat), Convert.ToDouble(atiSlimControl.LocLng));
                }
                UserInfo objNewUser = regService.InitialiseUser(PortalId);
                string fullname = atiSlimControl.FullName;
                string[] nameparts = fullname.Split(' ');
                string fname = string.Empty;
                string lname = string.Empty;
                if (nameparts.Length >= 2)
                {
                    fname = nameparts[0];
                    lname = nameparts[1];
                }

                regService.populateDnnUserInfo(PortalId, ref objNewUser, fname, lname, atiUserName.Text, atiSlimControl.Email, atiPassword.Password, atiSlimControl.Postal, atiSlimControl.Address, timezone);

                DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser);
                if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
                {
                    UID = objNewUser.UserID;
                    // DNN3 BUG
                    DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
                    objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED);

                    // send notification to portal administrator of new user registration
            //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings);
            //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings);
                    DataCache.ClearUserCache(PortalId, objNewUser.Username);
                    UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);

                    User us = new Data.User();
                    us = (User)populateUserSettings(us, objNewUser);
                    if (atiBodyComp.BirthDateVisible)
                    {
                        us.BirthDate = atiBodyComp.BirthDate;
                    }
                    SiteSetting tutorial = new SiteSetting()
                    {
                        UserSetting = us,
                        Name = "SiteIntro",
                        Value = "1"
                    };
                    entities.AddToUserSettings(us);
                    entities.SaveChanges();

                    us = entities.UserSettings.OfType<User>().FirstOrDefault( u => u.UserKey == objNewUser.UserID && u.PortalKey == objNewUser.PortalID );

                    // TODO: should have a populate function for these
                    BodyComposition bc = new BodyComposition()
                    {
                        UserSetting = us
                    };
                    if (atiBodyComp.FitnessLevelVisible)
                    {
                        bc.FitnessLevel = atiBodyComp.FitnessLevel;
                    }

                    // need height and weight conversions
                    if (atiBodyComp.WeightVisible)
                    {
                        bc.Weight = atiBodyComp.UserWeightInSystemDefault;
                    }
                    if( atiBodyComp.HeightVisible )
                    {
                        bc.Height = atiBodyComp.UserHeightInSystemDefault;
                    }
                    entities.AddToBodyComposition(bc);
                    entities.SaveChanges();

                    string body = "User registration recorded\n\n";
                           body += "ID: " + objNewUser.UserID + "\n";
                           body += "User: "******"\n";
                           body += "First Name: " + objNewUser.FirstName + "\n";
                           body += "Last Name: " + objNewUser.LastName + "\n";
                           body += "Email: " + objNewUser.Email + "\n";
                           body += "Portal: " + objNewUser.PortalID + "\n";
                           body += "User-Agent: " + Request.UserAgent + "\n\n";
             //           DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "User Signup: " + objNewUser.Username, body);

                    // where they brought here by a group?
                    long gid = Convert.ToInt64(hiddenGroupKey.Value);
                    if (gid > 0)
                    {   // if so then we auto add them to the group.
                        Data.Managers.LINQ.DataManager.Instance.JoinGroup(us.Id, gid, Utils.ConstsUtil.Relationships.GROUP_MEMBER);
                    }

                    // See if this person was invited by anyone.
                    ContactInvite invite = entities.ContactInvites.Include("UserSetting").FirstOrDefault(i => i.Email == us.UserEmail);
                    if (invite != null)
                    {   // this person was invited by someone so lets make them friends....
                        string stat = Affine.Data.Managers.LINQ.DataManager.Instance.AcceptFriendRequests(invite.UserSetting.Id, us.Id);
                        // TODO: assume success send for now
                    }
                    // TODO: look through a list of stored contacts to get a sugested friends list...
                }
                else
                { // registration error
                    string body = "User Registration Form FAILED (Us\n\n";
                    body += "ID: " + objNewUser.UserID + "\n";
                    body += "User: "******"\n";
                    body += "First Name: " + objNewUser.FirstName + "\n";
                    body += "Last Name: " + objNewUser.LastName + "\n";
                    body += "Email: " + objNewUser.Email + "\n";
                    body += "REGISTRATION ERROR: " + userCreateStatus.ToString() + "\n";
                    //  string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString();
                  //  DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "**FAIL** REGISTRATION FORM: " + objNewUser.Username, body);

                    litStatus.Text = "REGISTRATION ERROR: " + userCreateStatus.ToString();
                    return false;
                }
            }
            return true;
        }
Ejemplo n.º 10
0
        protected void bUserSetup_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int UID = -1;
                UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiUserNameSetup.Text);
                // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser.
                if (objUserInfo != null)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the User Name.\"}');");
                    return;
                }
                else if (string.IsNullOrWhiteSpace(atiSlimFBSetup.Postal))
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"Postal/Zip is required to give you accurate gym, route, and user information, in your location.\"}');");
                    return;
                }
                else if (atiPasswordSetup.Password != atiPasswordSetup.Confirm)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"Password and Confirmation do not match.\"}');");
                    return;
                }
                Affine.WebService.RegisterService regService = new WebService.RegisterService();
                UserInfo objNewUser = regService.InitialiseUser(PortalId); // TODO: this method

                // TODO: need a TimeZone control

                string fname = hiddenGivenName.Value;
                string lname = hiddenFamilyName.Value;
                string fullname = fname + " " + lname;
                //string uuid = Guid.NewGuid().ToString().Substring(0, 15);
                string pass = atiPasswordSetup.Password;
                string email = hiddenEmail.Value;
                regService.populateDnnUserInfo(PortalId, ref objNewUser, fname, lname, atiUserNameSetup.Text, email, pass, atiSlimFBSetup.Postal, atiSlimFBSetup.Address, null);

                DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser);
                if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
                {
                    UID = objNewUser.UserID;
                    // DNN3 BUG
                    DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
                    objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED);

                    // send notification to portal administrator of new user registration
                    //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings);
                    //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings);
                    DataCache.ClearUserCache(PortalId, objNewUser.Username);
                    UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);

                    User us = new Data.User();
                    us = (User)populateUserSettings(us, objNewUser);
                    try
                    {
                        us.FBUid = Convert.ToInt64(hiddenIdentifier.Value);
                    }
                    catch (Exception) { }
                    entities.AddToUserSettings(us);
                    entities.SaveChanges();

                    // TODO: should have a populate function for these
                    BodyComposition bc = new BodyComposition()
                    {
                        UserSetting = us
                    };
                    if (atiBodyComp.Visible && atiBodyComp.FitnessLevelVisible)
                    {
                        bc.FitnessLevel = atiBodyComp.FitnessLevel;
                    }

                    // need height and weight conversions
                    if (atiBodyComp.Visible && atiBodyComp.WeightVisible)
                    {
                        bc.Weight = atiBodyComp.UserWeightInSystemDefault;
                    }
                    if (atiBodyComp.Visible && atiBodyComp.HeightVisible)
                    {
                        bc.Height = atiBodyComp.UserHeightInSystemDefault;
                    }
                    entities.AddToBodyComposition(bc);
                    entities.SaveChanges();

                    string body = "User registration recorded\n\n";
                    body += "ID: " + objNewUser.UserID + "\n";
                    body += "User: "******"\n";
                    body += "First Name: " + objNewUser.FirstName + "\n";
                    body += "Last Name: " + objNewUser.LastName + "\n";
                    body += "Email: " + objNewUser.Email + "\n";
                    body += "Portal: " + objNewUser.PortalID + "\n";
                    //           DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "User Signup: " + objNewUser.Username, body);

                    // See if this person was invited by anyone.
                    ContactInvite invite = entities.ContactInvites.Include("UserSetting").FirstOrDefault(i => i.Email == us.UserEmail);
                    if (invite != null)
                    {   // this person was invited by someone so lets make them friends....
                        string stat = Affine.Data.Managers.LINQ.DataManager.Instance.AcceptFriendRequests(invite.UserSetting.Id, us.Id);
                        // TODO: assume success send for now
                    }
                    Response.Redirect(Convert.ToString(Settings["LandingPage"]), true);
                }
                else
                { // registration error
                    string body = "User registration FAILED \n\n";
                    body += "ID: " + objNewUser.UserID + "\n";
                    body += "User: "******"\n";
                    body += "First Name: " + fname + "\n";
                    body += "Last Name: " + lname + "\n";
                    body += "Email: " + email + "\n";
                    body += "Status: " + userCreateStatus.ToString();
                    //  string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString();
                    //  DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "**FAIL** RPX User Signup: " + objNewUser.Username, body);
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"" + userCreateStatus.ToString() + "\"}');");
                }
            }
            else
            {
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"\"}');");
            }
        }
Ejemplo n.º 11
0
        private void sendEmailAsync(Message message)
        {
            string emailBody = string.Empty;
            emailBody += "Subject: \"" + message.Subject + "\"\n\n";
            emailBody += message.Text + "\n\n";
            emailBody += "To see reply to the message, follow the link below:\n";
            emailBody += "http://" + Request.Url.Host +  System.Web.VirtualPathUtility.ToAbsolute("~/Inbox.aspx") + "?m=" + message.Id;

            aqufitEntities entities = new aqufitEntities();
            UserSettings sender = entities.UserSettings.FirstOrDefault(us => us.UserKey == message.UserSetting.UserKey && us.PortalKey == message.UserSetting.PortalKey );
            Affine.Utils.GmailUtil email = new Utils.GmailUtil();
            foreach (MessageRecipiant r in message.MessageRecipiants)
            {
                if (message.UserSetting.UserKey != r.UserSettingsKey)
                {
                    // TODO: cache
                    UserSettings settings = entities.UserSettings.FirstOrDefault(us => us.UserKey == r.UserSettingsKey && us.PortalKey == message.UserSetting.PortalKey);
                    if (settings != null)
                    {
                        email.Send(settings.UserEmail, "New message from " + sender.UserName,"New message from " + sender.UserName + "\n\n" + emailBody);
                    }
                }
            }
        }