예제 #1
0
        // Added by Bharat on 12/May/2017
        public JsonResult GetMailData(string fields)
        {
            string retJSON = "";

            if (Session["ctx"] != null)
            {
                VAdvantage.Utility.Ctx ctx = Session["ctx"] as Ctx;
                int R_MailText_ID;
                R_MailText_ID = Util.GetValueOfInt(fields);
                MMailText mt       = new MMailText(ctx, R_MailText_ID, null);
                string    mailText = mt.GetMailText();
                retJSON = JsonConvert.SerializeObject(mailText);
            }
            return(Json(retJSON, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// Prepare notice message.
        /// </summary>
        /// <param name="list">list of the values changed.</param>
        private void prepareNotificMsg(List <String> list)
        {
            if (mailText_ID == 0)
            {
                message = new StringBuilder();
                //		UpdatedBy: Joe
                int   UpdatedBy = GetCtx().GetAD_User_ID();
                MUser from      = MUser.Get(GetCtx(), UpdatedBy);
                if (from != null)
                {
                    message.Append(Msg.Translate(GetCtx(), "UpdatedBy")).Append(": ")
                    .Append(from.GetName());
                }
                //		LastAction/Created: ...
                if (_req.GetDateLastAction() != null)
                {
                    message.Append("\n").Append(Msg.Translate(GetCtx(), "DateLastAction"))
                    .Append(": ").Append(_req.GetDateLastAction());
                }
                else
                {
                    message.Append("\n").Append(Msg.Translate(GetCtx(), "Created"))
                    .Append(": ").Append(_req.GetCreated());
                }
                //	Changes
                for (int i = 0; i < list.Count; i++)
                {
                    X_R_Request req = new X_R_Request(GetCtx(), 0, null);

                    String columnName = (String)list[i];
                    message.Append("\n").Append(Msg.GetElement(GetCtx(), columnName))
                    .Append(": ").Append(_reqAction.getColumnValue(columnName))
                    .Append(" -> ").Append(_req.getColumnValue(columnName));
                }
                //	NextAction
                if (_req.GetDateNextAction() != null)
                {
                    message.Append("\n").Append(Msg.Translate(GetCtx(), "DateNextAction"))
                    .Append(": ").Append(_req.GetDateNextAction());
                }
                message.Append(SEPARATOR)
                .Append(_req.GetSummary());
                if (_req.GetResult() != null)
                {
                    message.Append("\n----------\n").Append(_req.GetResult());
                }
                message.Append(_req.GetMailTrailer(null));
            }
            else
            {
                message = new StringBuilder();

                MMailText text = new MMailText(GetCtx(), mailText_ID, null);
                text.SetPO(_req, true); //Set _Po Current value
                subject += _req.GetDocumentNo() + ": " + text.GetMailHeader();

                message.Append(text.GetMailText(true));
                if (_req.GetDateNextAction() != null)
                {
                    message.Append("\n").Append(Msg.Translate(GetCtx(), "DateNextAction"))
                    .Append(": ").Append(_req.GetDateNextAction());
                }

                // message.Append(GetMailTrailer(null));
            }
        }
예제 #3
0
        }       //	sendBPGroup

        /// <summary>
        ///	Send Individual Mail
        /// </summary>
        /// <param name="Name">user name</param>
        /// <param name="AD_User_ID">user</param>
        /// <param name="unsubscribe">unsubscribe message</param>
        /// <returns>true if mail has been sent</returns>
        private Boolean SendIndividualMail(String Name, int AD_User_ID, String unsubscribe)
        {
            //	Prevent two email
            int ii = AD_User_ID;

            if (_list.Contains(ii))
            {
                //return null;
                return(false);
            }
            _list.Add(ii);
            //
            MUser to = new MUser(GetCtx(), AD_User_ID, null);

            if (to.IsEMailBounced())                    //	ignore bounces
            {
                //return null;
                return(false);
            }
            _MailText.SetUser(AD_User_ID);              //	parse context
            String message = _MailText.GetMailText(true);

            //	Unsubscribe
            if (unsubscribe != null)
            {
                message += unsubscribe;
            }
            //
            EMail email = _client.CreateEMail(_from, to, _MailText.GetMailHeader(), message);

            if (email == null)
            {
                //return Boolean.FALSE;
                return(false);
            }
            if (_MailText.IsHtml())
            {
                email.SetMessageHTML(_MailText.GetMailHeader(), message);
            }
            else
            {
                email.SetSubject(_MailText.GetMailHeader());
                email.SetMessageText(message);
            }
            if (!email.IsValid() && !email.IsValid(true))
            {
                log.Warning("NOT VALID - " + email);
                to.SetIsActive(false);
                to.AddDescription("Invalid EMail");
                to.Save();
                //return Boolean.FALSE;
                return(false);
            }
            Boolean OK = EMail.SENT_OK.Equals(email.Send());

            new MUserMail(_MailText, AD_User_ID, email).Save();
            if (OK)
            {
                log.Fine(to.GetEMail());
            }
            else
            {
                log.Warning("FAILURE - " + to.GetEMail());
            }
            AddLog(0, null, null, (OK ? "@OK@" : "@ERROR@") + " - " + to.GetEMail());
            return(OK);
        }