I am writing an application that processes user emails. On start the application connects to Gmail and then once per minute checks for new emails.
After approximately 12 - 20 hours the application stops processing new emails. Using logs I found, that line
Mailbox mailBox = _gmailClient.SelectMailbox("inbox");
is the last one executed in this code.
Because the code is not in try / catch block I know that this is not a crash.
Please, advise.
Thank you.
Below is a part of code that retrieves new emails, where
_gmailClient is
Imap4Client() connected to Gmail using
ConnectSsl("imap.gmail.com", 993)
OutputLog($"RetrieveAndProcessNewEmails - In locked code.");
if (!_gmailClient.IsConnected)
{
OutputLog($"IMap client is not connected. Reconnecting...");
if (!(ConnectIMap4Client("imap.gmail.com", 993, true) && LoginIMap4Client("email", "pass")))
return;
}
OutputLog($"RetrieveAndProcessNewEmails - connected to GMail");
Mailbox mailBox = _gmailClient.SelectMailbox("inbox");
if (mailBox == null)
{
OutputLog("Mailbox is null! Processing incoming emails is disabled");
return;
}
OutputLog($"RetrieveAndProcessNewEmails - mailbox found: {MailBox2String(mailBox)}");
messages = mailBox.SearchParse("UNSEEN");
if (messages.Count == 0)
{
OutputLog($"Currently there is no new messages...");
return;
}
else
OutputLog($"New {messages.Count} found.");
What I have tried:
I already asked this question on GitHub, but still there was no answer.