public async Task DisplayPop3SubjectsAsync() { BotVisitor v = new BotVisitor(); for (int i = 0; i < Pop3?.Count; i++) { //Pop3.DeleteMessage(i); MimeMessage message = Pop3.GetMessage(i); v.Visit(message); Console.WriteLine("Subject: {0}", message.Subject); List <string> Messages = new List <string>(); if (message.Attachments != null) { foreach (MimeEntity mime in message.Attachments) { if (mime.IsAttachment) { var mp = (MimePart)mime; string path = Path.Combine(@"D:\Desktop\Hub Test Folder", mime.ContentType.Name); Console.WriteLine("Name: " + mime.ContentType.Name); using (var stream = File.Create(path)) { mp.Content.DecodeTo(stream); } ProcessedInvoice[] processedInvoices = await DataProcessing.ProcessInvoices(path); Messages.Add($"<p>\t - Processed {mime.ContentType.Name} as Invoice for {ABNHelper.GetCompanyName(processedInvoices[0].ABN)}</p>"); //File.Delete(path); } } } EmailService service = new EmailService(); MailboxAddress address = message.From.Mailboxes.First(); Console.WriteLine(address); string body = "<h3><b><u>Items Processed:</h3></b></u> \n"; for (int j = 0; j < Messages.Count; j++) { body += Messages[j] + '\n'; } // service.Send("*****@*****.**", address.Address, $"Re: {message.Subject}", body ); } Pop3.DeleteAllMessages(); }
public static string GetCompanyName(string abn) { return(ABNHelper.GetCompanyName(abn)); }