Reputation: 7883
I want to provide a preview of a user's messages, but I don't wish to download attachments just in order to do that.
The information I need is:
By calling the method fetchMessagesByNumberOperationWithFolder:
with request kind MCOIMAPMessagesRequestKindHeaders
, I get the date and subject, but it's very slow to return if any of the messages have attachments. By calling it with request kind MCOIMAPMessagesRequestKindUid
, it returns very quickly, with just the Uid
(and the current date, as a placeholder). From there, I still need to get the subject, the date and the sender.
Now I'm still trying to get this information, while avoiding downloading message attachments.
Calling fetchParsedMessageOperationWithFolder:
or fetchMessageOperationWithFolder:
both download the message with attachments, and are thus very slow to return.
Because fetchMessageOperationWithFolder:
completes with a NSData
object, checking the size of the given object reveals it to be the size of a regular message, plus its' attachment.
What can I do to get the information I need, without downloading any attachments?
EDIT: Calling requiredPartsForRendering
could give me the content of the email, but in order to retrieve the Date and sender information, I'd still have to have a request kind of MCOIMAPMessagesRequestKindHeaders
, which would download the attachment.
So to clarify:
I want to get the following information from an IMAP email, without downloading the email attachments:
Upvotes: 3
Views: 1672
Reputation: 478
The following methods should be helpful to you:
-[MCOAbstractMessage requiredPartsForRendering]
will return the message parts that you needs to fetch to be able to show the text content of the message.
-[MCOIMAPSession fetchMessageAttachmentOperationWithFolder:uid:partID:encoding:]
will help you fetch each of those parts.
-[MCOIMAPMessage htmlRenderingWithFolder:delegate:]
will return the rendered content as HTML (or nil if you don't provide all the content of the parts through the delegate.
-[NSString mco_flattenHTML]
is also useful if you'd like to convert the HTML to a unformatted string.
Upvotes: 3