Beispiel #1
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);
        }