示例#1
0
        public void MarkEmailAsProcessed(IMailboxSettings mailboxSettings, Email email)
        {
            lock (_key)
            {
                _mailAdaptor.MarkMessageAsRead(mailboxSettings, long.Parse(email.EmailUid));

                _mailAdaptor.RemoveLabelFromMessage(mailboxSettings, long.Parse(email.EmailUid),
                    _mailboxLabels.SmsProcessingLabel);

                _mailAdaptor.ApplyLabelToMessage(mailboxSettings, long.Parse(email.EmailUid),
                    _mailboxLabels.SmsSentLabel);
            }
        }
示例#2
0
        public static IMail MapToIMail(Email message)
        {
            var replyBuilder = ((IMail)message.OriginalEmail).Reply();

            replyBuilder.Text = message.PlainTextBody;

            if (!string.IsNullOrEmpty(message.HtmlBody))
                replyBuilder.Html = message.HtmlBody;

            var builder = replyBuilder.ReplyToAll(GetReplyAddress(message.EmailAddresses));

            return builder.Create();
        }
示例#3
0
        public static Email MapEmailToCoreEmail(string accountName, long emailId, IMail email)
        {
            var message = new Email
            {
                EmailUid = emailId.ToString(),
                EmailAddresses = ProcessEmailAddresses(email),
                Subject = email.Subject,
                HtmlBody = email.GetBodyAsHtml(),
                PlainTextBody = email.GetBodyAsText(),
                OriginalEmail = email,
            };

            return message;
        }
示例#4
0
        private static Sms BuildSms(Email email, ISmsSettings _smsSettings)
        {
            var sms = new Sms();
            sms.Body = email.PlainTextBody;
            sms.Created = DateTime.UtcNow;
            sms.Updated = DateTime.UtcNow;
            sms.From = new PhoneNumber
            {
                Number = _smsSettings.FromNumber
            };
            sms.To = new PhoneNumber
            {
                Number = email.Subject
            };
            sms.IsInbound = false;
            sms.IsRead = false;
            sms.IsArchived = false;

            return sms;
        }
示例#5
0
 public bool SendSms(Email email)
 {
     var sms = BuildSms(email, _smsSettings);
     var uri = new Uri($"{_serviceUrlSettings.Comms}");
     return _restService.Post(uri, sms, ApiOwner.Letme, "");
 }
        public bool SendResponse(IMailboxSettings mailboxSettings, Email email)
        {
            using (var client = new Smtp())
            {
                try
                {
                    client.ConnectSSL(mailboxSettings.OutboundServerAddress, mailboxSettings.OutboundServerPort);
                    client.LoginOAUTH2(email.FromAddress.Email, _oAuth2Authenticator.GetOAuth2AccessToken(email.FromAddress.Email));

                    return client.SendMessage(EmailMapper.MapToIMail(email)).Status == SendMessageStatus.Success;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
        }