当前位置: 首页 > 工具软件 > Mailcore > 使用案例 >

mailcore2 android,Mailcore2的一些坑

皇甫琛
2023-12-01

该博客主要描述我所遇到的问题情况。配置环境我附上连接自己去看看。

Mailcore2的配置

For iOS - If you're targeting iOS, you have to link against MailCore 2 as a static library:

1.Add libMailCore-ios.a

2.Add CFNetwork.framework

3.Add Security.framework

4.Set 'Other Linker Flags': -lctemplate-ios -letpan-ios -lxml2 -lsasl2 -liconv -ltidy -lz -lc++ -lresolv -stdlib=libc++ -ObjC

5.Make sure to use LLVM C++ standard library. Open Build Settings, scroll down to 'C++ Standard Library', and select libc++.

6.In Build Phases, add a Target Dependency of static mailcore2 ios.

该视频是iOS配置的视频 不过有些地方和官方代码不一样,还是以官方的代码配置为主,具体那里不同自己看后对比就知道

遇到的坑

Error Domain=MCOErrorDomain Code=5 "Unable to authenticate with the current session's credentials." UserInfo={NSLocalizedDescription=Unable to authenticate with the current session's credentials.}

这个错误主要是邮箱帐号或者密码错误。邮箱后缀是否正确。如163邮箱密码是使用授权码而不是登录密码(这个只是针对hostname:imap.163.com,当hostname:appleimap.163.com用邮箱登录密码依然可以使用)。

Error Domain=MCOErrorDomain Code=4 "The certificate for this server is invalid." UserInfo={NSLocalizedDescription=The certificate for this server is invalid.}

服务器证书无效,可以将checkCertificateEnabled 设置为NO,即session.checkCertificateEnabled = NO;

Error Domain=MCOErrorDomain Code=1 "A stable connection to the server could not be established." UserInfo={NSLocalizedDescription=A stable connection to the server could not be established.}

这个错误可以从以下三个方面尝试解决:

1.hostname不存在,或者拼写错误,修改hostname;该hostname不一定是 imap.**.com,我项目中用到的hostname是 10.101.10.1(主机名)。

2.需要SSL安全链接,将connectionType设置为MCOConnectionTypeTLS;

3.端口号错误。

以上解决后就可以跑起代码了。

附加其他情况:

unzip: cannot find zipfile directory in one of ctemplate-osx-3.zip or

ctemplate-osx-3.zip.zip, and cannot find ctemplate-osx-3.zip.ZIP, period.

/Users/somewhere/mailcore2-0.6.2/scripts/include.sh/build-dep.sh: line 329: cd: ctemplate-osx-3: No such file or directory

找不到'libetpan / libetpan.h'文件

找不到'unicode / udat.h'文件

找不到'ctemplate / template.h'文件

该问题是应该你导入的mailcore2中的libMailCore-ios.a为红色没有导入成功。

解决方法:

1.先运行 static mailcore2 ios

再运行 mailcore2 ios

3.再选择你自己的schemes的项目进行运行。

最后libMailCore-ios.a 库就导入进来了。(如果还是不行的话,用4g进行 下载libMailCore-ios.a)

解决中文名字的文件夹乱码问题

[[imapSession defaultNamespace] componentsFromPath:folder.path])

问题:如何添加正文附件

for (NHLineAttachment *lineAttachment in lineAttachmentArray) {

MCOAttachment *attachment = [MCOAttachment attachmentWithContentsOfFile:lineAttachment.attach_localfile];

attachment.contentID = lineAttachment.attach_contentID;

[attachment setInlineAttachment:YES];

[messageBuilder addRelatedAttachment:attachment];

}

 类似资料: