/// <summary> Constructor for a new instance of the Contact_HtmlSubwriter class </summary> /// <param name="Last_Mode"> URL for the last mode this user was in before selecting contact us</param> /// <param name="UserHistoryRequestInfo"> Some history and user information to include in the final email </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> public Contact_HtmlSubwriter(string Last_Mode, string UserHistoryRequestInfo, SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object) { // Save the parameters lastMode = Last_Mode; userHistoryRequestInfo = UserHistoryRequestInfo; currentMode = Current_Mode; this.Hierarchy_Object = Hierarchy_Object; // If this is a post back, send email if (HttpContext.Current.Request.Form["item_action"] == null) { return; } string action = HttpContext.Current.Request.Form["item_action"]; if (action == "email") { string notes = HttpContext.Current.Request.Form["notesTextBox"].Trim(); string subject = HttpContext.Current.Request.Form["subjectTextBox"].Trim(); string message_from = SobekCM_Library_Settings.System_Email; string email = HttpContext.Current.Request.Form["emailTextBox"].Trim(); string name = HttpContext.Current.Request.Form["nameTextBox"].Trim(); if ((notes.Length > 0) || (subject.Length > 0)) { // Create the mail message if (email.Length > 0) { message_from = email; } // Start the body StringBuilder builder = new StringBuilder(1000); builder.Append(notes + "\n\n\n\n"); builder.Append("The following information is collected to allow us better serve your needs.\n\n"); builder.Append("PERSONAL INFORMATION\n"); builder.Append("\tName:\t\t\t\t" + name + "\n"); builder.Append("\tEmail:\t\t\t" + email + "\n"); builder.Append(userHistoryRequestInfo); string email_body = builder.ToString(); try { MailMessage myMail = new MailMessage(message_from, base.Hierarchy_Object.Contact_Email.Replace(";", ",")) { Subject = subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", Body = email_body }; // Mail this SmtpClient client = new SmtpClient("smtp.ufl.edu"); client.Send(myMail); // Log this string sender = message_from; if (name.Length > 0) { sender = name + " ( " + message_from + " )"; } SobekCM_Database.Log_Sent_Email(sender, base.Hierarchy_Object.Contact_Email.Replace(";", ","), subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1); // Send back to the home for this collection, sub, or group Current_Mode.Mode = Display_Mode_Enum.Contact_Sent; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } catch { bool email_error = SobekCM_Database.Send_Database_Email(base.Hierarchy_Object.Contact_Email.Replace(";", ","), subject + " [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1); // Send back to the home for this collection, sub, or group if (email_error) { HttpContext.Current.Response.Redirect(SobekCM_Library_Settings.System_Error_URL, false); } else { // Send back to the home for this collection, sub, or group Current_Mode.Mode = Display_Mode_Enum.Contact_Sent; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false); } } } } }