In the latest version of my email archiving app I've changed most Chilkat related code to the async methods. I've now got 2 error reports from testers that this sometimes doesn't work. The code does 2 passes: first a header is downloaded. The message ID is checked if it's already in the database. If it's not then the full mail is downloaded with the following code:
dim messageID as Integer = CkoMessageSet.getID(counter - 1) CkoMailTask = CkoImap.FetchSingleAsMimeAsync(messageID, True) call CkoMailTask.run While CkoMailTask.Finished <> true CkoMailTask.SleepMs(50) wend if not CkoMailTask.TaskSuccess then Globals.theErrorLog.LogItem(CurrentMethodName + " " + MailboxPath + " task didn't finish") Return "" end if dim theBody as String = CkoMailTask.GetResultString if theBody = "" then globals.theErrorLog.LogItem(CurrentMethodName + " " + MailboxPath + " wasn't able to load result from task") globals.theErrorLog.LogItem(CurrentMethodName + " " + MailboxPath + setLastErrorForTask(CkoMailTask)) end if
And now the relevant part of the error log when the mail body is empty:
2017-08-25, 9:52:10 AM ImapIterator.GetNumberOfObjects INBOX 25517 2017-08-25, 12:57:58 PM ImapController.getMail INBOX wasn't able to load result from task 2017-08-25, 12:57:58 PM ImapController.getMail INBOXChilkatLog: FetchSingleAsMime: DllDate: May 25 2017 ChilkatVersion: 126.96.36.199 UnlockPrefix: xxx Architecture: Little Endian; 32-bit Language: MAC OS X C/C++ VerboseLogging: 0 msgId: 236230 bUid: 1 fetchSingleComplete: autoDownloadAttachments: 1 --fetchSingleComplete Success. --FetchSingleAsMime --ChilkatLog
Xojo 2017r1, macOS 10.12.6.
Is this a problem or can I ignore the mail?
Mit freundlichen Grüßen/Regards
http://www.mothsoftware.com Mail Archiver X: The email archiving solution for professionals
Here's a new build you can try:
What a simple error. Thanks! Outstanding service.
My first comment is to urge any developer NOT to use async just for the sake of using async. One should only use async to allow your main thread of execution to do other things while the async operation is underway.
This usage of async is just a more complicated/convoluted (and expensive) way of duplicating the synchronous method call:
CkoMailTask = CkoImap.FetchSingleAsMimeAsync(messageID, True) call CkoMailTask.run While CkoMailTask.Finished <> true CkoMailTask.SleepMs(50) wend
In other words, the async here is pointless. It's entirely equivalent to just calling CkoImap.FetchSingleAsMime.
Of course, I don't use async just for the sake of using async. When using async there is no longer the spinning pizza of death when downloading a large email. Even in a thread I saw this often when using FetchSingleAsMime. Now with the async method this is gone and I really don't want to go back.
PS> I'm looking into the problem..
Grin... not even sure if it's a problem. Just want to make sure that I don't omit a mail since I've now gotten this from 2 users.
Beatrix, re-run with VerboseLogging turned on, and then see what the LastErrorText contains. (Set the CkoImap.VerboseLogging property = YES.
My initial suspicion is that it's somehow a character encoding issue. (If you know, how large is the email in question?) If, for example, the raw bytes of the email are received, and somehow the information about what character encoding is used (i.e. should the bytes be interpreted as utf-8, utf-16, iso-8859-1, etc.?) .. if Chilkat interprets the bytes with a wrong encoding, then the result could be empty. (Because to properly return a string to your Objective-C code requires a conversion to utf-8 from whatever byte representation is received from the server..
Please check to see if this new build helps: https://chilkatdownload.com/prerelease/chilkat-9.5.0-macosx-objc-236.zip
I've asked the users to do the logging - haven't heard back from them, yet. I would need the Xojo plugin and not the Obj-C one.
Here's the new v188.8.131.52 release: https://www.chilkatsoft.com/xojo.asp
Please let me know if that resolves anything..