Example #1
0
        public static void SendTextMessage(string cellNumber, CellCarriers carrier, string otpCode)
        {
            try
            {
                string cellEmail = RetrieveCellCarrierMailbox(carrier, cellNumber);

                MailMessage message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");
                message.To.Add(new MailAddress(cellEmail));

                message.Subject = "One Time Pin";
                message.Body    = otpCode;

                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "test!");
                smtp.EnableSsl             = true;
                smtp.Send(message);
            }
            catch (SmtpException exception)
            {
                LoggingUtility.TraceException(exception, System.Diagnostics.TraceEventType.Error);
            }
        }
        public static void SendTextMessage(string cellNumber, CellCarriers carrier, string otpCode)
        {
            try
            {
                string cellEmail = RetrieveCellCarrierMailbox(carrier, cellNumber);

                MailMessage message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");
                message.To.Add(new MailAddress(cellEmail));

                message.Subject = "One Time Pin";
                message.Body = otpCode;

                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "test!");
                smtp.EnableSsl = true;
                smtp.Send(message);
            }
            catch (SmtpException exception)
            {
                LoggingUtility.TraceException(exception, System.Diagnostics.TraceEventType.Error);
            }
        }
        private static string RetrieveCellCarrierMailbox(CellCarriers carrier, string cellPhone)
        {
            string cellmailboxaddress;
            switch (carrier)
            {
                case CellCarriers.ATT:
                    cellmailboxaddress = String.Format("{0}@txt.att.net", cellPhone);
                    break;

                default:
                    throw new Exception("Unrecognized carrier");
            }

            return cellmailboxaddress;
        }
Example #4
0
        private static string RetrieveCellCarrierMailbox(CellCarriers carrier, string cellPhone)
        {
            string cellmailboxaddress;

            switch (carrier)
            {
            case CellCarriers.ATT:
                cellmailboxaddress = String.Format("{0}@txt.att.net", cellPhone);
                break;

            default:
                throw new Exception("Unrecognized carrier");
            }

            return(cellmailboxaddress);
        }