Author |
|
jay.ganesh Newbie
Joined: 09 February 2012
Online Status: Offline Posts: 6
|
Posted: 09 February 2012 at 2:04pm | IP Logged
|
|
|
I am trying the evaluation version of the IMAP component and encountered a problem while using it.
What I intend to do is to read all the messages from the inbox and move them to specific folders based on the subject and also insert them in to the database. I am using MoveMessage function with UId's for this.
The problem is, move succeeds when moving the first message in to the folder and fails when moving the second message. It fails with an exception 'Empty or null argument value is not allowed'.Looking at the log file shows an error when setting the message flags after moving the message.
//code
MailMessageCollection messageCollection = imapObject.DownloadEntireMessages("1:*", false);
foreach (MailMessage msg in messageCollection)
{
string matchResult = new RegularExpressionEvaluator(lstRegex).GetMatch(msg.Subject);
if (!string.IsNullOrEmpty(matchResult))
{
//move to folder specified and insert in db
InsertInDb(0, "NOT FOUND", msg.Subject, msg.BodyHtmlText, msg.Importance.ToString(), msg.DateReceived);
if (CheckFolderExists("Inbox/" + matchResult))
{
imapObject.MoveMessages(msg.UidO nServer.ToString(), true, GetImapFolderName("Inbox/" + matchResult));
MarkMessageAsUnread(GetImapFolde rName("Inbox/" + matchResult));
}
else
{
//create and move
imapObject.CreateFolder(GetImapF olderName("Inbox/" + matchResult));
imapObject.MoveMessages(msg.UidO nServer.ToString(), true, GetImapFolderName("Inbox/" + matchResult));
MarkMessageAsUnread(GetImapFolde rName("Inbox/" + matchResult));
}
}
}
//Mark the messages left in inbox as unread
MarkMessagesAsUnread("Inbox");
}
catch(Exception ex)
{
}
finally
{
if (imapObject.IsConnected)
{
imapObject.Close();
Disconnect();
}
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 09 February 2012 at 2:07pm | IP Logged
|
|
|
The actual log will be helpful. You can submit it via Helpdesk if it contains sensitive information.
Regards,
A;ex
|
Back to Top |
|
|
jay.ganesh Newbie
Joined: 09 February 2012
Online Status: Offline Posts: 6
|
Posted: 09 February 2012 at 2:07pm | IP Logged
|
|
|
//log
10:27:14.73] [RECV] * LIST (\HasNoChildren) "/" Sent\r\n [Total 34 bytes received.]
[10:27:14.73] [RECV] * LIST (\HasNoChildren) "/" Spam\r\n [Total 34 bytes received.]
[10:27:14.73] [RECV] * LIST (\HasNoChildren) "/" Trash\r\n [Total 35 bytes received.]
[10:27:14.73] [RECV] MBN00000014 OK LIST completed\r\n [Total 31 bytes received.]
[10:27:14.73] [INFO] Folder list downloaded.
[10:27:16.99] [INFO] Will move messages to folder "INBOX/jaytest".
[10:27:16.99] [INFO] Will copy messages to folder "INBOX/jaytest".
[10:27:16.99] [SEND] MBN00000015 UID COPY 38454 "INBOX/jaytest"\r\n
[10:27:17.04] [RECV] MBN00000015 OK UID COPY completed\r\n [Total 35 bytes received.]
[10:27:17.04] [INFO] Messages copied.
[10:27:17.04] [INFO] Setting flags for messages.
[10:27:17.05] [INFO] Error: Empty or null argument value is not allowed.
[10:27:34.79] [INFO] Close folder.
[10:27:34.82] [SEND] MBN00000016 CLOSE\r\n
[10:27:34.98] [RECV] MBN00000016 OK CLOSE completed\r\n [Total 32 bytes received.]
[10:27:35.00] [SEND] MBN00000017 LOGOUT\r\n
[10:27:35.03] [RECV] * BYE Server logging out\r\n [Total 26 bytes received.]
[10:27:35.03] [RECV] MBN00000017 OK LOGOUT completed\r\n [Total 33 bytes received.]
[10:27:35.03] [INFO] Will disconnect from host "imap.1and1.co.uk".
[10:27:35.04] [INFO] Disconnected from host "imap.1and1.co.uk".
|
Back to Top |
|
|
jay.ganesh Newbie
Joined: 09 February 2012
Online Status: Offline Posts: 6
|
Posted: 09 February 2012 at 2:13pm | IP Logged
|
|
|
Hi Alex,
I already submitted via helpdesk with log file and code.
thanks
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 09 February 2012 at 2:50pm | IP Logged
|
|
|
Oh, I indeed found the original inquiry. Thanks.
The outcome was the missing COPYUID value in some of UID COPY results from the server (a bug on the IMAP server).
Regards,
Alex
|
Back to Top |
|
|
jay.ganesh Newbie
Joined: 09 February 2012
Online Status: Offline Posts: 6
|
Posted: 10 February 2012 at 2:19am | IP Logged
|
|
|
Hi Alex,
I get an error the first time I try to move because the message hasn't got a copy UId argument.I stop the application, and run it again and the same message has a copy Uid argument this time and it gets moved and the next message doesn't have a copy uid argument and so fails. stop it and run it, the same message which failed last time gets moved and the next one fails... goes on
Is it a bug on the server?
Thanks
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 10 February 2012 at 3:55am | IP Logged
|
|
|
A bug, definitely. If fixing it on the server is not an option for you (I guess so), try to avoid multiple UID COPY operations per IMAP session. For instance, you can move multiple messages with a single command instead of issuing multiple commands where each of them moves only a single messages.
Regards,
Alex
|
Back to Top |
|
|
jay.ganesh Newbie
Joined: 09 February 2012
Online Status: Offline Posts: 6
|
Posted: 22 February 2012 at 9:58am | IP Logged
|
|
|
Hi Alex,
I got a reply from our hosting providers.
Thank you for contacting us. Our administrators have confirmed that is was not a bug on our end.
The following response only exists, if at least 1 mail has been copied:
"[COPYUID 1328782884 38453 1]"
If no mail has been copied, we therefore don't know the new UID, as there is not one.
"A non-existent unique identifier is ignored without any error message generated. Thus, it is possible for a UID FETCH command to return an OK without any data or a UID COPY or UID STORE to return an OK without performing any operations."
regards,
Jay
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 23 February 2012 at 2:10am | IP Logged
|
|
|
OK, sounds reasonable. Perhaps, the problem is with the wrong parameter value you're passing to MoveMessages. If you pass wrong (non-existent) UID, the result can be that you get from the mail server.
Regards,
Alex
|
Back to Top |
|
|