MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.58k stars 623 forks source link

[Bug] - Obtain the email body flash back #1975

Closed chensunwang closed 1 year ago

chensunwang commented 1 year ago

Summary When the mail content is null, get less than will flash back.

iOS 16.4, Xcode14.3 Platform(s)

<iOS>

Happens on Mail Server

<Gmail>
<iCloud>

Piece of code

- (void)fetchHtmlRenderingWidthFolder:(NSString *)folder imapMessage:(MCOIMAPMessage *)imapMessage
                           completion:(void (^)(NSError *error, NSString *htmlString))completion {
    MCOIMAPMessageRenderingOperation * fetchRendingOp = [self.imapSession htmlBodyRenderingOperationWithMessage:imapMessage folder:folder];
    [fetchRendingOp start:^(NSString *htmlString, NSError *error) {
        if ([error code] != MCOErrorNone) {
            [[NSNotificationCenter defaultCenter] postNotificationName:LSMail_Mail_LoadMSG_Error object:error];
            if (completion) { completion(error,nil); } return;
        }
        if (completion) {
            NSString *htmlStr = htmlString;
            NSRange locationRange = [htmlString rangeOfString:@"<html xmlns="];
            if (locationRange.location > 0 && locationRange.length > 0) {
                htmlStr = [htmlString substringFromIndex:locationRange.location];
                NSRange endRange = [htmlStr rangeOfString:@"</html>" options:NSBackwardsSearch];
                if (endRange.length > 0 && endRange.location > 0) {
                    htmlStr = [htmlStr substringToIndex:(endRange.location+endRange.length)];
                }
            }
            completion(error,htmlStr);
        }
    }];
}

Actual outcome fetchRendingOp calls the start method and flashes back

Connection Logs

Expected outcome Hope to get the content of the email

Link to sample code on GitHub reproducing the issue (a full Xcode project):

https://