protected void lbSend_Click(object sender, System.EventArgs e) { string sTo = txtTo.Text.Trim(); // all recipients string string allRecipients = String.Empty; if (sTo != String.Empty) { allRecipients = sTo; } if (allRecipients != String.Empty) { allRecipients += "; "; } allRecipients += lblCC.Text; CommonHelper.AddToContext(ForumThreadNodeSetting.AllRecipients, allRecipients); string regex = "([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\\w]*[0-9a-zA-Z])*\\.)+[a-zA-Z]" + "{2,9})"; List <string> dic = new List <string>(); System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline) | System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options); foreach (Match item in reg.Matches(sTo)) { if (!dic.Contains(item.Value)) { dic.Add(item.Value); } } string[] masTo = dic.ToArray(); if (masTo.Length == 0 && lblCC.Text == String.Empty) { lblException.Text = LocRM.GetString("NoRecipients"); divMessage.Visible = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles", "window.setTimeout('updateAttachments()', 500);", true); return; } string _containerName = "FileLibrary"; string _containerKey = "EMailAttach"; CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey); CS.FileStorage fs = (CS.FileStorage)bic.LoadControl("FileStorage"); CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, _guid, true); try { if (IncidentId > 0) { NameValueCollection _params = new NameValueCollection(); _params["IssueId"] = IncidentId.ToString(); EMailClient.SendMessage(masTo, txtSubject.Text, fckEditor.Text, di, EMailClient.IssueMode, _params); string sUrl = "../Incidents/IncidentView.aspx?IncidentId=" + IncidentId; if (Request["back"] != null) { sUrl = HttpUtility.UrlDecode(Request["back"]); } Page.ClientScript.RegisterStartupScript(this.GetType(), "_close", "try{window.opener.location.href='" + sUrl + "';}catch(ex){}window.close();", true); } else { EMailClient.SendMessage(masTo, txtSubject.Text, fckEditor.Text, di); Page.ClientScript.RegisterStartupScript(this.GetType(), "_close", "window.close();", true); } } catch (Exception ex) { string sException = ""; switch (ex.GetType().ToString()) { case "System.Net.Sockets.SocketException": sException = ex.Message; break; case "Mediachase.IBN.Business.EMail.SmtpClientException": sException = LocRM2.GetString("tServerSMTPError") + ": <span style='color:#444;font-style:italic;'>" + ex.Message + "</span>"; break; default: // TODO: Save Exception to IBN Log And Show Friendly Link to Log sException = ex.Message; CHelper.GenerateErrorReport(ex); break; } lblException.Text = LocRM2.GetString("SMTPSettingsIncorrect") + " " + LocRM2.GetString("tWereErrorsSMTP") + "<br/>" + sException; if (Security.IsUserInGroup(InternalSecureGroups.Administrator)) { lblSMTP.Text = "<a href='javascript:ToSMTPSettings();'><font style='color:Red;'><b><u>" + LocRM2.GetString("tSetupSMTPServer") + "</u></b></font></a>"; } else { lblSMTP.Text = LocRM2.GetString("tContactSMTPError"); } divMessage.Visible = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles", "window.setTimeout('updateAttachments()', 500);", true); } }