public static List <EmailAttachment> GetAttachmentsFromMessage(IMail msg) { List <EmailAttachment> attachments = new List <EmailAttachment>(); foreach (var attachment in msg.Attachments) { string filename = "noname"; if (attachment.FileName != null) { filename = attachment.SafeFileName; } //removing Outlook garbage attachements Regex outlook_garbage = new Regex("ATT\\d*.+html?", RegexOptions.IgnoreCase); //like ATT00001.htm if (outlook_garbage.IsMatch(filename)) { continue; } attachments.Add(new EmailAttachment() { FileName = filename, FileData = attachment.Data, ContentId = attachment.ContentId }); } return(attachments); }
public static bool IsUselessMessage(IMail msg) { //is it a bounce email? var bounce = new Limilabs.Mail.Tools.Bounce(); var result = bounce.Examine(msg); var useless = result.IsDeliveryFailure; if (!useless) { useless = IsUselessMessage(msg.From[0].Address, msg.From[0].Name, msg.Subject, msg.Headers); } return(useless); //loop through all entities and if some entity has ContentType "message/delivery-status" - its probably an NDR /*if (!useless) * { * if (msg.AllEntities != null) * { * foreach (var e in msg.AllEntities) * { * if (e.ContentType.TypeWithSubtype == MIME_MediaTypes.Message.delivery_status) * return true; * } * } * }*/ //temporary commented this out, to see if helps cure the missing emails problem }
public static string GetEmailBBCodeBody(IMail msg, bool removeQuotedText) { bool isHtml = msg.IsHtml; string body = isHtml ? msg.Html : msg.Text; if (isHtml || StringUtils.HasCommonHtmlTags(body)) { if (removeQuotedText) //"#ticket#" text is found in the subject, so it is a reply. { //lets try to get rid of the quoted msg (sometimes it can be done in HTML version only) body = RemoveQuotedReplyFromHTMLEmail(body); } //now let's ged rid of all BBCODE-incompatible html body = StringUtils.HTML2BBCode(body); } else //not HTML, but le't still escape bbcode { body = StringUtils.EscapeBbCode(body); } if (removeQuotedText) { body = RemoveQuotedReplyFromBBCodeEmail(body); } //get rid of too many CRs (to make it look nice) body = StringUtils.RemoveRepeatingCRLFs(body); return(body); }
static void send(string subject, User to) { try { MailBuilder builder = new MailBuilder(); builder.Html = @"Html with an image: <img src=""cid:lena"" />"; builder.Subject = subject; MimeData visual = builder.AddVisual(HostingEnvironment.MapPath("~/Images/logo_2.png")); visual.ContentId = "lena"; MimeData attachment = builder.AddAttachment(@"C:\Users\User\Desktop\Attachment.txt"); attachment.FileName = "document.doc"; builder.From.Add(new MailBox("*****@*****.**")); builder.To.Add(new MailBox(to.Email)); //builder.To.Add(new MailBox("*****@*****.**")); IMail email = builder.Create(); using (Smtp smtp = new Smtp()) { smtp.Connect(_server); // or ConnectSSL for SSL smtp.UseBestLogin(_user, _password); smtp.SendMessage(email); smtp.Close(); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private void OpenMail(string mailPath, SaveMailToPdfRequest model) { InstantiateOutlook(); string mailExt = Path.GetExtension(mailPath); if (mailExt.Equals(".msg", StringComparison.InvariantCultureIgnoreCase)) { _logger.WriteInfo(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " is .msg file. Open item with outlook directly.")), LogCategories); _outlookMail = OpenSharedItem(mailPath); return; } _logger.WriteInfo(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " is not .msg file. Try build message manually.")), LogCategories); MailBuilder builder = new MailBuilder(); IMail mail = builder.CreateFromEmlFile(mailPath); _outlookMail = ConvertToMsg(mail, model); if (_outlookMail == null) { _logger.WriteError(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " not open. Check if item is a correct email message.")), LogCategories); throw new Exception("Mail not open. Check if item is a correct email message."); } }
/// <summary> /// Saves the specified mail message. A service will pick it up and deliver it /// </summary> /// <param name="mailMessage">The mail message.</param> /// <returns></returns> public IMail Save(IMail mailMessage) { mailMessage.Id = mailMessage.Id ?? NewLongId(); mailMessage.DateAdded = DateTime.Now; mailCollection.Save(mailMessage.ToBsonDocument()); return(mailMessage); }
public bool Send(IMail iMail) { using (var mail = new MailMessage()) { mail.To.Add(iMail.To); mail.From = new MailAddress(iMail.From); mail.Subject = iMail.Subject; mail.Body = iMail.Body; mail.IsBodyHtml = true; mail.Headers.Add("List-Unsubscribe", $"<mailto:{iMail.From}?subject=unsubscribe>"); using (var smtp = new SmtpClient()) { try { smtp.Send(mail); } catch (Exception) { throw; } } } return(true); }
/// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> public virtual void Process(PipelineArgs args) { Assert.ArgumentNotNull(args, "args"); Order order = args.CustomData["order"] as Order; if (order == null) { return; } BusinessCatalogSettings businnesCatalogSettings = Context.Entity.GetConfiguration <BusinessCatalogSettings>(); Item companyMasterData = Sitecore.Context.Database.SelectSingleItem(businnesCatalogSettings.CompanyMasterDataLink); if (companyMasterData == null) { return; } string queryString = string.Format("orderid={0}&mode=mail", order.OrderNumber); Item saleDepartment = companyMasterData.Children["Sale"]; var saleParams = new { Recipient = saleDepartment["Email"] }; IMail mailProvider = Context.Entity.Resolve <IMail>(); mailProvider.SendMail("Order Mail To Admin", saleParams, queryString); }
internal List<KeyValuePair<string, string>> FetchFormParams(IMail message) { var result = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("api_user", _credentials.UserName), new KeyValuePair<string, string>("api_key", _credentials.Password), new KeyValuePair<string, string>("headers", message.Headers.Count == 0 ? null : Utils.SerializeDictionary(message.Headers)), new KeyValuePair<string, string>("replyto", message.ReplyTo.Length == 0 ? null : message.ReplyTo.ToList().First().Address), new KeyValuePair<string, string>("from", message.From.Address), new KeyValuePair<string, string>("fromname", message.From.DisplayName), new KeyValuePair<string, string>("subject", message.Subject), new KeyValuePair<string, string>("text", message.Text), new KeyValuePair<string, string>("html", message.Html), new KeyValuePair<string, string>("x-smtpapi", message.Header.AsJson()) }; if (message.To != null) { result = result.Concat(message.To.ToList().Select(a => new KeyValuePair<string, string>("to[]", a.Address))) .Concat(message.To.ToList().Select(a => new KeyValuePair<string, string>("toname[]", a.DisplayName))) .ToList(); } if (message.Bcc != null) { result = result.Concat(message.Bcc.ToList().Select(a => new KeyValuePair<string, string>("bcc[]", a.Address))) .ToList(); } if (message.Cc != null) { result = result.Concat(message.Cc.ToList().Select(a => new KeyValuePair<string, string>("cc[]", a.Address))) .ToList(); } return result.Where(r => !string.IsNullOrEmpty(r.Value)).ToList(); }
private async void btnSend_Click(object sender, RoutedEventArgs e) { for (int i = 0; i < 100; i++) { MailBuilder mb = new MailBuilder(); mb.From.Add(new MailBox(txtFrom.Text)); mb.To.Add(new MailBox(txtTo.Text)); mb.Subject = txtSubject.Text; mb.Html = txtBody.Text; if (file != null) { await mb.AddAttachment(file); } IMail mail = mb.Create(); try { Smtp smtp = new Smtp(); await smtp.Connect("smtp.gmail.com", 587); await smtp.UseBestLoginAsync(txtFrom.Text, txtPasscode.Password); await smtp.SendMessageAsync(mail); await smtp.CloseAsync(); } catch (Exception ex) { new MessageDialog(ex.Message).ShowAsync(); //throw; } } await new MessageDialog("Send mail completed").ShowAsync(); }
public SentMailReadingWindow(IMail message, EmailBox emailBox) { this.InitializeComponent(); this.Message = message; this.EmailBox = emailBox; this.ShowMessageInWindow(); }
public SkillCommandHandler( IMediatorHandler bus, ILogger <SkillCommandHandler> logger, ISkillDomainService skillDomainService, IWareDomainService wareDomainService, IHttpContextAccessor httpAccessor, IMapper mapper, IMail mail, IPlayerDomainService playerDomainService, IPlayerSkillDomainService playerSkillDomainService, INpcDomainService npcDomainService, IPlayerRelationDomainService playerRelationDomainService, INpcSkillDomainService npcSkillDomainService, IPlayerWareDomainService playerWareDomainService, IRedisDb redisDb, IMudProvider mudProvider, INotificationHandler <DomainNotification> notifications, IUnitOfWork uow) : base(uow, bus, notifications) { _bus = bus; _logger = logger; _skillDomainService = skillDomainService; _wareDomainService = wareDomainService; _httpAccessor = httpAccessor; _mapper = mapper; _mail = mail; _playerDomainService = playerDomainService; _playerSkillDomainService = playerSkillDomainService; _npcDomainService = npcDomainService; _playerRelationDomainService = playerRelationDomainService; _npcSkillDomainService = npcSkillDomainService; _playerWareDomainService = playerWareDomainService; _redisDb = redisDb; _mudProvider = mudProvider; }
public bool SendMail(IMail mailInfo) { try { var mail = new MimeMessage(); mail.From.Add(new MailboxAddress(mailInfo.From, mailInfo.SenderMail)); mail.To.Add(new MailboxAddress(mailInfo.To)); mail.Subject = mailInfo.Subject; mail.Body = new TextPart("plain") { Text = mailInfo.Body }; using (SmtpClient client = new SmtpClient()) { client.Connect("smtp.gmail.com", 587, false); client.Authenticate("*****@*****.**", "smtpsmtp123456"); client.Send(mail); client.Disconnect(true); } return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// Initializes a new instance of the Meetuphh class. /// </summary> public Meetuphh() : base() { this._mail = new Mail(this); this._user = new UserOperations(this); this._baseUri = new Uri("https://microsoft-apiapp21ee0a3b45e043e58aa5068ad2488263.azurewebsites.net"); }
public async Task <List <Email> > GetPop3EmailHeaders(Model.UserInfo userInfo) { Pop3 pop3 = await ConnectPop3(userInfo); try { if (pop3 != null) { List <string> uids = pop3.GetAll(); MailBuilder builder = new MailBuilder(); foreach (string uid in uids) { var headers = pop3.GetHeadersByUID(uid); IMail mail = builder.CreateFromEml(headers); Email email = new Email { Uid = uid, Date = mail.Date ?? DateTime.MinValue, Subject = mail.Subject, From = string.Join(",", mail.From?.Select(s => s.Address)), }; emailHeaderList.Add(email); } } return(emailHeaderList); } finally { serverConnection.Add(pop3); } }
static void Main() { IMail email = Mail .Html(@"<img src=""cid:lemon@id"" align=""left"" /> This is simple <strong>HTML email</strong> with an image and attachment") .Subject("Subject") .AddVisual("Lemon.jpg").SetContentId("lemon@id") .AddAttachment("Attachment.txt").SetFileName("Invoice.txt") .From(new MailBox("*****@*****.**", "Lemon Ltd")) .To(new MailBox("*****@*****.**", "John Smith")) .Create(); email.Save(@"SampleEmail.eml"); // You can save the email for preview. using (Smtp smtp = new Smtp()) // Now connect to SMTP server and send it { smtp.Connect(_server); // Use overloads or ConnectSSL if you need to specify different port or SSL. smtp.UseBestLogin(_user, _password); // You can also use: Login, LoginPLAIN, LoginCRAM, LoginDIGEST, LoginOAUTH methods, // or use UseBestLogin method if you want Mail.dll to choose for you. ISendMessageResult result = smtp.SendMessage(email); Console.WriteLine(result.Status); smtp.Close(); } // For sure you'll need to send complex emails, // take a look at our templates support in SmtpTemplates sample. }
public MimeMessage DefaultMessage(IMail mail) { return(_mimeMessage.AddMessage(mail.Message) .AddSubject(mail.Subject) .AddSender(mail.Sender) .AddRecievers(mail.Recievers)); }
private async void btnSend_Click(object sender, RoutedEventArgs e) { MailBuilder myMail = new MailBuilder(); string message = string.Empty; txtMessage.Document.GetText(Windows.UI.Text.TextGetOptions.AdjustCrlf, out message); myMail.Html = message; myMail.Subject = txtSubject.Text; await myMail.AddAttachment(AttachFile); myMail.To.Add(new MailBox(txtTo.Text)); myMail.From.Add(new MailBox(txtFrom.Text)); myMail.Cc.Add(new MailBox(txtCC.Text)); myMail.Bcc.Add(new MailBox(txtBCc.Text)); IMail email = myMail.Create(); using (Smtp smtp = new Smtp()) { await smtp.Connect("smtp.gmail.com", 587); await smtp.UseBestLoginAsync("*****@*****.**", "Osxunix97"); await smtp.SendMessageAsync(email); await smtp.CloseAsync(); await new MessageDialog("mail send success").ShowAsync(); } }
public OutlookConversationTopicSource(IHostApplicationProvider hostAppProvider, IMail mailItem) : base (hostAppProvider, mailItem) { string conversationTopic = RemoveInvalidStringsFromConversationTopic(_mailItem.ConversationTopic); _dataSource.ApplyFilter(string.Format("[ConversationTopic]='{0}'", conversationTopic)); Count = _dataSource.Count; }
private void SendMessageClick(object sender, RoutedEventArgs e) { MailBuilder builder = new MailBuilder(); builder.From.Add(new MailBox(from_textBox.Text, "Hello")); builder.To.Add(new MailBox(to_textBox.Text, "World")); builder.Subject = subject_textBox.Text; builder.Text = messageText_textBox.Text; IMail email = builder.Create(); // отправка сообщения using (Smtp smtp = new Smtp()) { smtp.ConnectSSL("smtp.gmail.com"); smtp.UseBestLogin("email", "password"); //вставляем email и пароль ISendMessageResult result = smtp.SendMessage(email); if (result.Status == SendMessageStatus.Success) { MessageBox.Show("Сообщение отправленно!"); } smtp.Close(); } }
public ReplyController(IMail mailService, UserManager <ApplicationUser> userManager, IApplicationUser userService, IPlatform platformService) { _mailService = mailService; _userManager = userManager; _userService = userService; _platformService = platformService; }
public async Task <SendGridMessageResult> SendViaHttp(IMail input) { var from = new Email(input.MailMessage.From.Address); var subject = input.MailMessage.To; var to = new Email(input.MailMessage.To.ToString()); var content = new Content(input.EncodeType, input.Body); var mail = new Mail(from, input.MailMessage.Subject, to, content); if (!string.IsNullOrEmpty(input.ExtraParams.TemplateId) && input.ExtraParams.EnableTemplates) { mail.TemplateId = input.ExtraParams.TemplateId; if (input.ExtraParams.Substitutions != null) { foreach (var substitution in input.ExtraParams.Substitutions) { mail.Personalization[0].AddSubstitution(substitution.Key, substitution.Value); } } } var result = await _sendGrid.client.mail.send.post(requestBody : mail.Get()); if (result.StatusCode.ToString() == "Accepted") { return(new SendGridMessageResult() { ErroMessage = "", Success = true }); } return(new SendGridMessageResult() { ErroMessage = result.StatusCode.ToString(), Success = false }); }
private void ProcessMessageQueue() { IMail theGameEmail = null; try { if (_messageIDsBeingSent.Count.Equals(0)) { if (_messageQueue.Count > 0) { theGameEmail = _messageQueue.Peek(); _messageIDsBeingSent.Add(theGameEmail.MessageID); SendAowEmail(theGameEmail); } } } catch (Exception ex) { Trace.WriteLine(string.Format("ProcessMessageQueue Error: {0}", ex.ToString())); if (theGameEmail != null) { RaiseOnEmailSentEvent(new SmtpSendResponse(theGameEmail, false, ex)); } } }
private void button2_Click(object sender, EventArgs e) { imap.SelectInbox(); List <long> uids = imap.SearchFlag(Flag.Unseen); int i = int.Parse(textBox3.Text); if (i > uids.Count) { i = uids.Count; } int j = 0; foreach (long uid in uids) { if (j < i) { imail = new MailBuilder().CreateFromEml(imap.GetHeadersByUID(uid)); DataRow row = table.NewRow(); row["IDMail"] = uid.ToString(); row["Subject"] = imail.Subject; table.Rows.Add(row); table.AcceptChanges(); j++; } else { break; } } dataGridView1.DataSource = table; }
protected virtual void RunConsole(IMail mail, string exe, string[] args, ActorId shell) { var console = new ConsoleProcessActor(exe, exe, args); Node.Add(console); console.AttachConsole(shell); Node.Reply(mail, console.Id); }
public EmailListViewModel(IMail mail, IEventAggregator ea) { _mail = mail; _ea = ea; DownloadCommand = new DelegateCommand <PrismInfrastructure.Models.Email>(DownloadAttatchementCommand, CanDownloadAttachement); }
public PlatformController(IPlatform platformService, IMail mailService, IUpload uploadService, IConfiguration configuration) { _platformService = platformService; _mailService = mailService; _uploadService = uploadService; _configuration = configuration; }
private static void ProcessMessage(IMail email) { Console.WriteLine("Subject: " + email.Subject); Console.WriteLine("From: " + JoinAddresses(email.From)); Console.WriteLine("To: " + JoinAddresses(email.To)); Console.WriteLine("Cc: " + JoinAddresses(email.Cc)); Console.WriteLine("Bcc: " + JoinAddresses(email.Bcc)); Console.WriteLine("Text: " + email.Text); Console.WriteLine("HTML: " + email.Html); System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); synth.SetOutputToDefaultAudioDevice(); // Speak a string. synth.Speak("You have a Mail from" + email.From + "On" + email.Subject + email.Text); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); Console.WriteLine("Attachments: "); foreach (MimeData attachment in email.Attachments) { Console.WriteLine(attachment.FileName); attachment.Save(@"c:\" + attachment.SafeFileName); } }
private void AttachFiles(IMail message, MultipartFormDataContent content) { var files = FetchFileBodies(message); foreach (var file in files) { var ifile = file.Value; var fileContent = new StreamContent(ifile.OpenAsync(FileAccess.Read).Result); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "files[" + ifile.Name + "]", FileName = ifile.Name }; fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream"); content.Add(fileContent); } var streamingFiles = FetchStreamingFileBodies(message); foreach (KeyValuePair<string, MemoryStream> file in streamingFiles) { var name = file.Key; var stream = file.Value; var fileContent = new StreamContent(stream); fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "files[" + name + "]", FileName = name }; fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream"); content.Add(fileContent); } }
/// <summary> /// Send message built in ProcessMailToSend() /// </summary> /// <param name="email"></param> /// <returns></returns> protected int SendMail(IMail email) { try { // COnnect to server if (_ua.OutUserSSL == "SSL") { _smtp.ConnectSSL(_ua.OutUserServer, Int32.Parse(_ua.OutUserPort)); _smtp.Login(_ua.UserUsername, _ua.UserPassword); } else { _smtp.Connect(_ua.OutUserServer, Int32.Parse(_ua.OutUserPort)); _smtp.UseBestLogin(_ua.UserUsername, _ua.UserPassword); } _smtp.SendMessage(email); // SET TO EMAIL return(1); } catch (Exception ex) { return(0); } }
public LoginServiceImpl(ILoginRepository loginRepository, IEmailRepository emailRepository, IMail mail) { repository = loginRepository; this.emailRepository = emailRepository; this.mail = mail; this.constituentRepository = constituentRepository; }
public void Send(IMail mail) { foreach (string email in Emails) { mail.SendMail(email, Subject, Body, GetAttachment()); } }
/// <summary> /// Initializes a new instance of the Meetuphh class. /// </summary> /// <param name='rootHandler'> /// Optional. The http client handler used to handle http transport. /// </param> /// <param name='handlers'> /// Optional. The set of delegating handlers to insert in the http /// client pipeline. /// </param> public Meetuphh(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) { this._mail = new Mail(this); this._user = new UserOperations(this); this._baseUri = new Uri("https://microsoft-apiapp21ee0a3b45e043e58aa5068ad2488263.azurewebsites.net"); }
internal List <KeyValuePair <string, string> > FetchFormParams(IMail message) { var result = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("api_user", _credentials.UserName), new KeyValuePair <string, string>("api_key", _credentials.Password), new KeyValuePair <string, string>("headers", message.Headers.Count == 0 ? null : Utils.SerializeDictionary(message.Headers)), new KeyValuePair <string, string>("replyto", message.ReplyTo.Length == 0 ? null : message.ReplyTo.ToList().First().Address), new KeyValuePair <string, string>("from", message.From.Address), new KeyValuePair <string, string>("fromname", message.From.DisplayName), new KeyValuePair <string, string>("subject", message.Subject), new KeyValuePair <string, string>("text", message.Text), new KeyValuePair <string, string>("html", message.Html), new KeyValuePair <string, string>("x-smtpapi", message.Header.JsonString()) }; if (message.To != null) { result = result.Concat(message.To.ToList().Select(a => new KeyValuePair <string, string>("to[]", a.Address))) .Concat(message.To.ToList().Select(a => new KeyValuePair <string, string>("toname[]", a.DisplayName))) .ToList(); } if (message.Bcc != null) { result = result.Concat(message.Bcc.ToList().Select(a => new KeyValuePair <string, string>("bcc[]", a.Address))) .ToList(); } if (message.Cc != null) { result = result.Concat(message.Cc.ToList().Select(a => new KeyValuePair <string, string>("cc[]", a.Address))) .ToList(); } return(result.Where(r => !string.IsNullOrEmpty(r.Value)).ToList()); }
public QuestCommandHandler( IMediatorHandler bus, ILogger <QuestCommandHandler> logger, IQuestDomainService questDomainService, IHttpContextAccessor httpAccessor, IMapper mapper, IMail mail, IPlayerDomainService playerDomainService, IPlayerQuestDomainService playerQuestDomainService, IRedisDb redisDb, IMudProvider mudProvider, INotificationHandler <DomainNotification> notifications, IUnitOfWork uow) : base(uow, bus, notifications) { _bus = bus; _logger = logger; _questDomainService = questDomainService; _httpAccessor = httpAccessor; _mapper = mapper; _mail = mail; _playerDomainService = playerDomainService; _playerQuestDomainService = playerQuestDomainService; _redisDb = redisDb; _mudProvider = mudProvider; }
void ReceiveFileChunk(IMail mail, FileChunk chunk) { using (var fs = File.OpenWrite(chunk.Name)) { fs.Position = chunk.Position; fs.Write(chunk.Bytes, 0, chunk.Bytes.Length); } }
public static IMail GetMailGateway() { if(mail == null) { mail = new Mail(); } return mail; }
private void AttachFormParams(IMail message, MultipartFormDataContent content) { var formParams = FetchFormParams(message); //formParams.ForEach(kvp => multipartEntity.AddBody(new StringBody(Encoding.UTF8, kvp.Key, kvp.Value))); foreach (var keyValuePair in formParams) { content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key); } }
private List<IContentItem> InitialiseDataSource(IMail mailItem) { List<IContentItem> attachments = new List<IContentItem>(); foreach (IMailAttachment attachment in mailItem.Attachments) { attachments.Add(attachment); } return attachments; }
public void Reply(IMail m, string name, params object[] args) { var mail = m.As<RpcMail>(); Send(new RpcMail{ To = mail.From, From = mail.To, MessageId = mail.MessageId, Message = new FunctionCall(name, args), }); }
public RegistrationServiceImpl(IRegisterationRepository repository, IConstituentRepository constituentRepository, IMail mail, IEmailServiceImpl emailServiceImpl, IPhoneServiceImpl phoneServiceImpl, IAddressServiceImpl addressServiceImpl, ILoginServiceImpl loginServiceImpl) { this.constituentRepository = constituentRepository; this.repository = repository; this.emailServiceImpl = emailServiceImpl; this.phoneServiceImpl = phoneServiceImpl; this.addressServiceImpl = addressServiceImpl; this.loginServiceImpl = loginServiceImpl; this.mail = mail; }
public ConverstationTopicStrategy(IContentItem item) { _item = item as IMail; if (_item == null) throw new System.InvalidCastException("Expecting an IMail item"); Precedence = 1; DisplayName = "Conversation Topic Strategy"; Context = Interfaces.Context.Original; }
public void Send(IMail mail) { try { sender.Send(mail); } catch (Exception ex) { Trace.WriteLine("send " + ex); } }
public static void DeleteMail(IMail selectedMail) { var mail = selectedMail as EFMail; if (mail != null) { UpdateCacheMail(mail, false); OADBManager.Instance.DBContext.Entry(selectedMail).State = EntityState.Deleted; OADBManager.Instance.DBContext.SaveChanges(); } }
public void Dispatch(IMail obj) { DistributedActor actor; lock (actors) { if (!actors.TryGetValue(obj.As<RpcMail>().To.As<ActorId>().Name, out actor)) return; if (!IsMatch(obj.As<RpcMail>().To.As<ActorId>(), actor.Id)) return; } actor.Post(obj.As<RpcMail>()); }
/// <summary> /// Delivers a message over SendGrid's Web interface /// </summary> /// <param name="message"></param> public void Deliver(IMail message) { var client = new HttpClient { BaseAddress = _https ? new Uri("https://" + BaseUrl) : new Uri("http://" + BaseUrl) }; var content = new MultipartFormDataContent(); AttachFormParams(message, content); AttachFiles(message, content); var response = client.PostAsync(Endpoint + ".xml", content).Result; CheckForErrors(response); }
/// <summary> /// Asynchronously delivers a message over SendGrid's Web interface. /// </summary> /// <param name="message"></param> public async Task DeliverAsync(IMail message) { var client = new HttpClient { BaseAddress = _https ? new Uri("https://" + BaseUrl) : new Uri("http://" + BaseUrl) }; var content = new MultipartFormDataContent(); AttachFormParams(message, content); AttachFiles(message, content); var response = await client.PostAsync(Endpoint + ".xml", content).ConfigureAwait(false); CheckForErrors(response); }
public OutlookSentItemSource(IHostApplicationProvider hostAppProvider, IMail mailItem) : base(hostAppProvider) { _mailItem = mailItem; Precedence = 1; Context = Interfaces.Context.Original; _dataSource = new OutlookDataSource(hostAppProvider, mailItem); _dataSource.ApplyFilter(string.Empty); //_dataSource.ApplyFilter("%lastmonth(\"urn:schemas:httpmail:date\")%"); //string filter = @"@SQL=(""urn:schemas:httpmail:date"" <= '" + (DateTime.Now - new TimeSpan(7, 0, 0, 0)).ToString("g") + @"')"; Count = _dataSource.Count; }
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; }
private static MailMessage ConvertIMailToMailMessage(IMail mail) { MailMessage email = new MailMessage(); email.Subject = mail.Subject; email.Body = mail.Body; email.From = new MailAddress(mail.FromAddress); email.To.Add(GetAddress(mail.ToAddresses)); if (mail.CcAddresses.Count > 0) email.CC.Add(GetAddress(mail.CcAddresses)); if (mail.BccAddresses.Count > 0) email.Bcc.Add(GetAddress(mail.BccAddresses)); email.IsBodyHtml = false; return email; }
public OutlookSentItemSourceWithFilter(IHostApplicationProvider hostAppProvider, IMail mail) : base(hostAppProvider, mail) { var mailItem = _mailItem.RawMailItem; var propertyAccessor = mailItem.PropertyAccessor; var PR_SENDER_NAME_W = propertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0C1A001F"); string smtpAddress = GetSmtpAddress(); string filter = string.Format("@SQL=\"urn:schemas:httpmail:displayto\" LIKE '%{0}%' OR \"urn:schemas:httpmail:displayto\" LIKE '%{1}%'", PR_SENDER_NAME_W, smtpAddress); _dataSource.ApplyFilter(filter); Count = _dataSource.Count; Marshal.ReleaseComObject(propertyAccessor); Marshal.ReleaseComObject(mailItem); }
private static List<EmailAddress> ProcessEmailAddresses(IMail email) { var result = new List<EmailAddress> { new EmailAddress { Name = email.Sender.Name, Email = email.Sender.Address, Type = EmailAddressType.From, } }; result.AddRange(ExtractEmailAddresses(email.To, EmailAddressType.To)); result.AddRange(ExtractEmailAddresses(email.Cc, EmailAddressType.BlindCarbonCopy)); result.AddRange(ExtractEmailAddresses(email.Bcc, EmailAddressType.BlindCarbonCopy)); return result; }
public EnvelopeModel(IMail imail, string uid) { UID = uid; if (imail.From != null && imail.From.Count > 0) From = new AddressModel(imail.From[0]); Subject = imail.Subject; Date = imail.Date; Recipients = new List<AddressModel>(); foreach(var imRec in imail.To) { var mailBoxes = imRec.GetMailboxes(); foreach (var mb in mailBoxes) { Recipients.Add(new AddressModel(mb)); } } }
private static void ProcessMessage(IMail email) { Console.WriteLine("Subject: " + email.Subject); Console.WriteLine("From: " + JoinAddresses(email.From)); Console.WriteLine("To: " + JoinAddresses(email.To)); Console.WriteLine("Cc: " + JoinAddresses(email.Cc)); Console.WriteLine("Bcc: " + JoinAddresses(email.Bcc)); Console.WriteLine("Text: " + email.TextDataString); Console.WriteLine("HTML: " + email.HtmlDataString); Console.WriteLine("Attachments: "); foreach (MimeData attachment in email.Attachments) { Console.WriteLine(attachment.FileName); attachment.Save(@"c:\" + attachment.SafeFileName); } }
public static bool ParseReceivedHeader(IMail mail, out string ehloDomain, out string ehloIp, out string mx, out DateTime? dateReceived) { ehloDomain = null; ehloIp = null; mx = null; dateReceived = null; if (mail.Document.Root.Headers["received"] == null) { return false; } const string regex = @"from\s+(?<ehlodomain>[a-zA-Z0-9\-\.]+)\s+\(\[(?<ehloip>(?:[0-9]{1,3}\.?){4})\]\)\s+by\s+(?<receivedmx>[a-zA-Z0-9\.\-]+)\s.+;\s+(?<receiveddate>.+)"; var match = Regex.Match(mail.Document.Root.Headers["received"], regex); ehloDomain = match.Groups["ehlodomain"] != null ? match.Groups["ehlodomain"].Value : null; ehloIp = match.Groups["ehloip"] != null ? match.Groups["ehloip"].Value : null; mx = match.Groups["receivedmx"] != null ? match.Groups["receivedmx"].Value : null; dateReceived = match.Groups["receiveddate"] != null ? DateTimeHelper.SafeParseAndConvertToEasternStandardTime(match.Groups["receiveddate"].Value) : null; return true; }
private IStrategyResult FindOriginalMail(IMail mailItem) { IStrategyResult originalMail = null; NumberOfStrategies = 3; IDiscoveryStrategy quickStrategy = new ConverstationTopicStrategy(mailItem); IContentSource quickSource = new OutlookConversationTopicSource(Global.ApplicationProvider, mailItem); quickSource.ApplyingStrategy += source_ApplyingStrategy; NumberOfItems = quickSource.Count; originalMail = quickSource.ApplyStrategy(quickStrategy); if (originalMail.Count > 0) return originalMail; var sources = new List<IContentSource>() { new OutlookSentItemSourceWithFilter(Global.ApplicationProvider, mailItem), new OutlookSentItemSource(Global.ApplicationProvider, mailItem) }; NumberOfItems = sources[1].Count; IDiscoveryStrategy strategyOfLastResort = new DocumentTrackingStrategy(mailItem); foreach (IContentSource source in sources) { source.ApplyingStrategy += source_ApplyingStrategy; originalMail = source.ApplyStrategy(strategyOfLastResort); if (originalMail.Count > 0) return originalMail; } return originalMail; }
public void SetUp() { _smtpClient = Substitute.For<ISmtpClientWrapper>(); _mail = new Mail(_smtpClient); }
public void Add(IMail mail) { this.mail.Add(mail); }
public OutlookDataSource(IHostApplicationProvider hostAppProvider, IMail mailItem) { _mailItem = mailItem; Logger.LogInfo("OutlookSentItemSource.OutlookDataSource()"); _ns = hostAppProvider.Host.GetNamespace("MAPI"); _sent = _ns.GetDefaultFolder(MsOutlook.OlDefaultFolders.olFolderSentMail); _items = _sent.Items; }
public static Email MapEmailToCoreEmail(string accountName, long emailId, IMail email) { var message = new Email { AccountName = accountName, EmailUid = emailId, EmailAddresses = ProcessEmailAddresses(email), Subject = email.Subject, HtmlBody = email.GetBodyAsHtml(), PlainTextBody = email.GetBodyAsText(), Date = email.Date?.ToUniversalTime() ?? DateTime.UtcNow, Direction = Direction.Inbound, Status = Status.Unknown, }; message.Attachments.AddRange(ExtractAttachments(email.NonVisuals)); message.Attachments.AddRange(ExtractAttachments(email.Visuals)); return message; }