protected override void SendSms(Message message)
 {
     if (!String.IsNullOrWhiteSpace(sid))
     {
         var client = new HttpClient();
         client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", BasicAuthToken);
         var result = client.PostAsync(Url, GetBody(message)).Result;
         result.EnsureSuccessStatusCode();
     }
 }
        HttpContent GetBody(Message msg)
        {
            var values = new KeyValuePair<string, string>[]
            {
                new KeyValuePair<string, string>("From", fromPhone),
                new KeyValuePair<string, string>("To", msg.To),
                new KeyValuePair<string, string>("Body", msg.Body),
            };

            return new FormUrlEncodedContent(values);
        }
        protected virtual void DeliverMessage(string email, string subject, string body)
        {
            subject = String.Format("[{0}] {1}",
                appInfo.ApplicationName,
                subject);

            var msg = new Message
            {
                To = email,
                Subject = subject,
                Body = body
            };
            this.messageDelivery.Send(msg);
        }
 public IHttpActionResult TestMessageTemplate(Guid id)
 {
     if (id == default(Guid))
         return BadRequest("MessageTemplate id cannot be empty.");
     ClaimsPrincipal principal = HttpContext.Current.User as ClaimsPrincipal;
     if (principal == null)
         return NotFound();
     Claim emailClaim = principal.FindFirst(ClaimTypes.Email);
     if (emailClaim == null || string.IsNullOrEmpty(emailClaim.Value))
         return BadRequest("Cannot find email address.");
     string to = emailClaim.Value.Trim();
     IMessageTemplateService messageTemplateServce = IoC.GetService<IMessageTemplateService>();
     MessageTemplate template = messageTemplateServce.GetById(id);
     if (template == null)
         return BadRequest(string.Format("Cannot find email template {0}.", id));
     string subject = string.IsNullOrEmpty(template.Subject) ? null : Tokenize(template.Subject);
     string body = string.IsNullOrEmpty(template.Body) ? null : Tokenize(template.Body);
     var smtp = new SmtpMessageDelivery();
     var msg = new Message
     {
         To = to,
         Subject = "[Email Template Test] " + subject,
         Body = body
     };
     smtp.Send(msg);
     SessionMessageManager.SetMessage(MessageType.Success, MessageBehaviors.StatusBar, "Test email is sent.");
     return Ok();
 }
 public void Send(Message msg)
 {
 }
Example #6
0
 protected abstract void SendSms(Message message);