Ejemplo n.º 1
0
        void btn_Click(object sender, EventArgs e)
        {
            BP.Sys.SMS msg = new BP.Sys.SMS();
            msg.Title  = this.Pub1.GetTextBoxByID("TB_Title").Text;
            msg.Doc    = this.Pub1.GetTextBoxByID("TB_Doc").Text;
            msg.Sender = WebUser.No;
            msg.RDT    = DataType.CurrentDataTime;

            string acces = this.Pub1.GetTextBoxByID("TB_Emps").Text.Trim();

            if (acces.Length == 0)
            {
                throw new Exception("请输入或者选择接受人.");
            }

            if (msg.Title.Length == 0)
            {
                throw new Exception("请输入标题.");
            }

            acces = acces.Replace(";", ",");
            acces = acces.Replace(";;", ",");
            acces = acces.Replace(" ", ",");
            acces = acces.Replace(",,", ",");

            string[] strs = acces.Split(',');
            foreach (string str in strs)
            {
                if (str == null || str == "")
                {
                    continue;
                }

                msg.MsgAccepter = str;
                msg.MyPK        = DBAccess.GenerOID().ToString();
                msg.Insert();
            }

            BP.DA.Paras ps = new BP.DA.Paras();
            ps.Add("Sender", WebUser.No);
            ps.Add("Receivers", msg.MsgAccepter);
            ps.Add("Title", msg.Title);
            ps.Add("Context", msg.Doc);
            try
            {
                DBAccess.RunSP("CCstaff", ps);
            }
            catch (Exception ex)
            {
                this.ToMsgPage("发送消息出现错误:" + ex.Message);
                return;
            }
            this.ToMsgPage("您的信息已经成功的发送到:" + acces);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送邮件。
        /// </summary>
        /// <param name="sms"></param>
        public void SendMail(BP.Sys.SMS sms)
        {
            //如果向 ccim 写入消息。
            if (this.CB_IsWriteToCCIM.Checked)
            {
                try
                {
                    Glo.SendMessage(sms.MyPK, DateTime.Now.ToString(), sms.Title + "\t\n" + sms.Doc, sms.MsgAccepter);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "错误");
                    return;
                }
            }

            if (string.IsNullOrEmpty(sms.MsgAccepter))
            {
                BP.WF.Port.WFEmp emp = new BP.WF.Port.WFEmp(sms.SendToEmpID);
                if (sms.MsgType == 0)
                {
                    sms.MsgAccepter = emp.Email;
                }
                else
                {
                    sms.MsgAccepter = emp.Tel;
                }
            }

            System.Net.Mail.MailMessage myEmail = new System.Net.Mail.MailMessage();
            myEmail.From = new MailAddress("*****@*****.**", "ccflow", System.Text.Encoding.UTF8);

            myEmail.To.Add(sms.MsgAccepter);
            myEmail.Subject         = sms.Title;
            myEmail.SubjectEncoding = System.Text.Encoding.UTF8;//邮件标题编码

            myEmail.Body         = sms.Doc;
            myEmail.BodyEncoding = System.Text.Encoding.UTF8; //邮件内容编码
            myEmail.IsBodyHtml   = true;                      //是否是HTML邮件

            myEmail.Priority = MailPriority.High;             //邮件优先级

            SmtpClient client = new SmtpClient();

            client.Credentials = new System.Net.NetworkCredential(SystemConfig.GetValByKey("SendEmailAddress", "*****@*****.**"),
                                                                  SystemConfig.GetValByKey("SendEmailPass", "ccflow123"));
            //上述写你的邮箱和密码
            client.Port      = SystemConfig.GetValByKeyInt("SendEmailPort", 587); //使用的端口
            client.Host      = SystemConfig.GetValByKey("SendEmailHost", "smtp.gmail.com");
            client.EnableSsl = SystemConfig.GetValByKeyBoolen("SendEmailEnableSsl", true);

            object userState = myEmail;

            try
            {
                client.SendAsync(myEmail, userState);
                sms.HisMsgSta = BP.Sys.MsgSta.RunOK;
                sms.Update();
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BP.Sys.SMS msg = new BP.Sys.SMS();
            switch (this.DoType)
            {
            case "Re":
                //msg.MyPK = this.RefOID;
                //if (msg.Accepter != WebUser.No)
                //{
                //    //return;
                //}
                //msg.Title = "RE:" + msg.Title;
                //msg.Doc = " ----------------- " + msg.Doc;
                //msg.Accepter = msg.Sender;
                break;

            default:
                if (this.WorkID != 0 && this.FK_Node != 0)
                {
                    Node nd = new Node(this.FK_Node);
                    Work wk = nd.HisWork;
                    wk.OID = this.WorkID;
                    wk.Retrieve();

                    string msgInfo = "\t\n ************** 工作信息 **************";
                    Attrs  attrs   = wk.EnMap.Attrs;
                    foreach (Attr attr in attrs)
                    {
                        if (attr.UIVisible == false)
                        {
                            continue;
                        }

                        if (attr.IsFKorEnum)
                        {
                            continue;
                        }

                        msgInfo += "\t\n" + attr.Desc + ": " + wk.GetValStrByKey(attr.Key);
                    }
                    msg.Doc = msgInfo;
                }
                break;
            }
            this.Pub1.AddTable("width='95%'");
            if (WebUser.IsWap)
            {
                this.Pub1.AddCaptionLeft("<a href='./../Home.aspx' ><img src='./../Img/Home.gif' border=0>Home</a> - <a href='./../../WAP/Msg.aspx' >列表</a>");
            }
            //else
            //    this.Pub1.AddCaption("&nbsp;&nbsp;&nbsp;信息发送");

            this.Pub1.AddTR();
            this.Pub1.AddTDTitle("width=10%", "<b>接受人</b>");
            TextBox tb = new TextBox();

            tb.ID                  = "TB_Emps";
            tb.Columns             = 80;
            tb.Text                = msg.MsgAccepter;
            tb.Attributes["Width"] = "100%";
            this.Pub1.AddTD(tb);
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            this.Pub1.AddTDTitle("width=10%", "<b>标题</b>");
            tb                     = new TextBox();
            tb.ID                  = "TB_Title";
            tb.Columns             = 80;
            tb.Text                = msg.Title;
            tb.Attributes["Width"] = "100%";
            this.Pub1.AddTD(tb);
            this.Pub1.AddTREnd();

            this.Pub1.AddTR();
            tb                     = new TextBox();
            tb.ID                  = "TB_Doc";
            tb.Rows                = 15;
            tb.Columns             = 70;
            tb.Text                = msg.Doc;
            tb.TextMode            = TextBoxMode.MultiLine;
            tb.Attributes["Width"] = "100%";
            this.Pub1.AddTD("colspan=2", tb);
            this.Pub1.AddTREnd();

            this.Pub1.AddTRSum();
            Button btn = new Button();

            btn.CssClass = "Btn";
            btn.ID       = "Btn_Send";
            btn.Text     = "  发 送  ";
            btn.Click   += new EventHandler(btn_Click);
            this.Pub1.AddTD("colspan=2", btn);
            this.Pub1.AddTREnd();
            this.Pub1.AddTableEnd();
        }