コード例 #1
0
        public JsonResult SendMailToOwner(string userDetails, string toEmail, string orderId, string paymentId)
        {
            bool isOTPSent = false;

            try
            {
                SendMail    obj     = new SendMail();
                Credentials objCred = new Credentials();
                objCred.SMTPUser     = "******";
                objCred.SMTPPassword = "******";
                objCred.Host         = "smtp.gmail.com";
                objCred.Port         = 25;
                if (paymentId != "" && paymentId != null)
                {
                    objCred.Subject = "New order received with Order Id: " + orderId + " and payment Id: " + paymentId;
                }
                else
                {
                    objCred.Subject = "New COD order received with Order Id: " + orderId;
                }

                objCred.IsBodyHtml = true;
                objCred.EnableSsl  = true;
                objCred.Body       = "<html><body><div>" + userDetails.Trim() + "</div></body></html>";


                if (toEmail == "" || toEmail == null)
                {
                    isOTPSent = false;
                }
                else
                {
                    objCred.ToEmail = toEmail;
                    isOTPSent       = obj.Gmail(objCred);
                    isOTPSent       = true;
                }
            }
            catch (Exception ex)
            {
                objExceptionLoggingToSQL.LogAppException(ex.StackTrace);
                isOTPSent = false;
            }

            return(Json(isOTPSent));
        }