username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using CY.Config;
using CY.Infrastructure.DESEncrypt;
using CY.Infrastructure.Common;
 
namespace CY.SendMessage
{
    public static class SendMessge
    {
        private static CY.SendMessage.ServerSDK.LinkWS webService = null;
 
        static SendMessge()
        {
            if (webService == null)
            {
                webService = new CY.SendMessage.ServerSDK.LinkWS();
                webService.Url = "http://mb345.com/WS/linkWS.asmx";
            }
        }
 
        //短信帐号
        //账号:YG00001
        //密码:733955
        #region 发送短信
 
        /// <summary>
        /// 发送文本消息 - 异步  返回1表示成功,其它为错误信息
        /// </summary>
        /// <param name="phones">手机号码字符串,请用半角逗号分隔(单次提交上限1000个)</param>
        /// <param name="contents">短信内容,手机限70字,小灵通限54字,超长系统自动拆分</param>
        /// <param name="setTime">发送时间(格式为:yyyy-mm-dd HH:mm),即时发送请传空值</param>
        /// <returns></returns>
        public static bool SendSMS(string phones, string contents, string setTime)
        {
            string msg = "";
            int result = webService.BatchSend(WebInfo.Instance.SMSLoginName.ToString2(), DESEncrypt.Decrypt(WebInfo.Instance.SMSPwd.ToString2()), phones, contents + "【川印】", "", setTime);
            switch (result)
            {
                case -1:
                    msg = "帐号未注册";
                    break;
                case -2:
                    msg = "其他错误";
                    break;
                case -3:
                    msg = "密码错误";
                    break;
                case -4:
                    msg = "手机号码格式不对";
                    break;
                case -5:
                    msg = "余额不足";
                    break;
                case -6:
                    msg = "定时发送时间不是有效时间格式";
                    break;
                case -7:
                    msg = "内容为空或者超过上限(500)";
                    break;
                case -8:
                    msg = "定时时间格式错误";
                    break;
                case 0:
                    msg = "1";//成功
                    break;
                case 1:
                    msg = "1";//成功
                    break;
                default:
                    msg = "未知错误";
                    break;
            }
            if (msg == "1")
                return true;
            else
            {
                return false;
                //Common.ExceptionEx.MyExceptionLog.AddLogError(msg);
            }
        }
 
        #endregion
 
        public static string GetBalance()
        {
            string sa = webService.SelSum(WebInfo.Instance.SMSLoginName.ToString2(), DESEncrypt.Decrypt(WebInfo.Instance.SMSPwd.ToString2())).ToString();
            return sa;
        }
 
        public static bool SendEmail(string subject, string content, string email)
        {
            try
            {
                MailMessage mailmessage = new MailMessage();
                SmtpClient smtp = new SmtpClient();
                smtp.Host = WebInfo.Instance.EmailServer.ToString2();
                smtp.Port = Convert.ToInt32(WebInfo.Instance.EmailPort.ToString2());
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = new System.Net.NetworkCredential(WebInfo.Instance.Email.ToString2(), DESEncrypt.Decrypt(WebInfo.Instance.EmailPwd.ToString2()));
                smtp.EnableSsl = false;
                mailmessage.To.Clear();
                mailmessage.To.Add(email);
                mailmessage.From = new MailAddress(WebInfo.Instance.Email.ToString2(), WebInfo.Instance.EmailLoginName.ToString2(), System.Text.Encoding.UTF8);
                mailmessage.Subject = subject;
                mailmessage.SubjectEncoding = System.Text.Encoding.UTF8;
                mailmessage.Body = content;
                mailmessage.IsBodyHtml = true;
                mailmessage.BodyEncoding = System.Text.Encoding.UTF8;
                mailmessage.Priority = MailPriority.High;
 
                smtp.Send(mailmessage);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
 
        public static bool SendEmailMemberTest(string subject, string content, string email, string emailsmtp, string emailname, string emailaddress, string emailpwd, string port)
        {
            try
            {
                MailMessage mailmessage = new MailMessage();
                SmtpClient smtp = new SmtpClient();
                smtp.Host = emailsmtp;
                smtp.Port = Convert.ToInt32(port);
                smtp.UseDefaultCredentials = true;
                smtp.Credentials = new System.Net.NetworkCredential(emailaddress, DESEncrypt.Decrypt(emailpwd));
                smtp.EnableSsl = false;
                mailmessage.To.Clear();
                mailmessage.To.Add(email);
                mailmessage.From = new MailAddress(emailaddress, emailname, System.Text.Encoding.UTF8);
                mailmessage.Subject = subject;
                mailmessage.SubjectEncoding = System.Text.Encoding.UTF8;
                mailmessage.Body = content;
                mailmessage.IsBodyHtml = true;
                mailmessage.BodyEncoding = System.Text.Encoding.UTF8;
                mailmessage.Priority = MailPriority.High;
 
                smtp.Send(mailmessage);
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
    }
}