示例#1
0
        /// <summary>
        /// 以配置的发送方式批量发送消息。
        /// </summary>
        /// <param name="Msg"></param>
        public static void Send(List <MessageEntity> Msgs)
        {
            //多种发送方式
            foreach (MessageBase client in Clients)
            {
                bool isMail = client.GetType() == typeof(Mail.MessageMail);
                //多条消息
                foreach (MessageEntity msg in Msgs)
                {
                    if (isMail)
                    {
                        client.To = msg.EMails;
                    }

                    client.Subject  = msg.Title;
                    client.Body     = msg.Content;
                    client.Receiver = msg.Receiver;
                    client.Priority = MessagePriority.High;

                    try
                    {
                        client.Send();
                        msg.IsSended = true;
                        SLog.WriteLogWithDefaultTime(client.To + client.Body + "发送成功");
                    }
                    catch (Exception ex)
                    {
                        msg.IsSended = false;
                        SLog.WriteLogWithDefaultTime(ex.Message);
                        continue;
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// 以配置的发送方式发送消息。
        /// </summary>
        /// <param name="Msg"></param>
        public static void Send(MessageEntity Msg)
        {
            foreach (MessageBase client in Clients)
            {
                if (client.GetType() == typeof(Mail.MessageMail))
                {
                    client.To = Msg.EMails;
                }

                client.Subject  = Msg.Title;
                client.Body     = Msg.Content;
                client.Receiver = Msg.Receiver;
                client.Priority = MessagePriority.High;

                try
                {
                    client.Send();
                    Msg.IsSended = true;
                    SLog.WriteLogWithDefaultTime(client.To + client.Body + "发送成功");
                }
                catch (Exception ex)
                {
                    Msg.IsSended = false;
                    SLog.WriteLogWithDefaultTime(ex.Message);
                    continue;
                }
            }
        }