Author |
|
boranin Newbie
Joined: 29 September 2007 Location: New Zealand
Online Status: Offline Posts: 32
|
Posted: 28 January 2008 at 12:03am | IP Logged
|
|
|
I will use this post to ask questions I come across while coding WebMail application. Your help will be very appreciated.
1) Downloading all envelopes in a purpose of showing first 20 in a web mail grid sounds too resource intensive. What is the best option for finding latest 20 and then next 20 after particular UID? Simple, geting next 20 message UIDs for supplied UID. If UID not supplied, then latest 20. Idealy, imap client would go to offline mode after retrieving envelopes and connecting again for geting next lot.
|
Back to Top |
|
|
boranin Newbie
Joined: 29 September 2007 Location: New Zealand
Online Status: Offline Posts: 32
|
Posted: 28 January 2008 at 12:58am | IP Logged
|
|
|
2) How can I get info on whether attachments are present in the message without downloading the whole message? This would be something as Evnelope.MessageHasAttachments = True/False.
|
Back to Top |
|
|
boranin Newbie
Joined: 29 September 2007 Location: New Zealand
Online Status: Offline Posts: 32
|
Posted: 28 January 2008 at 4:48am | IP Logged
|
|
|
3) This is more like feature request:
dim imp as Imap
dim envColl as EnvelopeCollection = imp.DownloadEnvelopes(...)
envColl.SortBy("From","ASC")
Easy sorting of EnvelopeCollection would be great feature. Please let me know if something like that is already available.
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 28 January 2008 at 9:28am | IP Logged
|
|
|
Quote:
1) Downloading all envelopes in a purpose of showing first 20 in a web mail grid sounds too resource intensive. What is the best option for finding latest 20 and then next 20 after particular UID? Simple, geting next 20 message UIDs for supplied UID. If UID not supplied, then latest 20. Idealy, imap client would go to offline mode after retrieving envelopes and connecting again for geting next lot. |
|
|
Yes, you're right.
Quote:
2) How can I get info on whether attachments are present in the message without downloading the whole message? This would be something as Evnelope.MessageHasAttachments = True/False. |
|
|
You can find an example here.
Quote:
3) This is more like feature request:
dim imp as Imap
dim envColl as EnvelopeCollection = imp.DownloadEnvelopes(...)
envColl.SortBy("From","ASC")
Easy sorting of EnvelopeCollection would be great feature. Please let me know if something like that is already available. |
|
|
Doesn't Imap.SortedSearch method fulfill your requirements?
Best regards,
Andrew
|
Back to Top |
|
|
boranin Newbie
Joined: 29 September 2007 Location: New Zealand
Online Status: Offline Posts: 32
|
Posted: 28 January 2008 at 10:16pm | IP Logged
|
|
|
Whole 15 words. I am thrilled!!!
4) When using MailMessage.HasAttachments I am getting True as result for messages with images as part of message body HTML (so no actual attachments in the message). In mail clients, this is not considered attachment. What is the workaround to get True only if message contains the real attachment?
PS
Example you provided (word No:9) has never worked for me. Attachment never gets recognized. Email server is SmarterMail 2.0.
|
Back to Top |
|
|
boranin Newbie
Joined: 29 September 2007 Location: New Zealand
Online Status: Offline Posts: 32
|
Posted: 28 January 2008 at 10:42pm | IP Logged
|
|
|
5) after msg=imp.DownloadEntireMessage(...) msg becomes read (Seen) message. How to prevent that or how to get it back unseen flag?
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 29 January 2008 at 4:29am | IP Logged
|
|
|
Quote:
4) When using MailMessage.HasAttachments I am getting True as result for messages with images as part of message body HTML (so no actual attachments in the message). In mail clients, this is not considered attachment. What is the workaround to get True only if message contains the real attachment? |
|
|
If you have not downloaded entire message, but downloaded message headers only, there is no reliable way to determine if the message has attachments or not.
If only message headers are available, MailMessage.HasAttachments checks "Content-Type" header (values like multipart/mixed) to determine if the message has attachments. But this approach is not 100% accurate.
The only reliable way is to download entire message and check attachments collection (MailMessage.HasAttachments does this if entire message is downloaded).
With regard to images as parts of HTML messages, they're indeed real attachments, but of special "in-line" type. That's why Attachment class provides IsInline and IsFile properties.
Does your application download entire message or just headers? If just headers, it's not possible to distinguish in-line attachments from non-in-line ones.
Quote:
PS
Example you provided (word No:9) has never worked for me. Attachment never gets recognized. Email server is SmarterMail 2.0. |
|
|
Are you sure your application downloaded EnvelopeParts.BodyStructure? This sample won't work if EnvelopeParts.BodyStructure is not downloaded.
Quote:
5) after msg=imp.DownloadEntireMessage(...) msg becomes read (Seen) message. How to prevent that or how to get it back unseen flag? |
|
|
The first approach is to open IMAP folder in read-only mode via Imap.ExamineFolder method.
The second one is to change flags after downloading in read-write mode via Imap.SetMessageFlags method.
Best regards,
Andrew
|
Back to Top |
|
|