Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Delete message Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 01 June 2008 at 2:26pm | IP Logged Quote Mhd

Hi, I'm trying to delete the message after reading it but it seems does not delete, What I'm doing wrong?



Dim objMsg As MailBee.Mime.MailMessage, arrNew, I, J

arrNew = imp.Search(True, "unseen", "")
If imp.MessageCount > 0 Then
   Dim objAtt As MailBee.Mime.AttachmentCollection
   For I = (arrNew.count - 1) To 0 Step -1
       objMsg = imp.DownloadEntireMessage(arrNew(I), True)

   objMsg.Parser.HeadersAsHtml = True
   objMsg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
   objMsg.Parser.PlainToHtmlOptions = PlainToHtmlConvertOptions.UriToLink

                   
   If m_Delete_After_Transfer Then
      imp.DeleteMessages(I.ToS tring + 1, False)
   End If
   Next
End If
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 02 June 2008 at 1:15am | IP Logged Quote Andrew

As described in the documentation:

Quote:
This method just sets "\Deleted" flag for the specified messages. To purge deleted messages permanently, call Expunge method or explicitly unselect the folder using Close method.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 28 June 2008 at 5:18am | IP Logged Quote Mhd

Hi again I used Expunge as you recomended but I got exception like the following:
"The server has responded with negative reply. The server responded: MBN00000008 BAD UID invalid arguments."

the exception appears on Expunge function.
Here is my code:

Dim objMsg As MailBee.Mime.MailMessage, arrNew, I, J

arrNew = imp.Search(True, "unseen", "")
If imp.MessageCount > 0 Then
   Dim objAtt As MailBee.Mime.AttachmentCollection
   For I = (arrNew.count - 1) To 0 Step -1
        imp.SetMessageFlags(I.ToString, False, SystemMessageFlags.Deleted, MessageFlagAction.Add)

objMsg = imp.DownloadEntireMessage(arrNew(I), True)

   objMsg.Parser.HeadersAsHtml = True
   objMsg.Parser.PlainToHtmlMode = PlainToHtmlAutoConvert.IfNoHtml
   objMsg.Parser.PlainToHtmlOptions = PlainToHtmlConvertOptions.UriToLink

                     
   If m_Delete_After_Transfer Then
      Dim uidList As EnvelopeCollection = imp.DownloadEnvelopes("1", False, EnvelopeParts.Uid, 0)

      If uidList.Count > 0 Then
        imp.Expunge(uidList(I).Uid.ToString(), False)
      End If
   End If
   Next
End If
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 28 June 2008 at 12:23pm | IP Logged Quote Andrew

Please enable logging, reproduce the issue and provide us with the log file for examination.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 28 June 2008 at 2:44pm | IP Logged Quote Mhd

[00:41:00.78] [INFO] Assembly version: 3.0.1.74.
[00:41:00.78] [INFO] Will resolve host "mail.smartlivesupport.com".
[00:41:02.00] [INFO] Host "mail.smartlivesupport.com" resolved to IP address(es) 69.90.236.51.
[00:41:02.01] [INFO] Will connect to host "mail.smartlivesupport.com" on port 143.
[00:41:02.92] [INFO] Socket connected to IP address 69.90.236.51 on port 143.
[00:41:03.60] [RECV] * OK IMAP4rev1 SmarterMail\r\n [Total 28 bytes received.]
[00:41:03.60] [INFO] Get the list of IMAP4 capabilities via CAPABILITY command.
[00:41:03.61] [SEND] MBN00000001 CAPABILITY\r\n
[00:41:03.86] [RECV] * CAPABILITY IMAP4 IMAP4rev1\r\n [Total 30 bytes received.]
[00:41:04.29] [RECV] MBN00000001 OK CAPABILITY completed\r\n [Total 37 bytes received.]
[00:41:04.59] [INFO] Connected to mail service at host "mail.smartlivesupport.com" on port 143 and ready.
[00:41:04.60] [INFO] Will login as "support@smartlivesupport.com".
[00:41:04.61] [INFO] Will try regular LOGIN authentication.
[00:41:04.61] [SEND] MBN00000002 LOGIN "support@smartlivesupport.com" "********"\r\n
[00:41:04.86] [RECV] MBN00000002 OK LOGIN completed\r\n [Total 32 bytes received.]
[00:41:04.86] [INFO] Logged in as "support@smartlivesupport.com".
[00:41:04.86] [INFO] Select folder "Inbox".
[00:41:04.86] [SEND] MBN00000003 SELECT "Inbox"\r\n
[00:41:05.11] [RECV] * 191 EXISTS\r\n [Total 14 bytes received.]
[00:41:05.55] [RECV] * 0 RECENT\r\n [Total 12 bytes received.]
[00:41:05.58] [RECV] * OK [UNSEEN 189] Message 189 is first unseen\r\n [Total 47 bytes received.]
[00:41:05.58] [RECV] * OK [UIDVALIDITY 0] UIDs valid\r\n [Total 33 bytes received.]
[00:41:05.58] [RECV] * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)\r\n [Total 52 bytes received.]
[00:41:05.58] [RECV] * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]\r\n [Total 66 bytes received.]
[00:41:05.58] [RECV] MBN00000003 OK [READ-WRITE] SELECT completed\r\n [Total 46 bytes received.]
[00:41:05.59] [INFO] Will perform search in the folder.
[00:41:05.59] [SEND] MBN00000004 UID SEARCH unseen\r\n
[00:41:05.94] [RECV] * SEARCH 567\r\n [Total 14 bytes received.]
[00:41:06.42] [RECV] MBN00000004 OK UID completed\r\n [Total 30 bytes received.]
[00:41:06.42] [INFO] Search done.
[00:41:06.48] [INFO] Setting flags for messages.
[00:41:06.48] [SEND] MBN00000005 STORE 0 +FLAGS.SILENT (\Deleted)\r\n
[00:41:06.72] [RECV] MBN00000005 OK STORE completed\r\n [Total 32 bytes received.]
[00:41:06.76] [INFO] Will download envelopes.
[00:41:06.76] [SEND] MBN00000006 UID FETCH 567 (UID RFC822.SIZE BODY[])\r\n
[00:41:07.45] [RECV] * 189 FETCH (UID 567 RFC822.SIZE 567 BODY[] {567}\r\n
[00:41:07.45] [RECV] [Literal of length 567.]
[00:41:07.45] [RECV] )\r\n [Total 621 bytes received.]
[00:41:07.59] [RECV] MBN00000006 OK UID completed\r\n [Total 30 bytes received.]
[00:41:07.59] [INFO] Envelopes downloaded
[00:41:10.48] [INFO] Will download envelopes.
[00:41:10.48] [SEND] MBN00000007 FETCH 1 (UID)\r\n
[00:41:11.16] [RECV] * 1 FETCH (UID 49)\r\n [Total 20 bytes received.]
[00:41:11.17] [RECV] MBN00000007 OK FETCH completed\r\n [Total 32 bytes received.]
[00:41:11.17] [INFO] Envelopes downloaded
[00:41:11.17] [INFO] Expunge messages with UIDs "49" from the folder.
[00:41:11.17] [INFO] Will perform search in the folder.
[00:41:11.17] [SEND] MBN00000008 UID SEARCH DELETED NOT UID 49\r\n
[00:41:11.41] [RECV] MBN00000008 BAD UID invalid arguments\r\n [Total 39 bytes received.]
[00:41:11.43] [INFO] Error: The server has responded with negative reply. The server responded: MBN00000008 BAD UID invalid arguments.
[00:41:11.43] [SEND] MBN00000009 LOGOUT\r\n
[00:41:11.75] [RECV] * BYE IMAP4rev1 Server logging out\r\n [Total 36 bytes received.]
[00:41:11.75] [RECV] MBN00000009 OK LOGOUT completed\r\n [Total 33 bytes received.]
[00:41:11.75] [INFO] Will disconnect from host "mail.smartlivesupport.com".
[00:41:11.78] [INFO] Disconnected from host "mail.smartlivesupport.com".
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 28 June 2008 at 11:01pm | IP Logged Quote Andrew

There's something wrong in the source code you provided:

1. For some reason, it always downloads the first envelope:

Code:
Dim uidList As EnvelopeCollection = imp.DownloadEnvelopes("1", False, EnvelopeParts.Uid, 0)


2. It passes entire envelope to Expunge method, while it requires just UID:

Code:
imp.Expunge(uidList(I).Uid.ToString(), False)


If we understood you correctly, you need to mark as deleted just downloaded message and then expunge it. So, your code should be similar to:

Code:
Dim objMsg As MailBee.Mime.MailMessage, arrNew, I, J

arrNew = imp.Search(True, "unseen", "")
If imp.MessageCount > 0 Then
   Dim objAtt As MailBee.Mime.AttachmentCollection
   For I = (arrNew.count - 1) To 0 Step -1
      ' Download message by UID instead of index
      objMsg = imp.DownloadEntireMessage(arrNew(I), True)

      objMsg.Parser.HeadersAsH tml = True
      objMsg.Parser.PlainToHtm lMode = PlainToHtmlAutoConvert.IfNoHtml
      objMsg.Parser.PlainToHtm lOptions = PlainToHtmlConvertOptions.UriToLink

      If m_Delete_After_Transfer Then
        ' Mark the downloaded message as deleted
        imp.SetMessageFlags(arrNew(I).ToString(), True, SystemMessageFlags.Deleted, MessageFlagAction.Add)
        ' Expunge the message
        imp.Expunge(arrNew(I).ToString(), True)
      End If
   Next
End If


However, this code may be simplified. For instance, it's possible to use Imap.DeleteMessages instead of Imap.SetMessageFlags.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 29 June 2008 at 1:30am | IP Logged Quote Mhd

Thank you for the quick response but now we got a new exception that appears on Expunge function says:
"The IMAP4 server does not support UIDPLUS capability required for the current operation to complete."

Any suggestion please?
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 29 June 2008 at 4:22am | IP Logged Quote Andrew

Try to call Expunge without any arguments. Does it work?

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 29 June 2008 at 9:18am | IP Logged Quote Mhd

Yes Expunge without any arguments works successfully, What do you suggest?
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 30 June 2008 at 1:57am | IP Logged Quote Igor

Expunge with arguments uses UIDPLUS IMAP extension to select necessary messages by their UIDs, but your IMAP server does not support this extension.
However, there is still a workaround. Try to set the second argument of Expunge to False:
Code:
imp.Expunge(arrNew(I).ToString(), False);

In this case Expunge will try to emulate UIDPLUS feature using other IMAP commands.
See the documentation page for more details:
http://www.afterlogic.com/mailbee_net/docs/MailBee.ImapMail. Imap.Expunge_overload_1.html

Regards, Igor.
Back to Top View Igor's Profile Search for other posts by Igor
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 01 July 2008 at 2:03am | IP Logged Quote Mhd

I got the same earlier exception: "The server has responded with negative reply. The server responded: MBN00000008 BAD UID invalid arguments. "
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 01 July 2008 at 3:14am | IP Logged Quote Andrew

Please provide us with the source code you currently use. Also, please enable logging, reproduce the issue and provide us with the new log file for examination.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 01 July 2008 at 8:28am | IP Logged Quote Mhd

Here is the log file:
[18:23:24.68] [INFO] Assembly version: 3.0.1.74.
[18:23:24.63] [INFO] Will resolve host "mail.mydomain.com".
[18:23:25.58] [INFO] Host "mail.mydomain.com" resolved to IP address(es) 69.90.236.51.
[18:23:25.58] [INFO] Will connect to host "mail.mydomain.com" on port 143.
[18:23:26.13] [INFO] Socket connected to IP address 69.90.236.51 on port 143.
[18:23:26.79] [RECV] * OK IMAP4rev1 SmarterMail\r\n [Total 28 bytes received.]
[18:23:26.92] [INFO] Get the list of IMAP4 capabilities via CAPABILITY command.
[18:23:26.92] [SEND] MBN00000001 CAPABILITY\r\n
[18:23:27.18] [RECV] * CAPABILITY IMAP4 IMAP4rev1\r\n [Total 30 bytes received.]
[18:23:27.62] [RECV] MBN00000001 OK CAPABILITY completed\r\n [Total 37 bytes received.]
[18:23:27.65] [INFO] Connected to mail service at host "mail.mydomain.com" on port 143 and ready.
[18:23:27.65] [INFO] Will login as "support@smartlivesupport.com".
[18:23:27.66] [INFO] Will try regular LOGIN authentication.
[18:23:27.66] [SEND] MBN00000002 LOGIN "support@smartlivesupport.com" "********"\r\n
[18:23:27.92] [RECV] MBN00000002 OK LOGIN completed\r\n [Total 32 bytes received.]
[18:23:27.92] [INFO] Logged in as "support@smartlivesupport.com".
[18:23:27.92] [INFO] Select folder "Inbox".
[18:23:27.92] [SEND] MBN00000003 SELECT "Inbox"\r\n
[18:23:28.18] [RECV] * 185 EXISTS\r\n [Total 14 bytes received.]
[18:23:28.63] [RECV] * 0 RECENT\r\n [Total 12 bytes received.]
[18:23:28.64] [RECV] * OK [UNSEEN 167] Message 167 is first unseen\r\n [Total 47 bytes received.]
[18:23:28.64] [RECV] * OK [UIDVALIDITY 0] UIDs valid\r\n [Total 33 bytes received.]
[18:23:28.64] [RECV] * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)\r\n [Total 52 bytes received.]
[18:23:28.65] [RECV] * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft)]\r\n [Total 66 bytes received.]
[18:23:28.65] [RECV] MBN00000003 OK [READ-WRITE] SELECT completed\r\n [Total 46 bytes received.]
[18:23:28.65] [INFO] Will perform search in the folder.
[18:23:28.65] [SEND] MBN00000004 UID SEARCH unseen\r\n
[18:23:28.92] [RECV] * SEARCH 473 485 487\r\n [Total 22 bytes received.]
[18:23:29.38] [RECV] MBN00000004 OK UID completed\r\n [Total 30 bytes received.]
[18:23:29.38] [INFO] Search done.
[18:23:29.49] [INFO] Will download envelopes.
[18:23:29.49] [SEND] MBN00000005 UID FETCH 487 (UID RFC822.SIZE BODY[])\r\n
[18:23:29.87] [RECV] * 172 FETCH (UID 487 RFC822.SIZE 6093 BODY[] {6093}\r\n
[18:23:29.87] [RECV] [Literal of length 6093.]
[18:23:29.88] [RECV] )\r\n [Total 6149 bytes received.]
[18:23:29.98] [RECV] MBN00000005 OK UID completed\r\n [Total 30 bytes received.]
[18:23:29.98] [INFO] Envelopes downloaded
[18:23:32.98] [INFO] Will download envelopes.
[18:23:33.27] [SEND] MBN00000006 FETCH 1 (UID)\r\n
[18:23:33.99] [RECV] * 1 FETCH (UID 53)\r\n [Total 20 bytes received.]
[18:23:34.00] [RECV] MBN00000006 OK FETCH completed\r\n [Total 32 bytes received.]
[18:23:34.00] [INFO] Envelopes downloaded
[18:23:34.00] [INFO] Setting flags for messages.
[18:23:34.00] [SEND] MBN00000007 UID STORE 487 +FLAGS.SILENT (\Deleted)\r\n
[18:23:35.56] [RECV] MBN00000007 OK UID completed\r\n [Total 30 bytes received.]
[18:23:35.56] [INFO] Expunge messages with UIDs "487" from the folder.
[18:23:35.56] [INFO] Will perform search in the folder.
[18:23:35.56] [SEND] MBN00000008 UID SEARCH DELETED NOT UID 487\r\n
[18:23:35.82] [RECV] MBN00000008 BAD UID invalid arguments\r\n [Total 39 bytes received.]
[18:23:35.83] [INFO] Error: The server has responded with negative reply. The server responded: MBN00000008 BAD UID invalid arguments.
[18:23:35.84] [SEND] MBN00000009 LOGOUT\r\n
[18:23:36.12] [RECV] * BYE IMAP4rev1 Server logging out\r\n [Total 36 bytes received.]
[18:23:36.12] [RECV] MBN00000009 OK LOGOUT completed\r\n [Total 33 bytes received.]
[18:23:36.12] [INFO] Will disconnect from host "mail.mydomain.com".
[18:23:36.16] [INFO] Disconnected from host "mail.mydomain.com".


And here is my code, it's the same as the prevoius one except that I pass false parameter to the Expunge function:

arrNew = imp.Search(True, "unseen", "")
If imp.MessageCount > 0 Then
   Dim objAtt As MailBee.Mime.AttachmentCollection
   For I = (arrNew.count - 1) To 0 Step -1
      ' Download message by UID instead of index
      objMsg = imp.DownloadEntireMessage(arrNew(I), True)

      objMsg.Parser.HeadersAsH tml = True
      objMsg.Parser.PlainToHtm lMode = PlainToHtmlAutoConvert.IfNoHtml
      objMsg.Parser.PlainToHtm lOptions = PlainToHtmlConvertOptions.UriToLink

      If m_Delete_After_Transfer Then
        ' Mark the downloaded message as deleted
        imp.SetMessageFlags(arrNew(I).ToString(), True, SystemMessageFlags.Deleted, MessageFlagAction.Add)
        ' Expunge the message
        imp.Expunge(arrNew(I).ToString(), False)
      End If
   Next
End If
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 01 July 2008 at 9:15am | IP Logged Quote Alex

Looks like the bug in the server (SmarterMail). Many mail server vendors do not pay much attention to those parts of IMAP functionality which is not used by popular mail clients like Outlook.

"UID SEARCH DELETED NOT UID 487" is a valid IMAP command, but it's not used by other mail clients and thus is probably not supported by this server (maybe, it's just not implemented). Other mail servers support it properly. You should contact your mail server manufacturer for resolving this issue.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Mhd
Newbie
Newbie


Joined: 18 February 2008
Location: United Kingdom
Online Status: Offline
Posts: 38
Posted: 01 July 2008 at 9:25am | IP Logged Quote Mhd

Hi, actually we want to use your compoenet in our application which will be installed on different mail server so SmarterMail is not our concern, now what do you suggest to use, please provide us with code that uses exponge function which should work on the most servers.
Back to Top View Mhd's Profile Search for other posts by Mhd
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 02 July 2008 at 12:25am | IP Logged Quote Andrew

Just use Imap.Expunge without arguments. It works with any IMAP server.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide