Archived Forum Post

Index of archived forum posts

Question:

MailMan stops decrypting e-mails

Nov 29 '12 at 06:17

We have a Windows Service which checks an e-mail account regularly, every X seconds using a Timer. It manages to decrypt mails the first few times it runs, but after that it just reports "Could not decrypt e-mail" (see code below). If I restart the service, it will decrypt the e-mail, but after a few more "runs" it gives up again.

Here is a sample code (not complete) which runs at every run. A new instance of the MailMan object is instantiated every time the timer is elapsed. It runs on a Windows 2008 server in .Net 4.0.

var _mailman = new MailMan();
...set account info...
try
{
    EmailBundle bundle = _mailman.CopyMail();
    if (bundle == null || bundle.MessageCount == 0)           
        return;

    for (i = 0; i <= bundle.MessageCount - 1; i++)
    {
        Email email = bundle.GetEmail(i);
        if (email.ReceivedEncrypted && !email.Decrypted)
        {                    
           _log.Error("Could not decrypt e-mail");
           return;            
        }    
        ...process email...
    }
}
finally
{
   _mailman.Pop3EndSession();   
}

So to the questions. Does anybody have a clue why this happens?

How can I find the reason why it can't decrypt the e-mail? LastErrorText will not give me anything after the call to GetMail.


Answer

The decryption happens in the CopyMail. Therefore, you would want to examine the _mailman.LastErrorText after calling CopyMail.