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.59k stars 623 forks source link

iOS mailCore integration issue #1958

Open yihoushuhang opened 1 year ago

yihoushuhang commented 1 year ago

Hello the iOS MailCore don't being able to find MCOIMAPMoveMessagesOperation.h file when using CocoaPods and 'MCOSMTPSendOperation' callback not responding when using Carthage. I use XCode version: 14.0

MCOMessageBuilder *msgBuilder = [[MCOMessageBuilder alloc] init];
//header;
if (displayName != nil) {
    msgBuilder.header.from = [MCOAddress addressWithDisplayName:displayName mailbox:mail];
}else{
    msgBuilder.header.from = [MCOAddress addressWithMailbox:mail];
}
msgBuilder.header.to      = [self mailStringToMCOAddress:to];//transform address function
msgBuilder.header.cc      = [self mailStringToMCOAddress:cc];
msgBuilder.header.bcc     = [self mailStringToMCOAddress:bcc];
msgBuilder.header.subject = subject;

if (msgParser != nil) {
      NSArray *inAttach = msgParser.htmlInlineAttachments;
      for (MCOAttachment *attach in inAttach) {
          NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@_%@",msgParser.header.messageID,attach.filename]];
          NSData *data = [NSData dataWithContentsOfFile:path];
          if (data) {
              MCOAttachment *temp = [MCOAttachment attachmentWithData:data filename:attach.filename];
              temp.inlineAttachment = YES;
              [msgBuilder addRelatedAttachment:temp];
          }
      }
  }
if (attachs) {
    for (NSString *name in attachs.allKeys) {
        MCOAttachment *attach = [MCOAttachment attachmentWithData:[attachs objectForKey:name] filename:name];
        [msgBuilder addAttachment:attach];
    }
}

//body
[msgBuilder setHTMLBody:body];
NSData *data = [msgBuilder data];

MCOSMTPSendOperation *send = [self.smtpSession sendOperationWithData:data];
[send start:^(NSError * _Nullable error) {
    if (error) {
        fail(error);
    }else {
        MCOIMAPAppendMessageOperation *op = [self.imapSession appendMessageOperationWithFolder:@"Sent" messageData:data flags:MCOMessageFlagSeen];
        op.progress = ^(unsigned int current, unsigned int maximum) {
            NSLog(@"%d--%d",current,maximum);
        };
        [op start:^(NSError * _Nullable error, uint32_t createdUID) {
            if (error) {
                NSLog(@"%u---failed%@",createdUID,error.description);
            }else {
                NSLog(@"success");
            }
        }];
        complete();
    }
}];
yihoushuhang commented 1 year ago

I checked out commit is "a23882b13a1028753d1bdaef795cfd91acd7be8c". Looks like the latest commit

image