Exemplo n.º 1
0
        public static bool SendEmailToGroup(List <UserBasic> lMember, Messages message, int iUserId, List <Attachment> lAttach)
        {
            MailMessage mailMessage = new MailMessage();

            if (lAttach != null)
            {
                foreach (var img in lAttach)
                {
                    mailMessage.Attachments.Add(img);
                }
            }
            mailMessage.From    = new MailAddress(message.nvFrom);
            mailMessage.Subject = message.nvSubject;
            mailMessage.Body    = message.nvMessage;
            for (int i = 0; i < lMember.Count; i++)
            {
                if (lMember[i].nvEmail != null && lMember[i].nvEmail != "")
                {
                    //To ליסט של כתובות מייל
                    mailMessage.Bcc.Add(new MailAddress(lMember[i].nvEmail));
                }
            }
            try
            {
                using (SmtpClient smtpClient = new SmtpClient())
                {
                    smtpClient.Send(mailMessage);
                }
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "sendEmailToGroup, Email, try1");
                return(false);
            }
            try
            {
                foreach (var item in lMember)
                {
                    MessageCust messageCust = new MessageCust();
                    messageCust.iCreateUserId = iUserId;
                    messageCust.nvSubject     = message.nvSubject;
                    messageCust.nvComment     = message.nvMessage;
                    messageCust.iUserId       = item.iUserId;
                    bool res = MessageCust.CreateNewMessage(messageCust);
                    if (!res)
                    {
                        return(res);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.ExceptionLog(ex.Message, "sendEmailToGroup, Email, try2");
                return(false);
            }
        }
Exemplo n.º 2
0
 public static bool CreateNewMessage(MessageCust message)
 {
     try
     {
         List <SqlParameter> parameters = new List <SqlParameter>();
         parameters.AddRange(ObjectGenerator <MessageCust> .GetSqlParametersFromObject(message));
         DataSet ds = SqlDataAccess.ExecuteDatasetSP("TMessage_INS", parameters);
         return(true);
     }
     catch (Exception ex)
     {
         Log.ExceptionLog(ex.Message, "CreateNewMessage");
         return(false);
     }
 }
Exemplo n.º 3
0
        public static string SendSMSToOne(User member, Messages message, int iUserId)
        {
            StringBuilder sbXml = new StringBuilder();

            sbXml.Append("<Inforu>");
            sbXml.Append("<User>");
            sbXml.Append("<Username>" + "webit" + "</Username>");
            sbXml.Append("<Password>" + "2222953 " + "</Password>");
            sbXml.Append("</User>");
            sbXml.Append("<Content Type=\"sms\">");
            sbXml.Append("<Message>" + "<![CDATA[" + message.nvMessage + "]]>" + "</Message>");
            sbXml.Append("</Content>");
            sbXml.Append("<Recipients>");
            sbXml.Append("<PhoneNumber>" + message.nvTo + "</PhoneNumber>");
            sbXml.Append("</Recipients>");
            sbXml.Append("<Settings>");
            sbXml.Append("<SenderNumber>" + message.nvFrom + "</SenderNumber>");


            sbXml.Append("<MessageInterval>" + 0 + "</MessageInterval>");

            sbXml.Append("</Settings>");
            sbXml.Append("</Inforu>");
            string strXML = HttpUtility.UrlEncode(sbXml.ToString(), System.Text.Encoding.UTF8);
            string result = PostDataToURL("http://api.inforu.co.il/SendMessageXml.ashx", "InforuXML=" + strXML);

            MessageCust messageCust = new MessageCust();

            messageCust.iCreateUserId = iUserId;
            messageCust.nvSubject     = message.nvSubject;
            messageCust.nvComment     = message.nvMessage;
            messageCust.iUserId       = member.iUserId;
            bool res = MessageCust.CreateNewMessage(messageCust);

            return(result);
        }