Author |
|
kasparschmid Newbie
Joined: 19 July 2007
Online Status: Offline Posts: 3
|
Posted: 21 August 2007 at 11:58pm | IP Logged
|
|
|
If i download a UNREAD message, i get a strange error:
Code:
MailBee.ImapMail.MailBeeImapInvalidEnvelopeException The envelope data is corrupted or incorrect. Envelope.IsValid will be false. The invalid envelope message number is: 10. |
|
|
The message is automatically marked as READ. If i download the message now, it all works fine.
What could be the problem?
I can download the message too, if i use ExamineFolder instead of SelectFolder, but then, the message is not marked as READ automatically.
Code fragment to download the message:
Code:
try {
// Connect to the server, login and select inbox.
imp.Connect(loginServer);
imp.Login(loginUser, loginPass);
imp.SelectFolder(FolderNames[currentFolder]);
} catch (MailBee.ImapMail.MailBeeImapLoginBadCredentialsException error) {
return "ERROR: Bad Credentials!";
} catch (MailBee.MailBeeGetRemoteHostNameException error) {
return "ERROR: Mail Server not found!";
} catch (MailBee.MailBeeException error) {
return "ERROR: "+error.ToString();
}
MailMessage message = imp.DownloadEntireMessage(long.Parse(Uid), true); |
|
|
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 22 August 2007 at 1:31am | IP Logged
|
|
|
Which IMAP server (exact name and version) you use? Have you tried to reproduce the issue via another mail client like MS Outlook?
Is it possible to provide us with a test account on your IMAP server? So, we would be able to reproduce and investigate the issue.
You can use Request Support Form for this purpose.
Best regards,
Andrew
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 29 August 2007 at 11:20am | IP Logged
|
|
|
We examined the issue and found out it's caused by incorrect behaviour of your mail server. For each request, it sends two responses instead of one. You can workaround this problem by telling MailBee to ignore invalid responses.
Instead of using
Code:
MailMessage message = imp.DownloadEntireMessage(long.Parse(Uid), true); |
|
|
use
Code:
EnvelopeCollection envs = imp.DownloadEnvelopes(long.Parse(Uid), true,
EnvelopeParts.MessagePreview | EnvelopeParts.Flags, -1);
MailMessage msg = envs[0].MessagePreview;
|
|
|
BTW, you can download multiple emails at once with this approach. If you decide to download multiple emails, you should skip elements which have Envelope.IsValid==false (they will corredpond to those responses which are bad).
However, you can still take advantage of bad responses as well. Actually your server does quite a weird thing (this is error behaviour which is better to be fixed by the server developers but let's see what you can do with MailBee right now). It splits things which should reside in a single response into two. Thus, some piece of data resides in the second response only while the first response may contain the same data missing or wrong. In particular, the data in question is flags information (\Seen, \Recent, etc). If you need this information, you should examine if the particular envelope is IsValid==false and check its Uid. If the collection already contains the same Uid, you should take the envelope with the same Uid but IsValid==true for all fields except Flags. For Flags, you should use the counterpart with the same Uid and IsValid==false.
If you're downloading only a single email each time and want to get Flags data, the approach is simpler. Examine if the returned collection contains the second element (envs.Count > 1) and check if envs[0].Uid == envs[1].Uid. If yes, you should take your message from envs[0].MessagePreview (as in the example above) and the flags from envs[1].Flags.
Regards,
Alex
|
Back to Top |
|
|