Skip to content

Commit

Permalink
Changed the email pickup parameters and the used the system aware new…
Browse files Browse the repository at this point in the history
…line character to split the incoming emails.
  • Loading branch information
uncheckederror committed Nov 16, 2024
1 parent 2188ffc commit 1e717bc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Messaging/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2208,15 +2208,15 @@ public static async Task<ReadOnlyMemory<InboundEmail>> GetEmailsAsync(string use
await client.AuthenticateAsync(username, password, cls);
var inbox = client.Inbox;
var folder = await inbox.OpenAsync(MailKit.FolderAccess.ReadWrite, cls);
var query = SearchQuery.DeliveredAfter(DateTime.Now.AddHours(-3));
var query = SearchQuery.Recent.And(SearchQuery.NotSeen);
var recentAndUnanswered = await inbox.SearchAsync(query, cls);
List<InboundEmail> emails = [];
foreach (var uid in recentAndUnanswered.Where(x => x.Id is 32))
foreach (var uid in recentAndUnanswered)
{
var message = await inbox.GetMessageAsync(uid);
var fromNumberStart = message.Subject.IndexOf("from 1");
var toNumberStart = message.Subject.IndexOf("to 1");
var justTheText = message.TextBody.Split("\r\n");
var justTheText = message.TextBody.Split(Environment.NewLine);
emails.Add(new InboundEmail(message.Subject, justTheText.FirstOrDefault() ?? message.TextBody, message.Subject.Substring(toNumberStart + 3, 11), message.Subject.Substring(fromNumberStart + 5, 11)));
_ = await inbox.StoreAsync(uid, new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen) { Silent = true }, cls);
}
Expand Down

0 comments on commit 1e717bc

Please sign in to comment.