//=============================================================== // Function: SendInviteEmail //=============================================================== private Boolean SendInviteEmail(int eventID, string emailAddress, string additionalInviteText, string dateString, SedogoEvent currentEvent, SedogoUser currentUser, out string errorMessageDescription) { Boolean sentOK = false; GlobalData gd = new GlobalData(""); errorMessageDescription = ""; if (MiscUtils.IsValidEmailAddress(emailAddress) == true) { try { // Check if they have already been invited int inviteCount = EventInvite.GetInviteCountForEmailAddress(eventID, emailAddress); if (inviteCount == 0) { StringBuilder emailBodyCopy = new StringBuilder(); // Check if they are a Sedogo account holder int sedogoUserID = SedogoUser.GetUserIDFromEmailAddress(emailAddress); Boolean enableSendEmails = true; if( sedogoUserID != currentUser.userID ) { EventInvite newInvite = new EventInvite(Session["loggedInUserFullName"].ToString()); newInvite.eventID = eventID; newInvite.emailAddress = emailAddress; newInvite.inviteAdditionalText = additionalInviteText; newInvite.userID = sedogoUserID; newInvite.Add(); string inviteURL = gd.GetStringValue("SiteBaseURL"); inviteURL = inviteURL + "?EIG=" + newInvite.eventInviteGUID; string eventURL = gd.GetStringValue("SiteBaseURL"); eventURL = eventURL + "?EID=" + currentEvent.eventID.ToString(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); if (sedogoUserID > 0) { SedogoUser inviteUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), sedogoUserID); if (inviteUser.enableSendEmails == false) { enableSendEmails = false; } inviteURL = inviteURL + "&UID=" + sedogoUserID.ToString(); emailBodyCopy.AppendLine(" <h1>You are invited to join the following goal:</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">What:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + currentEvent.eventName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td>" + currentEvent.eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">When:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td>" + dateString + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <p><span class=\"blue\">" + currentUser.firstName + "</span> has created this future goal on <a href=\"http://www.sedogo.com\">sedogo.com</a> and wants you to join in.</p>"); emailBodyCopy.AppendLine(" <p>To be part of this event, <a href=\"" + inviteURL + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <p>To see who else is part of making this goal happen, <a href=\"" + eventURL + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <p>To view this goal, <a href=\"" + eventURL + "\"><u>click here</u></a>.</p>"); } else { emailBodyCopy.AppendLine(" <h1>You are invited to join the following goal:</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">What:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + currentEvent.eventName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td>" + currentEvent.eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">When:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td>" + dateString + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <p><span class=\"blue\">" + currentUser.firstName + "</span> has created this future goal on <a href=\"http://www.sedogo.com\">sedogo.com</a> and wants you to join in.</p>"); emailBodyCopy.AppendLine(" <p>To be part of this event, <a href=\"" + inviteURL + "\">sign up</a> for a free sedogo account now."); emailBodyCopy.AppendLine(" <p>When you have completed the registration process, <a href=\"" + eventURL + "\">click here</a> to view this event."); } emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string emailSubject = currentUser.firstName + " wants you to be a part of " + currentEvent.eventName + " " + dateString + "!"; string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); if (enableSendEmails == true) { try { MailMessage message = new MailMessage(mailFromAddress, emailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = emailSubject; message.Body = emailBodyCopy.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); newInvite.inviteEmailSent = true; newInvite.inviteEmailSentDate = DateTime.Now; newInvite.inviteEmailSentEmailAddress = emailAddress; newInvite.Update(); SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } } sentOK = true; } else { errorMessageDescription = emailAddress + " - you cannot invite yourself"; } } else { errorMessageDescription = emailAddress + " - already invited"; } } catch (Exception ex) { errorMessageDescription = emailAddress + " - " + ex.Message; } } else { errorMessageDescription = emailAddress + " - invalid email address"; } return sentOK; }
//=============================================================== // Function: GetInviteCount //=============================================================== public void SendInviteAcceptedEmail() { GlobalData gd = new GlobalData(""); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); string invitedUserFullName = m_emailAddress; if( m_userID > 0 ) { SedogoUser invitedUser = new SedogoUser(m_loggedInUser, m_userID); invitedUserFullName = invitedUser.fullName; } SedogoEvent sedogoEvent = new SedogoEvent(m_loggedInUser, m_eventID); SedogoUser eventOwner = new SedogoUser(m_loggedInUser, sedogoEvent.userID); string emailSubject = "Sedogo invitation to " + sedogoEvent.eventName + " has been accepted by " + invitedUserFullName; string dateString = ""; DateTime startDate = sedogoEvent.startDate; MiscUtils.GetDateStringStartDate(eventOwner, sedogoEvent.dateType, sedogoEvent.rangeStartDate, sedogoEvent.rangeEndDate, sedogoEvent.beforeBirthday, ref dateString, ref startDate); string inviteURL = gd.GetStringValue("SiteBaseURL"); inviteURL = inviteURL + "/viewEvent.aspx?EID=" + m_eventID.ToString(); StringBuilder emailBodyCopy = new StringBuilder(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>" + invitedUserFullName + " has accepted your invitation:</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">What:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\" rowspan=\"4\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\"><a href=\"" + inviteURL + "\">" + sedogoEvent.eventName + "</a></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td>" + sedogoEvent.eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Who:</td>"); emailBodyCopy.AppendLine(" <td>" + eventOwner.firstName + " " + eventOwner.lastName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">When:</td>"); emailBodyCopy.AppendLine(" <td>" + dateString + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <p>To view this event, <a href=\"" + inviteURL + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + eventOwner.emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); if (eventOwner.enableSendEmails == true) { try { MailMessage message = new MailMessage(mailFromAddress, eventOwner.emailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = emailSubject; message.Body = emailBodyCopy.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } } }
//=============================================================== // Function: saveChangesButton_click //=============================================================== protected void saveChangesButton_click(object sender, EventArgs e) { Boolean continueSending = false; if (Session["SendMessageCaptcha"] == null || (string)Session["SendMessageCaptcha"] == "N") { if (registerCaptcha.IsValid == true) { Session["SendMessageCaptcha"] = "Y"; continueSending = true; } } else { // Captcha has already been done in this session continueSending = true; } if (continueSending == true) { int eventID = int.Parse(Request.QueryString["EID"]); SedogoEvent sedogoEvent = new SedogoEvent(Session["loggedInUserFullName"].ToString(), eventID); SedogoUser currentUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), int.Parse(Session["loggedInUserID"].ToString())); SedogoUser eventOwner = new SedogoUser(Session["loggedInUserFullName"].ToString(), sedogoEvent.userID); string messageText = messageTextBox.Text; Message message = new Message(Session["loggedInUserFullName"].ToString()); message.userID = sedogoEvent.userID; message.eventID = eventID; message.postedByUserID = int.Parse(Session["loggedInUserID"].ToString()); message.messageText = messageText; message.Add(); StringBuilder emailBodyCopy = new StringBuilder(); GlobalData gd = new GlobalData(""); string eventURL = gd.GetStringValue("SiteBaseURL"); eventURL = eventURL + "/viewEvent.aspx?EID=" + eventID.ToString(); string replyURL = gd.GetStringValue("SiteBaseURL"); replyURL = replyURL + "?Redir=Messages&MessageID=" + message.messageID.ToString(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); //emailBodyCopy.AppendLine(" <h1>sedogo.com message</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">From:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\" rowspan=\"5\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + currentUser.firstName + " " + currentUser.lastName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Goal:</td>"); emailBodyCopy.AppendLine(" <td><a href=\"" + eventURL + "\">" + sedogoEvent.eventName + "</a></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td>" + sedogoEvent.eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Message:</td>"); emailBodyCopy.AppendLine(" <td><p style=\"color:black\">" + messageText.Replace("\n", "<br/>") + "</p></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\"></td>"); emailBodyCopy.AppendLine(" <td><a class=\"blue\" href=\"" + replyURL + "\">Click here to reply to this message</a></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + eventOwner.emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string emailSubject = "Sedogo message from " + currentUser.firstName + " regarding " + sedogoEvent.eventName; string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); if (eventOwner.enableSendEmails == true) { try { MailMessage mailMessage = new MailMessage(mailFromAddress, eventOwner.emailAddress); mailMessage.ReplyTo = new MailAddress("*****@*****.**"); mailMessage.Subject = emailSubject; mailMessage.Body = emailBodyCopy.ToString(); mailMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(mailMessage); SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } } Response.Redirect("viewEvent.aspx?EID=" + eventID.ToString()); } }
//=============================================================== // Function: sendFeedbackButton_click //=============================================================== protected void sendFeedbackButton_click(object sender, EventArgs e) { int currentUserID = -1; SedogoUser currentUser = null; string userEmailAddress = ""; if (Session["loggedInUserID"] != null) { currentUserID = int.Parse(Session["loggedInUserID"].ToString()); currentUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), currentUserID); userEmailAddress = currentUser.emailAddress; } else { userEmailAddress = emailAddressTextBox.Text; } string feedbackText = feedbackTextBox.Text; GlobalData gd = new GlobalData(""); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); //MailMessage message = new MailMessage(mailFromAddress, "*****@*****.**"); MailMessage message = new MailMessage(mailFromAddress, "*****@*****.**"); message.ReplyTo = new MailAddress("*****@*****.**"); StringBuilder emailBody = new StringBuilder(); emailBody.AppendLine("<html><body>"); emailBody.AppendLine("Help:<br/>"); emailBody.AppendLine(userEmailAddress + "<br/>"); emailBody.AppendLine(feedbackText.Replace("\n", "<br/>") + "<br/>"); emailBody.AppendLine("</body></html>"); message.Subject = "Sedogo help"; message.Body = emailBody.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } try { smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo help"; emailHistory.body = emailBody.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = "*****@*****.**"; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo help"; emailHistory.body = ex.Message + " -------- " + emailBody.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = "*****@*****.**"; emailHistory.Add(); } Response.Redirect("profileRedirect.aspx"); }
//=============================================================== // Function: saveChangesButton_click //=============================================================== protected void saveChangesButton_click(object sender, EventArgs e) { Boolean continueSending = false; if (Session["SendMessageCaptcha"] == null || (string)Session["SendMessageCaptcha"] == "N") { if (registerCaptcha.IsValid == true) { Session["SendMessageCaptcha"] = "Y"; continueSending = true; } } else { // Captcha has already been done in this session continueSending = true; } if (continueSending == true) { int eventID = -1; if (Request.QueryString["EID"] != null) { eventID = int.Parse(Request.QueryString["EID"]); } int messageToUserID = int.Parse(Request.QueryString["UID"]); int parentMessageID = -1; if( Request.QueryString["PMID"] != null ) { parentMessageID = int.Parse(Request.QueryString["PMID"]); } int messageID = -1; if( Request.QueryString["MID"] != null ) { messageID = int.Parse(Request.QueryString["MID"]); } string redir = ""; if( Request.QueryString["Redir"] != null ) { redir = (string)Request.QueryString["Redir"]; } if (int.Parse(Session["loggedInUserID"].ToString()) == messageToUserID) { messageToUserID = Message.GetAltEmailUserID(parentMessageID, messageToUserID); } string messageText = messageTextBox.Text; Message message = new Message(Session["loggedInUserFullName"].ToString()); message.userID = messageToUserID; message.eventID = eventID; message.postedByUserID = int.Parse(Session["loggedInUserID"].ToString()); message.messageText = messageText; if (parentMessageID > 0) { // Do not do this - it makes it read for the original recipient not the recipient of the threaded message //Message parentMessage = new Message(Session["loggedInUserFullName"].ToString()); //parentMessage.messageRead = false; //parentMessage.Update(); message.parentMessageID = parentMessageID; } else if (messageID > 0) { message.parentMessageID = messageID; } message.Add(); SedogoUser currentUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), int.Parse(Session["loggedInUserID"].ToString())); SedogoUser messageToUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), messageToUserID); GlobalData gd = new GlobalData(""); StringBuilder emailBodyCopy = new StringBuilder(); string linkURL = gd.GetStringValue("SiteBaseURL"); //if (message.parentMessageID > 0) //{ // linkURL = linkURL + "?Redir=Messages&MID=" + message.parentMessageID.ToString(); //} //else //{ linkURL = linkURL + "?Redir=Messages&MID=" + message.messageID.ToString(); //} emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>sedogo.com message</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">From:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\" rowspan=\"3\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + currentUser.firstName + " " + currentUser.lastName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">To:</td>"); emailBodyCopy.AppendLine(" <td>" + messageToUser.firstName + " " + messageToUser.lastName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Message:</td>"); emailBodyCopy.AppendLine(" <td><p style=\"color:black\">" + messageText.Replace("\n", "<br/>") + "</p></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <p>To reply to this message, <a class=\"blue\" href=\"" + linkURL + "\">click here</a>.</p>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + messageToUser.emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string emailSubject = "You have a new Sedogo message from: " + currentUser.firstName + " " + currentUser.lastName; string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); SedogoUser inviteUser = new SedogoUser(Session["loggedInUserFullName"].ToString(), messageToUserID); if (inviteUser.enableSendEmails == true) { try { MailMessage emailMessage = new MailMessage(mailFromAddress, messageToUser.emailAddress); emailMessage.ReplyTo = new MailAddress("*****@*****.**"); emailMessage.Subject = emailSubject; emailMessage.Body = emailBodyCopy.ToString(); emailMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(emailMessage); SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = messageToUser.emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(Session["loggedInUserFullName"].ToString()); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = messageToUser.emailAddress; emailHistory.Add(); } Session["SentUserMessage"] = "Y"; if (redir == "Messages") { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "parent.window.location='message.aspx';", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "parent.window.location='userTimeline.aspx?UID=" + messageToUserID.ToString() + "';", true); } } else { } } }
//=============================================================== // Function: SendInviteEmail //=============================================================== private Boolean SendInviteEmail(int eventID, string emailAddress, string additionalInviteText, out string errorMessageDescription) { Boolean sentOK = false; GlobalData gd = new GlobalData(""); errorMessageDescription = ""; if (MiscUtils.IsValidEmailAddress(emailAddress) == true) { int userID = -1; if (Session["loggedInUserID"] != null) { userID = int.Parse(Session["loggedInUserID"].ToString()); } string currentUserFullName = ""; SedogoEvent sedogoEvent = new SedogoEvent("", eventID); if (userID > 0) { SedogoUser currentUser = new SedogoUser("", userID); currentUserFullName = currentUser.firstName + " " + currentUser.lastName; } SedogoUser eventOwner = new SedogoUser("", sedogoEvent.userID); string dateString = ""; DateTime startDate = sedogoEvent.startDate; MiscUtils.GetDateStringStartDate(eventOwner, sedogoEvent.dateType, sedogoEvent.rangeStartDate, sedogoEvent.rangeEndDate, sedogoEvent.beforeBirthday, ref dateString, ref startDate); StringBuilder emailBodyCopy = new StringBuilder(); string eventURL = gd.GetStringValue("SiteBaseURL"); eventURL = eventURL + "?EID=" + eventID.ToString(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); //emailBodyCopy.AppendLine(" <h1>sedogo.com message</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Goal:</td>"); emailBodyCopy.AppendLine(" <td><a href=\"" + eventURL + "\">" + sedogoEvent.eventName + "</a></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">When:</td>"); emailBodyCopy.AppendLine(" <td>" + dateString + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td>" + sedogoEvent.eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Message:</td>"); emailBodyCopy.AppendLine(" <td><p style=\"color:black\">" + additionalInviteText.Replace("\n", "<br/>") + "</p></td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + emailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string emailSubject = currentUserFullName + " wants to tell you about " + sedogoEvent.eventName; string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); sentOK = true; try { MailMessage mailMessage = new MailMessage(mailFromAddress, emailAddress); mailMessage.ReplyTo = new MailAddress("*****@*****.**"); mailMessage.Subject = emailSubject; mailMessage.Body = emailBodyCopy.ToString(); mailMessage.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(mailMessage); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } catch (Exception ex) { sentOK = false; errorMessageDescription = emailAddress + " - invalid email address"; SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } } else { errorMessageDescription = emailAddress + " - invalid email address"; } return sentOK; }
//=============================================================== // Function: SendEventUpdateEmail //=============================================================== public void SendEventUpdateEmail(int updatingUserID) { StringBuilder emailBodyCopy = new StringBuilder(); GlobalData gd = new GlobalData(""); string dateString = ""; DateTime startDate = m_startDate; SedogoUser eventOwner = new SedogoUser(m_loggedInUser, m_userID); SedogoUser updatingUser = new SedogoUser(m_loggedInUser, updatingUserID); MiscUtils.GetDateStringStartDate(eventOwner, m_dateType, m_rangeStartDate, m_rangeEndDate, m_beforeBirthday, ref dateString, ref startDate); string inviteURL = gd.GetStringValue("SiteBaseURL"); inviteURL = inviteURL + "/viewEvent.aspx?EID=" + m_eventID.ToString(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>" + updatingUser.firstName + " " + updatingUser.lastName + " has updated the following goal:</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">What:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\" rowspan=\"4\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + m_eventName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Owner:</td>"); emailBodyCopy.AppendLine(" <td>" + eventOwner.firstName + " " + eventOwner.lastName + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">Where:</td>"); emailBodyCopy.AppendLine(" <td>" + m_eventVenue + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td valign=\"top\">When:</td>"); emailBodyCopy.AppendLine(" <td>" + dateString + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <p>To view this event, <a href=\"" + inviteURL + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for <<RECIPIENT>>. To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string emailSubject = m_eventName + " on " + dateString + " has been updated"; string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); // Sent the message to the event owner as well as the trackers if (updatingUserID != m_userID) { if (eventOwner.enableSendEmails == true) { try { MailMessage message = new MailMessage(mailFromAddress, eventOwner.emailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = emailSubject; message.Body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", eventOwner.emailAddress); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", eventOwner.emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", eventOwner.emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = eventOwner.emailAddress; emailHistory.Add(); } } } SqlConnection conn = new SqlConnection(GlobalSettings.connectionString); try { conn.Open(); SqlCommand cmd = new SqlCommand("", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spSelectTrackingUsersByEventID"; cmd.Parameters.Add("@EventID", SqlDbType.Int).Value = m_eventID; DbDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { //int trackedEventID = int.Parse(rdr["TrackedEventID"].ToString()); int userID = int.Parse(rdr["UserID"].ToString()); string firstName = (string)rdr["FirstName"]; string lastName = (string)rdr["LastName"]; //string gender = (string)rdr["Gender"]; //string homeTown = (string)rdr["HomeTown"]; string emailAddress = (string)rdr["EmailAddress"]; if (updatingUserID != userID) { SedogoUser user = new SedogoUser(m_loggedInUser, userID); if (user.enableSendEmails == true) { try { MailMessage message = new MailMessage(mailFromAddress, emailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = emailSubject; message.Body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = emailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } } } } rdr.Close(); } catch (Exception ex) { ErrorLog errorLog = new ErrorLog(); errorLog.WriteLog("SedogoEvent", "SendEventUpdateEmail", ex.Message, logMessageLevel.errorMessage); throw ex; } finally { conn.Close(); } }
//=============================================================== // Function: registerUserButton_click //=============================================================== protected void registerUserButton_click(object sender, EventArgs e) { if (registerCaptcha.IsValid == true) { string emailAddress = emailAddressTextBox.Text; emailAddress = emailAddress.Trim().ToLower(); string userPassword = passwordTextBox1.Text.Trim(); // Verify this email has not been used before int testUserID = SedogoUser.GetUserIDFromEmailAddress(emailAddress); if (testUserID > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert(\"This email address is already registered, please log in, or click on the forgot your password link on the home page.\");", true); } else { // Create the user SedogoUser newUser = new SedogoUser(""); DateTime dateOfBirth; if (dateOfBirthYear.SelectedIndex > 0 && dateOfBirthMonth.SelectedIndex > 0 && dateOfBirthDay.SelectedIndex > 0) { dateOfBirth = new DateTime(int.Parse(dateOfBirthYear.SelectedValue), int.Parse(dateOfBirthMonth.SelectedValue), int.Parse(dateOfBirthDay.SelectedValue)); } else { dateOfBirth = DateTime.MinValue; } newUser.firstName = firstNameTextBox.Text; newUser.lastName = lastNameTextBox.Text; newUser.emailAddress = emailAddress; if (genderMaleRadioButton.Checked == true) { newUser.gender = "M"; } else { newUser.gender = "F"; } newUser.homeTown = homeTownTextBox.Text; if (dateOfBirth > DateTime.MinValue) { newUser.birthday = dateOfBirth; } newUser.timezoneID = int.Parse(timezoneDropDownList.SelectedValue); //Nikita Knyazev. Facebook Authentication. Start try { if (Session["facebookUserID"] != null) newUser.facebookUserID = (long)Session["facebookUserID"]; } catch (Exception ex) { } //Nikita Knyazev. Facebook Authentication. Finish newUser.avatarNumber = int.Parse(avatarComboBox.SelectedValue); newUser.Add(); newUser.UpdatePassword(userPassword); // Send registration email GlobalData gd = new GlobalData((string)Session["loggedInUserFullName"]); string siteBaseURL = gd.GetStringValue("SiteBaseURL"); StringBuilder emailBodyCopy = new StringBuilder(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>Thanks for registering with Sedogo</h1>"); emailBodyCopy.AppendLine(" <p>Please click on the link below to confirm your email.</p>"); emailBodyCopy.AppendLine(" <p><a href=\"" + siteBaseURL + "/e/?G=" + newUser.GUID + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr></table></body></html>"); // Old version, removed because of spam filters //emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\"><img src=\"http://www.sedogo.com/email-template/images/logo.gif\" /></a></td>"); //emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); //emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); string mailToEmailAddress = emailAddress; MailMessage message = new MailMessage(mailFromAddress, mailToEmailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = "Sedogo registration"; message.Body = emailBodyCopy.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } try { smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo registration"; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo registration"; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } Response.Redirect("registerWait.aspx"); } } }
//=============================================================== // Function: SendBroadcastTestEmail //=============================================================== public static void SendBroadcastTestEmail(string recipientEmailAddress) { GlobalData gd = new GlobalData(""); string broadcastEmailSubject = gd.GetStringValue("BroadcastEmailSubject"); string broadcastEmailContent = gd.GetStringValue("BroadcastEmailContent"); string emailBodyCopy = BuildBroadcastEmail(broadcastEmailContent); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); try { MailMessage message = new MailMessage(mailFromAddress, recipientEmailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = broadcastEmailSubject; message.Body = emailBodyCopy.Replace("<<RECIPIENT>>", recipientEmailAddress); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = broadcastEmailSubject; emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", recipientEmailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = recipientEmailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = broadcastEmailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", recipientEmailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = recipientEmailAddress; emailHistory.Add(); } }
//=============================================================== // Function: SendBroadcastEmail //=============================================================== public static void SendBroadcastEmail() { GlobalData gd = new GlobalData(""); string broadcastEmailWaiting = gd.GetStringValue("BroadcastEmailWaiting"); if (broadcastEmailWaiting == "Y") { // update this straight away - if the broadcast fails then it will not send again to all users gd.UpdateStringValue("BroadcastEmailWaiting", "N"); string broadcastEmailSubject = gd.GetStringValue("BroadcastEmailSubject"); string broadcastEmailContent = gd.GetStringValue("BroadcastEmailContent"); string emailBodyCopy = BuildBroadcastEmail(broadcastEmailContent); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); // Get a list of all users SqlConnection conn = new SqlConnection(GlobalSettings.connectionString); try { conn.Open(); SqlCommand cmd = new SqlCommand("", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spSelectUserList"; DbDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { string emailAddress = ""; string firstName = ""; string lastName = ""; int userID = int.Parse(rdr["UserID"].ToString()); if (!rdr.IsDBNull(rdr.GetOrdinal("EmailAddress"))) { emailAddress = (string)rdr["EmailAddress"]; } if (!rdr.IsDBNull(rdr.GetOrdinal("FirstName"))) { firstName = (string)rdr["FirstName"]; } if (!rdr.IsDBNull(rdr.GetOrdinal("LastName"))) { lastName = (string)rdr["LastName"]; } Boolean enableSendEmails = (Boolean)rdr["EnableSendEmails"]; if (enableSendEmails == true) { try { //MailMessage message = new MailMessage(mailFromAddress, "*****@*****.**"); MailMessage message = new MailMessage(mailFromAddress, emailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = broadcastEmailSubject; message.Body = emailBodyCopy.Replace("<<RECIPIENT>>", emailAddress); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = broadcastEmailSubject; emailHistory.body = emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = broadcastEmailSubject; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString().Replace("<<RECIPIENT>>", emailAddress); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = emailAddress; emailHistory.Add(); } } } rdr.Close(); } catch (Exception ex) { ErrorLog errorLog = new ErrorLog(); errorLog.WriteLog("MiscUtils", "SendBroadcastEmail", ex.Message, logMessageLevel.errorMessage); throw ex; } finally { conn.Close(); } } }
//=============================================================== // Function: forgotPasswordButton_click //=============================================================== protected void forgotPasswordButton_click(object sender, EventArgs e) { string loginEmailAddress = emailAddressTextBox.Text; SedogoUser user = new SedogoUser(""); string newPassword = ""; Boolean resetStatus = user.ResetUserPassword(loginEmailAddress, ref newPassword); if (resetStatus == true) { // Send the user an email with the new password // Email the password to the user GlobalData gd = new GlobalData(""); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); MailMessage message = new MailMessage(mailFromAddress, loginEmailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); StringBuilder emailBodyCopy = new StringBuilder(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>Your new sedogo.com password</h1>"); emailBodyCopy.AppendLine(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\">"); emailBodyCopy.AppendLine(" <tr>"); emailBodyCopy.AppendLine(" <td width=\"60\">Password:</td>"); emailBodyCopy.AppendLine(" <td width=\"10\"> </td>"); emailBodyCopy.AppendLine(" <td width=\"530\">" + newPassword + "</td>"); emailBodyCopy.AppendLine(" </tr>"); emailBodyCopy.AppendLine(" </table>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/logo.gif\" />"); emailBodyCopy.AppendLine(" </a></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); emailBodyCopy.AppendLine(" </td></tr><tr><td colspan=\"3\"><small>This message was intended for " + loginEmailAddress + ". To stop receiving these emails, go to your profile and uncheck the 'Enable email notifications' option.<br/>Sedogo offices are located at Sedogo Ltd, The Studio, 17 Blossom St, London E1 6PL.</small></td></tr>"); emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); message.Subject = "Sedogo password reset"; message.Body = emailBodyCopy.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } try { smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo password reset"; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = loginEmailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo password reset"; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = loginEmailAddress; emailHistory.Add(); } Session["ResetPassword"] = "******"; Response.Redirect("default.aspx"); } else { Response.Redirect("noSuchUser.aspx"); } }
//=============================================================== // Function: resendActivationButton_click //=============================================================== protected void resendActivationButton_click(object sender, EventArgs e) { string loginEmailAddress = emailAddressTextBox.Text; int userID = SedogoUser.GetUserIDFromEmailAddress(loginEmailAddress); if (userID > 0) { SedogoUser user = new SedogoUser("", userID); if (user.loginEnabled == false) { // Send registration email GlobalData gd = new GlobalData((string)Session["loggedInUserFullName"]); string siteBaseURL = gd.GetStringValue("SiteBaseURL"); StringBuilder emailBodyCopy = new StringBuilder(); emailBodyCopy.AppendLine("<html>"); emailBodyCopy.AppendLine("<head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">"); emailBodyCopy.AppendLine("<style type=\"text/css\">"); emailBodyCopy.AppendLine(" body, td, p { font-size: 15px; color: #9B9885; font-family: Arial, Helvetica, Sans-Serif }"); emailBodyCopy.AppendLine(" p { margin: 0 }"); emailBodyCopy.AppendLine(" h1 { color: #00ccff; font-size: 18px; font-weight: bold; }"); emailBodyCopy.AppendLine(" a, .blue { color: #00ccff; text-decoration: none; }"); emailBodyCopy.AppendLine(" img { border: 0; }"); emailBodyCopy.AppendLine("</style></head>"); emailBodyCopy.AppendLine("<body bgcolor=\"#f0f1ec\">"); emailBodyCopy.AppendLine(" <table width=\"692\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); //emailBodyCopy.AppendLine(" <tr><td colspan=\"3\"><img src=\"http://www.sedogo.com/email-template/images/email-template_01.png\" width=\"692\" height=\"32\" alt=\"\"></td></tr>"); emailBodyCopy.AppendLine(" <tr><td style=\"background: #fff\" width=\"30\"></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"632\">"); emailBodyCopy.AppendLine(" <h1>Thanks for registering with Sedogo</h1>"); emailBodyCopy.AppendLine(" <p>Please click on the link below to confirm your email.</p>"); emailBodyCopy.AppendLine(" <p><a href=\"" + siteBaseURL + "/e/?G=" + user.GUID + "\"><u>click here</u></a>.</p>"); emailBodyCopy.AppendLine(" <br /><br />"); emailBodyCopy.AppendLine(" <p>Regards</p><a href=\"http://www.sedogo.com\" class=\"blue\"><strong>The Sedogo Team.</strong></a><br />"); emailBodyCopy.AppendLine(" <br /></td>"); emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr></table></body></html>"); // Old version, removed because of spam filters //emailBodyCopy.AppendLine(" <br /><br /><br /><a href=\"http://www.sedogo.com\"><img src=\"http://www.sedogo.com/email-template/images/logo.gif\" /></a></td>"); //emailBodyCopy.AppendLine(" <td style=\"background: #fff\" width=\"30\"></td></tr><tr><td colspan=\"3\">"); //emailBodyCopy.AppendLine(" <img src=\"http://www.sedogo.com/email-template/images/email-template_05.png\" width=\"692\" height=\"32\" alt=\"\">"); //emailBodyCopy.AppendLine(" </td></tr></table></body></html>"); string SMTPServer = gd.GetStringValue("SMTPServer"); string mailFromAddress = gd.GetStringValue("MailFromAddress"); string mailFromUsername = gd.GetStringValue("MailFromUsername"); string mailFromPassword = gd.GetStringValue("MailFromPassword"); string mailToEmailAddress = user.emailAddress; MailMessage message = new MailMessage(mailFromAddress, mailToEmailAddress); message.ReplyTo = new MailAddress("*****@*****.**"); message.Subject = "Sedogo registration"; message.Body = emailBodyCopy.ToString(); message.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = SMTPServer; if (mailFromPassword != "") { // If the password is blank, assume mail relay is permitted smtp.Credentials = new System.Net.NetworkCredential(mailFromAddress, mailFromPassword); } try { smtp.Send(message); SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo registration"; emailHistory.body = emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = user.emailAddress; emailHistory.Add(); } catch (Exception ex) { SentEmailHistory emailHistory = new SentEmailHistory(""); emailHistory.subject = "Sedogo registration"; emailHistory.body = ex.Message + " -------- " + emailBodyCopy.ToString(); emailHistory.sentFrom = mailFromAddress; emailHistory.sentTo = user.emailAddress; emailHistory.Add(); } Response.Redirect("default.aspx"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Reset password", "alert(\"This account has already been activated.\");", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Reset password", "alert(\"No account with this email address was found.\");", true); } }