Example #1
0
        public String WebReq(String Tel, String Msg, out String Campanha, out String ResultStatus)
        {
            var    Result = "";
            Hlp    Hlp;
            String ApiUrl = URL_PLATFORM;
            String Status = "";

            //WhatsAppSendPST Send;
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => { return(true); };
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            using (WebClient WebPost = new WebClient()) {
                NameValueCollection WebFields = null;
                Byte[] WebResponse            = null;

                try {
                    Hlp       = new Hlp();
                    WebFields = new NameValueCollection();

                    WebFields["action"]       = "sendsms";
                    WebFields["lgn"]          = Login;
                    WebFields["pwd"]          = Pass;
                    WebFields["content"]      = Msg;
                    WebFields["numbers"]      = Tel;
                    WebFields["type_service"] = "LONGCODE";
                    //WebFields["url_callback"] = "URL DE RETORNO";

                    WebResponse = WebPost.UploadValues(ApiUrl, "POST", WebFields);
                    Result      = HTTP_ENCODING.GetString(WebResponse);

                    //String[] Part = Result.Split(':');

                    dynamic Json = JValue.Parse(Result);
                    Status       = Json.status;
                    Campanha     = Json.data;
                    ResultStatus = Json.msg;
                } catch (Exception Err) {
                    throw new Exception(Err.Message);
                } finally {
                    WebFields   = null;
                    WebResponse = null;
                }
                return(Result);
            }
        }
Example #2
0
        public void SendEmail(String Msg)
        {
            Hlp Hlp = new Hlp();

            try {
                using (SmtpClient Smtp = new SmtpClient()) {
                    String    Body  = "";
                    DataTable Table = new DataTable();

                    //Config Servidor Email
                    Smtp.Host                  = Host;
                    Smtp.Port                  = Port;
                    Smtp.EnableSsl             = true;
                    Smtp.UseDefaultCredentials = false;
                    Smtp.Credentials           = new NetworkCredential(User, Pass);

                    Body = Hlp.MsgFormat(Msg, Destinatario_Nome, Email_Contato);

                    using (MailMessage Mail = new MailMessage()) {
                        //Armazenamento dos dados
                        Mail.From = new MailAddress(From);
                        Mail.To.Add(new MailAddress(Destinatario_Email));
                        //Mail.To.Add(new MailAddress("*****@*****.**"));
                        Mail.Subject    = Subject;
                        Mail.IsBodyHtml = true;
                        Mail.Body       = Body;

                        Smtp.Send(Mail);

                        //Table.Rows.Add(Destinatario.Nome, "ENVIADO", Destinatario.Email, Obs);
                        Mail.Dispose();
                        Smtp.Dispose();
                    }
                }
            } catch (Exception Err) {
            }
        }