Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 使用带有纯文本附件的MCOMessageBuilder创建新邮件时,内容类型/字符集错误_Swift_Swift3_Imap_Attachment_Mailcore2 - Fatal编程技术网

Swift 使用带有纯文本附件的MCOMessageBuilder创建新邮件时,内容类型/字符集错误

Swift 使用带有纯文本附件的MCOMessageBuilder创建新邮件时,内容类型/字符集错误,swift,swift3,imap,attachment,mailcore2,Swift,Swift3,Imap,Attachment,Mailcore2,我仍然试图通过复制消息并将消息头添加到新消息中来向消息添加自定义消息头(另请参见我的未回答问题) 对于带有附件的邮件,此功能已起作用。原始邮件的附件将复制到新邮件,包括(纯文本)邮件,该邮件也是附件。太好了!:-) 现在,我尝试对没有任何附件的邮件执行相同的操作。当我查看原始消息的源时,标题是: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 现在,我尝试使用以下代码(Swift 3)将邮

我仍然试图通过复制消息并将消息头添加到新消息中来向消息添加自定义消息头(另请参见我的未回答问题)

对于带有附件的邮件,此功能已起作用。原始邮件的附件将复制到新邮件,包括(纯文本)邮件,该邮件也是附件。太好了!:-)

现在,我尝试对没有任何附件的邮件执行相同的操作。当我查看原始消息的源时,标题是:

Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
现在,我尝试使用以下代码(Swift 3)将邮件正文复制为附件:

然后我用电子邮件发送消息

let appendOp = self.imapSession.appendMessageOperation(withFolder: withFolder, messageData: messageBuilder.data(), flags: MCOMessageFlag(rawValue: 0), customFlags: ["$label1"])

appendOp?.start{ (err, createdUid) in
    log.debug("error from server \(err)")
    log.debug("created uid: \(createdUid)")
}
问题是,在新消息中,文本被base64编码文本替换。标题上写着:

Content-Type: text/plain; charset=ISO-8859-1
[...many header lines...]
Content-Type: text/plain
Content-Transfer-Encoding: base64
如何防止从纯ISO-8859-1文本转换为base64编码文本

或者,我怎样才能在没有任何压扁、删除空白、HTML呈现等的情况下从原始邮件或原始附件中获取纯文本字符串

Content-Type: text/plain; charset=ISO-8859-1
[...many header lines...]
Content-Type: text/plain
Content-Transfer-Encoding: base64