We have a .NET voicemail program that uses the Mail.dll IMAP client component to organize our Inbox.
Originally this was on Kerio, but we are currently moving everything over to Office 365 and more recent .NET version.
We have managed to get to get most of the programs original functionality restored but are still struggling to get the delete functionality to work as it currently does in production.
For a bit more insight, the way that it all works is when our Telesales department misses a call, our phone system will automatically upload the voicemail left by the caller to an email address we’ve set up.
The program that we have created is designed to first organize the inbox and create subfolders surrounding the dates the voicemails were received on (E.G a voicemail left on the 9th of May would be moved to a new subfolder created in the format of “Inbox/2022-05-09 Sun”).
From here the subfolders and .Wav files contained within are uploaded to an archive folder outside of the inbox and eventually zipped up for archive after a week.
Inside the inbox we keep hold of the last 8 days’ worth of emails before the program automatically removed the folders and emails that are past that threshold.
I’ve included a copy of the log file below as well if they are of any help and marked where the issue:
Connecting to 'outlook.office365.com:993', SSL: True.
S: * OK The Microsoft Exchange IMAP4 service is ready. [T...==]
C: 54559b81a65e4728 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2
SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
S: 54559b81a65e4728 OK CAPABILITY completed.
C: b838e3e463de43e2 ID ("name" "Mail.dll"
"version" "3.0.16237.1202"
"vendor" www.limilabs.com
"contact" support@limilabs.com)
S: * ID (
"name" "Microsoft.Exchange.Imap4.Imap4Server"
"version" "15.20")
S: b838e3e463de43e2 OK ID completed
C: 3ea9c4472a144abd AUTHENTICATE PLAIN A...=
S: 3ea9c4472a144abd OK AUTHENTICATE completed.
C: eae13496c689427b CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR
UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES
CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE
CHILDREN IDLE NAMESPACE LITERAL+
S: eae13496c689427b OK CAPABILITY completed.
C: 87a222bc93814668 LIST "" ""
S: * LIST (\Noselect \HasChildren) "/" ""
S: 87a222bc93814668 OK LIST completed.
C: c31db86568524994 SELECT INBOX
S: * 0 EXISTS
S: * 0 RECENT
S: * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
S: * OK [PERMANENTFLAGS
(\Seen \Answered \Flagged \Deleted \Draft $MDNSent)]
Permanent flags
S: * OK [UIDVALIDITY 14] UIDVALIDITY value
S: * OK [UIDNEXT 638] The next unique identifier value
S: c31db86568524994 OK [READ-WRITE] SELECT completed.
C: 66d0bffee5f7484b UID SEARCH UNDELETED
----- * Here is where the issue begins * -----
S: * SEARCH
S: 66d0bffee5f7484b OK SEARCH completed.
C: 40e124cec2d246e2 DELETE Inbox/09/03/2022
S: 40e124cec2d246e2 NO The requested item could not be found.
Exception thrown:
'Limilabs.Client.IMAP.ImapResponseException' in Mail.dll
C: ec5af7d22bbf4982 DELETE Inbox/10/03/2022
S: ec5af7d22bbf4982 NO The requested item could not be found.
Exception thrown:
'Limilabs.Client.IMAP.ImapResponseException' in Mail.dll
As for the issue, it seems to be that it’s returning a null result when trying to find the folders to delete but if I was to hardcode the specific folder that I want to delete, it still returns a null result when searching but successfully deletes the folder. Included a snippet of the code below:
Original:
Dim imap As Imap = ...
Dim fdate As Date = DateAdd(DateInterval.Month, -2, Now.Date)
imap.DeleteFolder("Inbox/" & Format(fdate, "yyyy-MM-dd ddd"))
Hardcoded:
Dim imap As Imap = ...
imap.DeleteFolder("Inbox/2022-05-01 Sun")
The code is looped from two months back through to a period of 7 days from the date the code is being run.
Using the original version, it won’t find or delete the folder.
Using the alternative version, it can delete the folder but doesn’t recognize it’s deleted or found the folder in the logs.