public emMessage InsertMessage(emMessage model) { #region set default model.IsDelete = false; model.IsRead = false; model.IsForward = false; model.IsReply = false; model.IsShow = true; model.RowFlag = 1; model.CreatedBy = "sa"; model.ModifiedBy = "sa"; model.SendDate = DateTimeNow; model.ModifiedDate = DateTimeNow; model.CreatedDate = DateTimeNow; #endregion qDB.emMessages.InsertOnSubmit(model); qDB.SubmitChanges(); IsResult = true; return(model); }
public emMessage InsertMessageReply(emMessage model, string type) { #region set default if (type == "Reply") { model.IsReply = true; } else { model.IsReply = false; } if (type == "Forward") { model.IsForward = true; } else { model.IsForward = false; } model.IsDelete = false; model.IsRead = false; model.IsShow = true; model.RowFlag = 1; model.CreatedBy = "sa"; model.ModifiedBy = "sa"; model.SendDate = DateTimeNow; model.ModifiedDate = DateTimeNow; model.CreatedDate = DateTimeNow; #endregion qDB.emMessages.InsertOnSubmit(model); qDB.SubmitChanges(); IsResult = true; return(model); }
public bool SendEmailNoMember(emMessage model, string name, string email) { #region variable bool IsSend = true; var Detail = ""; var url = ""; var mailTo = new List <string>(); List <string> mailToAdmin = GetMailListB2BAdmin(); var mailCC = new List <string>(); var Sender = ""; var Receiver = ""; svCompany = new CompanyService(); string fromName = ""; string fromPhone = ""; string fromEmail = ""; #endregion #region set from info if (model.FromCompID > 0) { string sqlselect = "CompID,CompName,ContactFirstName,ContactLastName,ContactEmail,ContactPhone,CompPhone"; string sqlwhere = "CompID = " + model.FromCompID + " AND IsDelete = 0"; var fromcomp = svCompany.SelectData <b2bCompany>(sqlselect, sqlwhere).Count() > 0 ? svCompany.SelectData <b2bCompany>(sqlselect, sqlwhere).First() : new b2bCompany(); if (!string.IsNullOrEmpty(model.FromContactPhone)) { fromPhone = model.FromContactPhone; } else if (!string.IsNullOrEmpty(fromcomp.ContactPhone)) { fromPhone = fromcomp.ContactPhone; } else { fromPhone = fromcomp.CompPhone; } } else { fromPhone = model.FromContactPhone; } Sender = model.FromName; string[] subName = model.FromName.Split(new char[] { '(', ')', ',' }, StringSplitOptions.RemoveEmptyEntries); if (subName.Length > 1) { fromName = subName[0].Substring(0, subName[0].Length); fromEmail = subName[1].Substring(0, subName[1].Length); } else { fromName = subName[0].Substring(0, subName[0].Length); fromEmail = model.FromEmail; } #endregion Receiver = name; #region Set Content & Value For Send Email string urlb2bthai = res.Pageviews.UrlWeb; url = urlb2bthai + "/Message/Detail?MessageID=" + model.MessageID + "&MessageCode=" + model.MessageCode + "&MsgType=Inbox"; //test path logo string b2bthai_url = res.Pageviews.UrlWeb; string pathlogo = b2bthai_url + "/Content/Default/logo/Ouikum/img_Logo120x74.png"; Hashtable EmailDetail = new Hashtable(); EmailDetail["ToFirstName"] = email; EmailDetail["FromFirstName"] = fromName; EmailDetail["FromPhone"] = fromPhone; EmailDetail["FromEmail"] = fromEmail; EmailDetail["MsgDetail"] = model.MsgDetail; EmailDetail["pathLogo"] = pathlogo; EmailDetail["url"] = url; if (model.IsFavorite == true) { EmailDetail["IsFavorite"] = "กรุณาติดต่อกลับด่วน"; } ViewBag.Data = EmailDetail; string Subject = "คุณ " + fromName + ", ได้ติดต่อคุณ ผ่านทาง Ouikum.com"; Detail = PartialViewToString("UC/Email/SendMessage"); var mailFrom = res.Config.EmailNoReply; mailTo.Add(email); //mailTo.Add("*****@*****.**"); //mailTo.Add("*****@*****.**"); #endregion IsSend = OnSendByAlertEmail(Subject, mailFrom, mailTo, mailCC, Detail); //url = urlb2bthai + "/Admin/Stat/MessageDetail?MessageID=" + model.MessageID + "&MessageCode=" + model.MessageCode; //Subject = res.Message_Center.lblKhun + " " + Sender + " " + res.Message_Center.lblContacted + " " + Receiver + " " + res.Message_Center.lblVia; //Detail = "<table ><tr><td>" + res.Message_Center.lblKhun + " " + Sender + " " + res.Message_Center.lblContacted + " " + Receiver + " " + res.Message_Center.lblVia + " </td></tr>"; //Detail += "<tr><td><br>" + model.MsgDetail + "</td></tr>"; //Detail += "<tr><td><br><br>" + res.Message_Center.lblWantToViewMsg + " <a href=\"" + url + "\" >" + url + "</a><br></td></tr>"; //Detail += "</table>"; //IsSend = OnSendByAlertEmail(Subject, mailFrom, mailToAdmin, mailCC, Detail); return(IsSend); }
public ActionResult sendmessage( string fromemail, string tel, string message, string subject, int tocompid, string msgstatus, int fromcompid = 0, int rootmessageid = 0) { Ouikum.Message.MessageService svMessage = new Ouikum.Message.MessageService(); var svCompany = new CompanyService(); string ToCompID = tocompid.ToString(); int rootMsgID = rootmessageid; string sqlWhere = ""; string msgdetail = message; var msgCtrl = new Ouikum.Controllers.MessageController(); #region MyRegion var emMessageSender = new emMessage(); var emMessageReceiver = new emMessage(); #region Sender Message emMessageSender.ToCompID = tocompid; emMessageSender.FromCompID = fromcompid; emMessageSender.IsFavorite = false; emMessageSender.Subject = subject; emMessageSender.MsgDetail = msgdetail; emMessageSender.RootMessageID = (rootMsgID != 0) ? rootMsgID : 0; emMessageSender.MessageCode = emMessageSender.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageSender.MsgStatus = "2"; emMessageSender.IsSend = true; emMessageSender.FromName = fromemail; emMessageSender.FromContactPhone = tel; #region Save Sender Message if (msgstatus == "Reply") { emMessageSender = svMessage.InsertMessageReply(emMessageSender, "Reply"); } else { emMessageSender = svMessage.InsertMessage(emMessageSender); } #endregion #endregion #region Receiver Message emMessageReceiver.ToCompID = tocompid; emMessageReceiver.FromCompID = fromcompid; emMessageReceiver.Subject = subject; emMessageReceiver.MsgDetail = msgdetail; emMessageReceiver.IsFavorite = false; emMessageReceiver.RootMessageID = (rootMsgID != 0) ? rootMsgID : 0; emMessageReceiver.MessageCode = emMessageSender.MessageCode; emMessageReceiver.MsgStatus = "2"; emMessageReceiver.IsSend = false; emMessageReceiver.FromName = fromemail; emMessageReceiver.FromContactPhone = tel; #region Save Receiver Message if (msgstatus == "Reply") { emMessageReceiver = svMessage.InsertMessageReply(emMessageReceiver, "Reply"); } else { emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); } #endregion #endregion if (emMessageReceiver.ToCompID > 0) { #region GetToCompName sqlWhere = "CompID = " + emMessageReceiver.ToCompID + " AND IsDelete = 0"; var Company = svCompany.SelectData <b2bCompany>("CompID,CompName,ContactEmail", sqlWhere).First(); var toCompName = Company.CompName; var toCompEmail = Company.ContactEmail; #endregion #region Send Email if (svMessage.IsResult) { msgCtrl.SendEmail(emMessageReceiver, toCompName, toCompEmail); } #endregion } else { if (svMessage.IsResult) { msgCtrl.SendEmailNoMember(emMessageReceiver, "", fromemail); } } #endregion msgCtrl.CountMessage(); return(Json(new { status = svMessage.IsResult }, JsonRequestBehavior.AllowGet)); }
public ActionResult ContactSupplier(string ToCompID, string FromCompID, string FromName, string FromEmail, string Subject, string MsgDetail, bool IsImportance, string ProductID, string FromContactPhone, string captcha, string captcha_id) { Ouikum.Message.MessageService svMessage = new Ouikum.Message.MessageService(); var emMessageSender = new emMessage(); var emMessageReceiver = new emMessage(); svCompany = new CompanyService(); var isResult = false; if (captcha == HttpContext.Session["captcha_" + captcha_id].ToString()) { //if (IsImportance == true) //{ // MsgDetail += "<p><strong>" + res.Message_Center.lblContactImmediately + "</strong></p>"; //} #region Set Message if (LogonCompID > 0) { #region Sender emMessageSender.ToCompID = DataManager.ConvertToInteger(ToCompID); emMessageSender.Subject = Subject; emMessageSender.MsgDetail = MsgDetail; emMessageSender.RootMessageID = 0; emMessageSender.MessageCode = emMessageSender.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageSender.MsgStatus = "2"; emMessageSender.IsSend = true; emMessageSender.SendDate = DateTimeNow; emMessageSender.IsFavorite = IsImportance; emMessageSender.FromCompID = LogonCompID; emMessageSender.FromName = FromName; emMessageSender.FromEmail = LogonEmail; emMessageSender.FromContactPhone = FromContactPhone; emMessageSender.MsgFolderID = 2; emMessageSender.IsAttach = false; emMessageSender = svMessage.InsertMessage(emMessageSender); #endregion #region Receiver emMessageReceiver.ToCompID = DataManager.ConvertToInteger(ToCompID); emMessageReceiver.Subject = Subject; emMessageReceiver.MsgDetail = MsgDetail; emMessageReceiver.RootMessageID = 0; emMessageReceiver.MessageCode = emMessageSender.MessageCode; emMessageReceiver.MsgStatus = "1"; emMessageReceiver.IsSend = false; emMessageReceiver.SendDate = DateTimeNow; emMessageReceiver.IsFavorite = IsImportance; emMessageReceiver.FromCompID = LogonCompID; emMessageReceiver.FromName = FromName; emMessageReceiver.FromEmail = LogonEmail; emMessageReceiver.FromContactPhone = FromContactPhone; emMessageReceiver.MsgFolderID = 1; emMessageReceiver.IsAttach = false; emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); #endregion #region Send Email if (ToCompID != "0") { var comp = svCompany.SelectData <b2bCompany>("CompID, CompName, ContactEmail", "CompID = " + emMessageReceiver.ToCompID).First(); isResult = SendEmail(emMessageReceiver, comp.CompName, comp.ContactEmail); } else { isResult = SendEmailNoMember(emMessageReceiver, FromName, FromEmail); } #endregion } else { #region Receiver emMessageReceiver.ToCompID = DataManager.ConvertToInteger(ToCompID); emMessageReceiver.Subject = Subject; emMessageReceiver.MsgDetail = MsgDetail; emMessageReceiver.RootMessageID = 0; emMessageReceiver.MessageCode = emMessageReceiver.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageReceiver.MsgStatus = "1"; emMessageReceiver.MsgFolderID = 1; emMessageReceiver.IsSend = false; emMessageReceiver.SendDate = DateTimeNow; emMessageReceiver.IsFavorite = IsImportance; emMessageReceiver.FromCompID = 0; emMessageReceiver.FromName = FromName; emMessageReceiver.FromEmail = FromEmail; emMessageReceiver.FromContactPhone = FromContactPhone; emMessageReceiver.IsAttach = false; emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); #endregion #region GetCompany var comp = svCompany.SelectData <b2bCompany>("CompID, CompName, ContactEmail", "CompID = " + emMessageReceiver.ToCompID).First(); #endregion #region Send Email isResult = SendEmail(emMessageReceiver, comp.CompName, comp.ContactEmail); #endregion } #endregion } GetStatusUser(); #region Update ContactCount if (!string.IsNullOrEmpty(ProductID)) { AddContactCount(DataManager.ConvertToInteger(ProductID)); } #endregion return(Json(new { IsResult = svMessage.IsResult, IsSendMail = isResult }, JsonRequestBehavior.AllowGet)); //return Json(true); }
public ActionResult New(FormCollection form) { if (LogonCompID > 0) { Ouikum.Message.MessageService svMessage = new Ouikum.Message.MessageService(); svCompany = new CompanyService(); string ToCompID = form["hidToCompID"]; string[] sub_ToCompID = ToCompID.Split(','); int rootMsgID = DataManager.ConvertToInteger(form["hidMsgID"]); string sqlWhere = ""; string msgdetail = form["MsgDetail"]; string msgStatus = form["msgstatus"]; var emMessageSender = new emMessage(); var emMessageReceiver = new emMessage(); var comp = svCompany.SelectData <b2bCompany>("CompID,CompPhone,CompName,ContactFirstName,ContactEmail", "CompID = " + LogonCompID).First(); if (DataManager.ConvertToBool(form["IsImportance"]) == true) { msgdetail += "<p><strong>" + res.Message_Center.lblContactImmediately + "</strong></p>"; } // บันทึกในแบบร่าง if (msgStatus == "Draft") { var emMessage = new emMessage(); var Messages = svMessage.SelectData <view_Message>("*", "MsgFolderID = 3 AND MessageID = " + DataManager.ConvertToInteger(form["hidMsgID"])); #region Draft if (Messages.Count > 0) { for (int i = 0; i < sub_ToCompID.Length; i++) { var sqlUpdate = "ToCompID = " + DataManager.ConvertToInteger(sub_ToCompID[i]) + " , Subject = N'" + form["txtSubject"] + "' , MsgDetail = N'" + msgdetail + "'"; if (!string.IsNullOrEmpty(form["hidImgFileName"])) { sqlUpdate += ", IsAttach = 1"; } else { sqlUpdate += ", IsAttach = 0"; } svMessage.UpdateByCondition <emMessage>(sqlUpdate, " MessageID = " + Messages[0].MessageID); } } else { for (int i = 0; i < sub_ToCompID.Length; i++) { emMessage.ToCompID = DataManager.ConvertToInteger(sub_ToCompID[i]); emMessage.FromCompID = LogonCompID; emMessage.IsFavorite = DataManager.ConvertToBool(form["IsImportance"]); emMessage.Subject = form["txtSubject"]; emMessage.MsgDetail = msgdetail; emMessage.MsgFolderID = 3; emMessage.RootMessageID = 0;//rootMsgID emMessage.MessageCode = emMessage.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessage.MsgStatus = "3"; emMessage.IsSend = false; emMessage.FromName = comp.ContactFirstName != null ? comp.ContactFirstName : comp.CompName; emMessage.FromContactPhone = comp.CompPhone; emMessage.FromEmail = comp.ContactEmail; if (!string.IsNullOrEmpty(form["hidImgFileName"])) { emMessage.IsAttach = true; } else { emMessage.IsAttach = false; } #region Save Draft emMessage = svMessage.InsertMessage(emMessage); #endregion // เช็คไฟล์แนบ if (!string.IsNullOrEmpty(form["hidImgFileName"])) { #region Save Image Files imgManager = new FileHelper(); imgManager.DirPath = "MessageFile/" + LogonCompID + "/" + emMessage.MessageID; imgManager.DirTempPath = "Temp/MessageFile/" + LogonCompID; SaveFileImage( imgManager.DirTempPath, imgManager.DirPath, form["hidImgFileName"]); #endregion string strFileName = form["hidImgFileName"]; string[] ArrayFileName = strFileName.Split('.'); var Attach = new emMessageAttach(); Attach.MessageID = emMessage.MessageID; Attach.MessageCode = emMessage.MessageCode; Attach.FileName = form["hidImgFileName"]; Attach.FileType = "." + ArrayFileName[1]; Attach.FilePath = "https://ouikumstorage.blob.core.windows.net/upload/MessageFile/" + LogonCompID + "/" + emMessage.MessageID + "/" + form["hidImgFileName"]; Attach.FileSize = 0; Attach = svMessage.InsertMessageFile(Attach); } } } #endregion } else { //ส่งข้อความ for (int i = 0; i < sub_ToCompID.Length; i++) { // บันทึกข้อมูลลงกล่องขาออกของผู้ส่ง #region Sender Message emMessageSender.ToCompID = DataManager.ConvertToInteger(sub_ToCompID[i]); emMessageSender.FromCompID = LogonCompID; emMessageSender.IsFavorite = DataManager.ConvertToBool(form["IsImportance"]); emMessageSender.Subject = form["txtSubject"]; emMessageSender.MsgDetail = msgdetail; emMessageSender.MsgFolderID = 2; emMessageSender.RootMessageID = (rootMsgID != 0) ? rootMsgID : 0; emMessageSender.MessageCode = emMessageSender.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageSender.MsgStatus = "2"; emMessageSender.IsSend = true; emMessageSender.FromName = comp.ContactFirstName != null ?comp.ContactFirstName : comp.CompName; emMessageSender.FromContactPhone = comp.CompPhone; emMessageSender.FromEmail = comp.ContactEmail; if (!string.IsNullOrEmpty(form["hidImgFileName"])) { emMessageSender.IsAttach = true; } else { emMessageSender.IsAttach = false; } #region Save Sender Message if (msgStatus == "Reply") { emMessageSender = svMessage.InsertMessageReply(emMessageSender, "Reply"); } else if (msgStatus == "Forward") { emMessageSender = svMessage.InsertMessageReply(emMessageSender, "Forward"); } else { emMessageSender = svMessage.InsertMessage(emMessageSender); } #endregion #endregion // บันทึกข้อมูลลงกล่องขาเข้าของผู้รับ #region Receiver Message emMessageReceiver.ToCompID = DataManager.ConvertToInteger(sub_ToCompID[i]); emMessageReceiver.FromCompID = LogonCompID; emMessageReceiver.Subject = form["txtSubject"]; emMessageReceiver.MsgDetail = form["MsgDetail"]; emMessageReceiver.MsgFolderID = 1; emMessageReceiver.IsFavorite = DataManager.ConvertToBool(form["IsImportance"]); emMessageReceiver.RootMessageID = (rootMsgID != 0) ? rootMsgID : 0; emMessageReceiver.MessageCode = emMessageSender.MessageCode; emMessageReceiver.MsgStatus = "1"; emMessageReceiver.IsSend = false; emMessageReceiver.FromName = comp.ContactFirstName != null ?comp.ContactFirstName : comp.CompName; emMessageReceiver.FromContactPhone = comp.CompPhone; emMessageReceiver.FromEmail = comp.ContactEmail; if (!string.IsNullOrEmpty(form["hidImgFileName"])) { emMessageReceiver.IsAttach = true; } else { emMessageReceiver.IsAttach = false; } #region Save Receiver Message if (msgStatus == "Reply") { emMessageReceiver = svMessage.InsertMessageReply(emMessageReceiver, "Reply"); } else if (msgStatus == "Forward") { emMessageReceiver = svMessage.InsertMessageReply(emMessageReceiver, "Forward"); } else { emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); } #endregion #endregion // เช็คไฟล์แนบ if (!string.IsNullOrEmpty(form["hidImgFileName"])) { // บันทึกข้อมูลลงกล่องขาออกของผู้ส่ง #region Save Image Files imgManager = new FileHelper(); imgManager.DirPath = "MessageFile/" + LogonCompID + "/" + emMessageSender.MessageID; imgManager.DirTempPath = "Temp/MessageFile/" + LogonCompID; SaveFileImage( imgManager.DirTempPath, imgManager.DirPath, form["hidImgFileName"]); #endregion string strFileName1 = form["hidImgFileName"]; string[] ArrayFileName1 = strFileName1.Split('.'); var Attach1 = new emMessageAttach(); Attach1.MessageID = emMessageSender.MessageID; Attach1.MessageCode = emMessageSender.MessageCode; Attach1.FileName = form["hidImgFileName"]; Attach1.FileType = "." + ArrayFileName1[1]; Attach1.FilePath = "https://ouikumstorage.blob.core.windows.net/upload/MessageFile/" + LogonCompID + "/" + emMessageSender.MessageID + "/" + form["hidImgFileName"]; Attach1.FileSize = 0; Attach1 = svMessage.InsertMessageFile(Attach1); // บันทึกข้อมูลลงกล่องขาเข้าของผู้รับ #region Save Image Files imgManager = new FileHelper(); imgManager.DirPath = "MessageFile/" + LogonCompID + "/" + emMessageReceiver.MessageID; imgManager.DirTempPath = "Temp/MessageFile/" + LogonCompID; SaveFileImage( imgManager.DirTempPath, imgManager.DirPath, form["hidImgFileName"]); #endregion string strFileName2 = form["hidImgFileName"]; string[] ArrayFileName2 = strFileName2.Split('.'); var Attach2 = new emMessageAttach(); Attach2.MessageID = emMessageReceiver.MessageID; Attach2.MessageCode = emMessageReceiver.MessageCode; Attach2.FileName = form["hidImgFileName"]; Attach2.FileType = "." + ArrayFileName2[1]; Attach2.FilePath = "https://ouikumstorage.blob.core.windows.net/upload/MessageFile/" + LogonCompID + "/" + emMessageReceiver.MessageID + "/" + form["hidImgFileName"]; Attach2.FileSize = 0; Attach2 = svMessage.InsertMessageFile(Attach2); } if (emMessageReceiver.ToCompID > 0) { #region GetToCompName sqlWhere = "CompID = " + emMessageReceiver.ToCompID + " AND IsDelete = 0"; var Company = svCompany.SelectData <b2bCompany>("CompID,CompName,ContactEmail", sqlWhere).First(); var toCompName = Company.CompName; var toCompEmail = Company.ContactEmail; #endregion #region Send Email if (svMessage.IsResult) { SendEmail(emMessageReceiver, toCompName, toCompEmail); } #endregion } else { if (svMessage.IsResult) { SendEmailNoMember(emMessageReceiver, form["hidNameNotMember"], form["hidEmailNotMember"]); } } } } GetStatusUser(); CountMessage(); return(View()); } else { return(Redirect(res.Pageviews.PvMemberSignUp)); } }
//[ValidateAntiForgeryToken] public ActionResult Contact( string hidToCompID, string hidToCompEmail, string MsgDetail, string IsImportance, string txtFromName, string txtFromEmail, string txtFromContactPhone, string txtSubject, string hidToCompName, string txtToEmail, string captcha, string captcha_id ) { Ouikum.Message.MessageService svMessage = new Ouikum.Message.MessageService(); var emMessageSender = new emMessage(); var emMessageReceiver = new emMessage(); int ToCompID = DataManager.ConvertToInteger(hidToCompID); string msgdetail = MsgDetail; var isResult = false; if (captcha == HttpContext.Session["captcha_" + captcha_id].ToString()) { //if (DataManager.ConvertToBool(IsImportance) == true) //{ // msgdetail += "<p><strong>" + res.Message_Center.lblContactImmediately + "</strong></p>"; //} #region Set Message if (LogonCompID > 0) { #region Sender emMessageSender.ToCompID = ToCompID; emMessageSender.Subject = txtSubject; emMessageSender.MsgDetail = msgdetail; emMessageSender.RootMessageID = 0; emMessageSender.MessageCode = emMessageSender.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageSender.MsgStatus = "2"; emMessageSender.IsSend = true; emMessageSender.SendDate = DateTimeNow; emMessageSender.IsFavorite = DataManager.ConvertToBool(IsImportance); emMessageSender.FromCompID = LogonCompID; emMessageSender.FromName = txtFromName; emMessageSender.FromEmail = LogonEmail; emMessageSender.MsgFolderID = 2; emMessageSender.FromContactPhone = txtFromContactPhone; emMessageSender.IsAttach = false; emMessageSender = svMessage.InsertMessage(emMessageSender); #endregion #region Receiver emMessageReceiver.ToCompID = ToCompID; emMessageReceiver.Subject = txtSubject; emMessageReceiver.MsgDetail = msgdetail; emMessageReceiver.RootMessageID = 0; emMessageReceiver.MessageCode = emMessageSender.MessageCode; emMessageReceiver.MsgStatus = "1"; emMessageReceiver.IsSend = false; emMessageReceiver.SendDate = DateTimeNow; emMessageReceiver.IsFavorite = DataManager.ConvertToBool(IsImportance); emMessageReceiver.FromCompID = LogonCompID; emMessageReceiver.FromName = txtFromName; emMessageReceiver.FromEmail = LogonEmail; emMessageReceiver.MsgFolderID = 1; emMessageReceiver.FromContactPhone = txtFromContactPhone; emMessageReceiver.IsAttach = false; #endregion if (ToCompID > 0) { #region Save Message emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); #endregion #region Send Email isResult = SendEmail(emMessageReceiver, hidToCompName, hidToCompEmail); #endregion } else { isResult = SendEmailNoMember(emMessageReceiver, hidToCompName, txtToEmail); } } else { #region Receiver emMessageReceiver.ToCompID = ToCompID; emMessageReceiver.Subject = txtSubject; emMessageReceiver.MsgDetail = msgdetail; emMessageReceiver.RootMessageID = 0; emMessageReceiver.MessageCode = emMessageReceiver.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageReceiver.MsgStatus = "1"; emMessageReceiver.MsgFolderID = 1; emMessageReceiver.IsSend = false; emMessageReceiver.SendDate = DateTimeNow; emMessageReceiver.IsFavorite = DataManager.ConvertToBool(IsImportance); emMessageReceiver.FromCompID = 0; emMessageReceiver.FromName = txtFromName; emMessageReceiver.FromEmail = txtFromEmail; emMessageReceiver.FromContactPhone = txtFromContactPhone; emMessageReceiver.IsAttach = false; #endregion if (ToCompID > 0) { #region Save Message emMessageReceiver = svMessage.InsertMessage(emMessageReceiver); #endregion #region Send Email isResult = SendEmail(emMessageReceiver, hidToCompName, hidToCompEmail); #endregion } else { #region Sender emMessageSender.ToCompID = ToCompID; emMessageSender.Subject = txtSubject; emMessageSender.MsgDetail = msgdetail; emMessageSender.RootMessageID = 0; emMessageSender.MessageCode = emMessageSender.ToCompID + "-" + GetTimeStamp() + "-" + svMessage.Generate_MessageCode(); emMessageSender.MsgStatus = "0"; emMessageSender.IsSend = false; emMessageSender.SendDate = DateTimeNow; emMessageSender.IsFavorite = DataManager.ConvertToBool(IsImportance); emMessageSender.FromCompID = LogonCompID; emMessageSender.FromName = txtFromName; emMessageSender.FromEmail = LogonEmail; emMessageSender.MsgFolderID = 0; emMessageSender.FromContactPhone = txtFromContactPhone; emMessageSender.IsAttach = false; emMessageSender = svMessage.InsertMessage(emMessageSender); #endregion isResult = SendEmailNoMember(emMessageSender, hidToCompName, txtToEmail); } } } //else //{ // return Json(new { IsResult = svCompany.IsResult, IsSendMail = isResult }, JsonRequestBehavior.AllowGet); //} #endregion GetStatusUser(); #region Update ContactCount string MsgContactProID = Request.Cookies["MsgContactProID"].Value; if (!string.IsNullOrEmpty(MsgContactProID)) { string[] strProductID = MsgContactProID.Split(','); for (int i = 0; i < strProductID.Length; i++) { AddContactCount(DataManager.ConvertToInteger(strProductID[i])); } } #endregion return(Json(new { IsResult = svMessage.IsResult, IsSendMail = isResult }, JsonRequestBehavior.AllowGet)); //return Json(true); }