/// <summary> /// send net mail /// </summary> /// <param name="toList"></param> /// <param name="ccList"></param> /// <param name="bccList"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <param name="EnableSsl">use ssl. true for default. please set false for byd.</param> /// <returns></returns> public bool SendNetMail(IList <string> toList, IList <string> ccList, IList <string> bccList, string subject, string body, IList <string> attachments, bool EnableSsl) { return(NotifyHelper.SendNetMail(toList, ccList, bccList, subject, body, attachments, this.SenderName, this.SenderUser, this.SenderPassword, this.SmtpServer, this.SmtpPort, EnableSsl)); }
protected override bool Execute(object readyData) { try { if (readyData == null) { return(false); } string returnMessage = string.Empty; bool isSent = false; #region PM_ALT_MESSAGE IList <PM_ALT_MESSAGE> messages = _PM_ALT_MESSAGEBO.GetEntitiesToSend(); // foreach (PM_ALT_MESSAGE msg in messages) { if (msg.MsgType == 1)//邮件发送 { isSent = false; // string to = msg.MsgTo; string cc = msg.MsgCc; string bcc = msg.MsgBcc; string subject = msg.MsgSubject; string body = msg.MsgContent; body = System.Web.HttpUtility.HtmlDecode(body); // try { isSent = NotifyHelper.SendNetMail(to, cc, bcc, subject, body, msg.Attachments, this.SenderName, this.SenderUser, this.SenderPassword, this.SmtpServer, this.SmtpPort, false); msg.ErrorMsg = string.Empty; } catch (Exception ex) { msg.ErrorMsg = ex.Message; // _mesLog.LogException("Exception: " + returnMessage + ". StackTree: " + ex.Message + Environment.NewLine + ex.StackTrace, this.Name + ".Execute()", true); } // } else if (msg.MsgType == 2)//微信发送 { IList <Siemens.Simatic.Wechat.Common.CV_PM_WECHAT_NOTI> notiList = _CV_PM_WECHAT_NOTIBO.GetEntities(new Siemens.Simatic.Wechat.Common.CV_PM_WECHAT_NOTI { AlertID = msg.ObjectID }); if (notiList != null && notiList.Count > 0) { foreach (Siemens.Simatic.Wechat.Common.CV_PM_WECHAT_NOTI noti in notiList) { corpsecret = noti.SecretID; _PM_WECHAT_NOTIBO.Gettoken(corpid, corpsecret); if (msg.Format == WechatFormat.IMAGE) { ReturnValue rv = _PM_WECHAT_NOTIBO.SendImage(noti.AgentID.Value, msg.MsgSubject, msg.MsgContent, noti.UserIDs, false); msg.ErrorMsg = "SendImage: Success=[" + rv.Success + "]" + ",Message=[" + rv.Message + "]"; } else if (msg.Format == WechatFormat.TEXT) { ReturnValue rv = _PM_WECHAT_NOTIBO.SendText(noti.AgentID.Value, msg.MsgContent, noti.UserIDs, false); msg.ErrorMsg = "SendText: Success=[" + rv.Success + "]" + ",Message=[" + rv.Message + "]"; } else if (msg.Format == WechatFormat.CARD) { ReturnValue rv = _PM_WECHAT_NOTIBO.SendCard(noti.AgentID.Value, msg.MsgSubject, msg.MsgContent, msg.URL, "更多", "", "", noti.UserIDs); msg.ErrorMsg = "SendText: Success=[" + rv.Success + "]" + ",Message=[" + rv.Message + "]"; } } } } msg.SentCnt += 1; // msg.ModifiedOn = DateTime.Now; _PM_ALT_MESSAGEBO.UpdateSome(msg); } #endregion // if (!string.IsNullOrEmpty(returnMessage)) { _mesLog.LogException("Exception: " + returnMessage, this.Name + ".Execute()", true); } } catch (Exception ex) { _mesLog.LogException(ex.Message + Environment.NewLine + ex.StackTrace, this.Name + ".Execute()", true); } // return(true); }
/// <summary> /// send net mail /// </summary> /// <param name="to"></param> /// <param name="cc"></param> /// <param name="bcc"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <param name="EnableSsl">use ssl. true for default. please set false for byd.</param> /// <returns></returns> public bool SendNetMail(string to, string cc, string bcc, string subject, string body, string attachments, bool EnableSsl) { return(NotifyHelper.SendNetMail(to, cc, bcc, subject, body, attachments, this.SenderName, this.SenderUser, this.SenderPassword, this.SmtpServer, this.SmtpPort, EnableSsl)); }