Exemplo n.º 1
0
        public string TriggerEmailWithAttachment(string toEmail, string toUsername, string emailSubject, string EmailContent, string fileBase64, string filename)
        {
            try
            {
                API sendinBlue = new mailinblue.API("d4jYbr0PcAFKJBg5");
                Dictionary <string, Object> data = new Dictionary <string, Object>();
                Dictionary <string, string> to   = new Dictionary <string, string>();

                to.Add(toEmail, toUsername);
                List <string> from_name = new List <string>();
                from_name.Add("*****@*****.**");
                from_name.Add("Reachelp Support");
                Dictionary <string, string> attachment = new Dictionary <string, string>();
                attachment.Add(filename, fileBase64);

                data.Add("to", to);
                data.Add("from", from_name);
                data.Add("subject", emailSubject);
                data.Add("html", EmailContent);
                data.Add("attachment", attachment);

                Object sendEmail = sendinBlue.send_email(data);
                return(sendEmail.ToString());
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 2
0
        public string TriggerEmail(IUsers users, string emailSubject, string EmailContent)
        {
            try
            {
                //API sendinBlue = new mailinblue.API("d4jYbr0PcAFKJBg5");                ;
                API sendinBlue = new mailinblue.API(ConfigurationManager.AppSettings["SENDINBLUE_API"].ToString());
                Dictionary <string, Object> data = new Dictionary <string, Object>();
                Dictionary <string, string> to   = new Dictionary <string, string>();


                to.Add(users.emailId, users.userName);
                List <string> from_name = new List <string>();
                //from_name.Add("*****@*****.**");
                //from_name.Add("Reachelp Support");
                from_name.Add(ConfigurationManager.AppSettings["FROM_ADD"].ToString());
                from_name.Add(ConfigurationManager.AppSettings["FROM_NAME"].ToString());

                data.Add("to", to);
                data.Add("from", from_name);
                data.Add("subject", emailSubject);
                data.Add("html", EmailContent);


                Object sendEmail = sendinBlue.send_email(data);
                return(sendEmail.ToString());
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            API test = new mailinblue.API("<access key>", "<secret key>");

            Console.Write(test.get_processes());
            Console.ReadKey(true);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            API test = new mailinblue.API("<access key>");
            Dictionary <string, int> data = new Dictionary <string, int>();

            data.Add("page", 1);
            data.Add("page_limit", 3);
            Object getProcesses = test.get_processes(data);

            Console.WriteLine(getProcesses);
            Console.ReadKey(true);
        }
 public void SendMail(Klant k)
 {
     {
         API sendinBlue = new mailinblue.API("r0GZv13CEFbk8yVq");
         Dictionary <string, string> to = new Dictionary <string, string>();
         to.Add(k.Email, k.Voornaam);
         List <string> from_name = new List <string>();
         from_name.Add("*****@*****.**");
         from_name.Add("Massage Santo");
         Dictionary <string, string> headers = new Dictionary <string, string>();
         headers.Add("Content-Type", "text/html; charset=iso-8859-1");
         headers.Add("X-param1", "value1");
         headers.Add("X-param2", "value2");
         headers.Add("X-Mailin-custom", "my custom value");
         headers.Add("X-Mailin-IP", "102.102.1.2");
         headers.Add("X-Mailin-Tag", "My tag");
         Object sendEmail = sendinBlue.send_email(to, "Gelukkige verjaardag", from_name, "Gelukkige verjaardag", "This is the text", new Dictionary <string, string>(), headers);
     }
 }
Exemplo n.º 6
0
        protected void ButtonMail_Click(object sender, EventArgs e)
        {
            string message = TextFacebook.InnerText;
            ///////////////////////////////////////////////// SEND IN BLUE //////////////////////////////////////////////////
            API sendinBlue = new mailinblue.API("ERWXqjT4mS3aA05V", 5000);    //Optional parameter: Timeout in MS
            Dictionary <string, Object> data = new Dictionary <string, Object>();
            Dictionary <string, string> to   = new Dictionary <string, string>();

            to.Add(TextDestination.Text, "to whom!");
            List <string> from_name = new List <string>();

            from_name.Add("*****@*****.**");
            from_name.Add("AREA.NET");
            //List<string> attachment = new List<string>();
            //attachment.Add("https://domain.com/path-to-file/filename1.pdf");
            //attachment.Add("https://domain.com/path-to-file/filename2.jpg");

            data.Add("to", to);
            data.Add("from", from_name);
            data.Add("subject", "AREA send in blue");
            data.Add("html", String.Concat("You post the following message on Facebook : ", message));
            //data.Add("attachment", attachment);

            Object sendEmail = sendinBlue.send_email(data);
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            string accessToken       = "EAAMDizLaZCQABAMqAXjW5FsQyRtLnaDlJaszDyep74w6srKfMP6ZC4ASW4KeRoLlmfrosZBXSRfsbRTRpHuM4R4REqtMMlF3TnNbyeMcpPQQV06fuwSnNuOPvdxjCSBpboIlMIZCDXP0UaExAha5dXCUUCkHAZB2H838yIaHmDZBYrk2B4p6w492apZAEHkAtKGsNpKTVVdawZDZD";
            var    objFacebookClient = new FacebookClient(accessToken);
            var    parameters        = new Dictionary <string, object>();

            parameters["message"] = message;
            try
            {
                objFacebookClient.Post("feed", parameters);
                LabelResult.ForeColor = System.Drawing.Color.Green;
                LabelResult.Visible   = true;
                LabelResult.Text      = "Message posted on Facebook and sended to " + TextDestination.Text + " !";
            }
            catch (FacebookApiException fbex)
            {
                LabelResult.Visible = true;
                LabelResult.Text    = fbex.Message;
            }
        }
        public void Mails()
        {
            List <Klant> klanten = new List <Klant>();

            klanten = GetKlanten();
            API sendinBlue = new mailinblue.API("r0GZv13CEFbk8yVq");

            foreach (Klant k in klanten)
            {
                Dictionary <string, string> attributes = new Dictionary <string, string>();
                attributes.Add("NAME", k.Voornaam);
                attributes.Add("SURNAME", k.Naam);
                List <int> listid = new List <int>();
                listid.Add(1);
                listid.Add(4);
                listid.Add(4);
                List <int> listid_unlink = new List <int>();
                listid_unlink.Add(2);
                listid_unlink.Add(5);
                Object createUpdatetUser = sendinBlue.create_update_user(k.Email, attributes, 0, listid, listid_unlink, 0);
                Console.WriteLine(createUpdatetUser);
            }
        }
Exemplo n.º 8
0
        public SMSReturn SendSMS(string sFrom, string sTo, string sText, string sMo = "")
        {
            Dictionary <string, string> SMSData = new Dictionary <string, string>();

            SMSData.Add("to", sTo);
            SMSData.Add("from", sFrom);
            SMSData.Add("text", sText);
            SMSData.Add("type", "marketing");
            SMSData.Add("tag", "Tag1");
            SMSData.Add("web_url", "http://example.com");

            API       sendinBlue = new mailinblue.API(ConfigurationManager.AppSettings["SendInBlueAccessKey"]);
            Object    sendSms    = new Object();
            SMSReturn result     = new SMSReturn();

            try
            {
                sendSms = sendinBlue.send_sms(SMSData);
                result  = JsonConvert.DeserializeObject <SMSReturn>(sendSms.ToString());
            }
            catch
            {
                try
                {
                    SMSReturnError errorResult;
                    errorResult    = JsonConvert.DeserializeObject <SMSReturnError>(sendSms.ToString());
                    result.code    = errorResult.code;
                    result.message = errorResult.message;
                }
                catch (Exception ex)
                {
                    result.code    = "Failure";
                    result.message = ex.Message + " in SendInBlue.SendSMS. [" + sendSms.ToString() + "]";
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public static void SendAttachment(Object objMail, string UserName)
        {
            MailContent objMailContent = (MailContent)objMail;

            System.Net.Mime.ContentType typeHTML = new System.Net.Mime.ContentType("text/html");
            AlternateView viewHTML = AlternateView.CreateAlternateViewFromString(objMailContent.emailBody, typeHTML);

            viewHTML.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
            //mailMessage.AlternateViews.Add(viewHTML);

            try
            {
                API sendinBlue = new mailinblue.API("sHnhr4w0fTbga7c3"); //add your api key here

                Dictionary <string, Object> data = new Dictionary <string, Object>();
                Dictionary <string, string> to   = new Dictionary <string, string>();
                to.Add(objMailContent.toEmailaddress, "to whom!");

                //to.Add("*****@*****.**", "to whom!");
                List <string> from_name = new List <string>();
                from_name.Add("*****@*****.**");

                //from_name.Add("from email!");
                //List<string> attachment = new List<string>();
                //attachment.Add("https://domain.com/path-to-file/filename1.pdf");
                //attachment.Add("https://domain.com/path-to-file/filename2.jpg");

                data.Add("to", to);
                data.Add("from", from_name);
                data.Add("subject", objMailContent.subject);
                data.Add("html", objMailContent.emailBody);
                //data.Add("attachment", attachment);

                Object sendEmail = sendinBlue.send_email(data);
                string InnerHtml = sendEmail.ToString();

                // Get your account information, plan and credits details
                //GetAccount result = apiInstance.GetAccount();

                //Debug.WriteLine(result);
            }
            catch (Exception ex)
            {
                throw (ex);
            }


            //commented on 12sep2020

            /* MailContent objMC = (MailContent)objMail;
             * if (objMC.toEmailaddress.StartsWith("admin"))
             * {
             *
             * }
             *
             * SmtpClient smtpClient = new SmtpClient();
             * MailMessage mailMessage = new MailMessage();
             *
             *
             *
             * bool flag = false;
             * bool UseSMTPSSL = false;
             * if (!string.IsNullOrEmpty(authenticate))
             * {
             *  flag = Convert.ToBoolean(authenticate);
             * }
             * if (!string.IsNullOrEmpty(UsesmtpSSL))
             * {
             *  UseSMTPSSL = Convert.ToBoolean(UsesmtpSSL);
             * }
             *
             * string host = mailServer;
             *
             * string address = fromEmailID;
             *
             *
             * ////if (UserName != null)
             * //if (objMC.BranchId > 0)
             * //{
             *
             * //    Branch obj = new Branch();
             * //    string email = obj.GetEmailId(objMC.BranchId);
             * //    if (email != "")
             * //    {
             * //        address = email;
             * //    }
             * //}
             *
             * if (!String.IsNullOrEmpty(objMC.From))
             * {
             *  address = objMC.From;
             * }
             *
             * MailAddress from = new MailAddress(address, objMC.displayName);
             *
             * if (objMC.CopyTo.Count > 0)
             * {
             *  foreach (string copyTo in objMC.CopyTo)
             *  {
             *      if (!string.IsNullOrEmpty(copyTo))
             *      {
             *          mailMessage.CC.Add(new MailAddress(copyTo));
             *      }
             *  }
             * }
             *
             *
             * try
             * {
             *
             *  smtpClient.EnableSsl = false;
             *  smtpClient.Host = host;
             *  mailMessage.From = from;
             *  smtpClient.Port = 25;
             *  mailMessage.To.Add(objMC.toEmailaddress);
             *  mailMessage.Subject = objMC.subject;
             *  mailMessage.IsBodyHtml = true;
             *
             *  if (objMC.EventData != null)
             *  {
             *      mailMessage.AlternateViews.Add(objMC.EventData);
             *
             *      System.Net.Mime.ContentType typeHTML = new System.Net.Mime.ContentType("text/html");
             *      AlternateView viewHTML = AlternateView.CreateAlternateViewFromString(objMC.emailBody, typeHTML);
             *      viewHTML.TransferEncoding = System.Net.Mime.TransferEncoding.SevenBit;
             *      mailMessage.AlternateViews.Add(viewHTML);
             *  }
             *  else
             *  {
             *      mailMessage.Body = objMC.emailBody;
             *  }
             *  if (objMC.strAttachment != null)
             *  {
             *      foreach (Attachment a in objMC.strAttachment)
             *      {
             *
             *          mailMessage.Attachments.Add(a);
             *
             *      }
             *  }
             *  if (flag)
             *  {
             *      NetworkCredential credentials = new NetworkCredential(userId, password);
             *      smtpClient.UseDefaultCredentials = false;
             *      smtpClient.Credentials = credentials;
             *  }
             *  else
             *  {
             *      smtpClient.UseDefaultCredentials = true;
             *  }
             *
             *  string sendMail = AllowSendMails;
             *
             *
             *  if (string.IsNullOrEmpty(sendMail) || (sendMail.ToUpper() != "NO"))
             *  {
             *      if (!string.IsNullOrEmpty(objMC.emailBody))
             *      {
             *          smtpClient.Send(mailMessage);
             *          smtpClient.Dispose();
             *      }
             *
             *  }
             *
             *
             *  // update Mail log status of IsDelivered
             *  //MailBoxManager.UpdateDeliveryStatus(MailerLogID, true, "Successfully Send.");
             *
             * }
             * catch (Exception ex)
             * {
             *  //ErrorLogger.Log(ex.Message);
             *  //ErrorLogger.Log(ex.StackTrace);
             *  //update Mail log status of IsDelivered = False and Logtext = ex.mesage
             *  //logger.ErrorFormat(ex.Message);
             *  throw ex;
             * }*/
        }
Exemplo n.º 10
0
 public static void Main(string[] args)
 {
     API test = new mailinblue.API("<access key>","<secret key>");
     Console.Write(test.get_processes());
     Console.ReadKey(true);
 }