GMail将不会打开由iPhone应用程序创建的.txt附件,根据大小 - 我认为在我的MIME中有一个Bug [英] GMail won't open .txt attachment created by iPhone App, Depending on Size - I think There's a Bug in my MIME

查看:80
本文介绍了GMail将不会打开由iPhone应用程序创建的.txt附件,根据大小 - 我认为在我的MIME中有一个Bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iPhone应用程式中建立了一个附有.txt附件的简短电子邮件。


  1. 大约10行长,GMail打开它只是罚款。


  2. 如果超过20行,GMail会阻塞 - 不会打开附件,下载附件,甚至转发电子邮件。 p>


  3. 此外,如果我向同事发送相同的电子邮件,他用他的Mac OS Mail客户端打开它,一切都很好。


例如,以下是文本文件的内容(此长度将在GMail中打开就好了):

 加速度计读数
-0.0724487,-0.941833,-0.235458,2009-07-11 15:18:46 -0700
-0.0724487, -0.941833,-0.271683,2009-07-11 15:18:47 -0700
-0.0724487,-0.923721,-0.253571,2009-07-11 15:18:48 -0700
-0.0543365, -0.923721,-0.326019,2009-07-11 15:18:49 -0700
-0.0724487,-0.959946,-0.181122,2009-07-11 15:18:50 -0700
-0.0543365, -0.923721,-0.253571,2009-07-11 15:18:51 -0700
-0.108673,-0.923721,-0.380356,2009-07-11 15:18:52 -0700
-0.0724487, -0.923721,-0.271683,2009-07-11 15:18:53 -0700

GPS读数

标题阅读
211.421,2009-07-11 15 :18:46 -0700
206.421,2009-07-11 15:18:49 -0700
184.421,2009-07-11 15:18:50 -0700
195.421,2009- 07-11 15:18:51 -0700
198.421,2009-07-11 15:18:53 -0700

如果文件是这个大小的两倍,GMail不能处理ith它,但再次邮件可以。那么,可能是什么问题?我创建了如下电子邮件:

  SKPSMTPMessage * testMsg = [[SKPSMTPMessage alloc] init]; 
testMsg.fromEmail = @founders@gmail.com;
testMsg.toEmail = @andrewljohnson@trailbehind.com;
testMsg.relayHost = @smtp3.webfaction.com;
testMsg.requiresAuth = YES;
testMsg.login = @andrewljohnson;
testMsg.pass = @********;
testMsg.subject = @iPhone乐器阅读;
testMsg.wantsSecure = YES; // smtp.gmail.com不工作没有TLS!
testMsg.delegate = self;

NSDictionary * plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@text / plain,kSKPSMTPPartContentTypeKey,@Hey Kevin,\ n您有一些GPS读数可供筛选。\\\
\\\
Love, \\ nTrailBehind,kSKPSMTPPartMessageKey,@8bit,kSKPSMTPPartContentTransferEncodingKey,nil];
NSData * fileData = [NSData dataWithContentsOfFile:fileName];
NSDictionary * attached = [NSDictionary dictionaryWithObjectsAndKeys:@text / directory; \r\\\
\tx-unix-mode = 0644; \r\\\
\tname = \readings.txt \,kSKPSMTPPartContentTypeKey,@attachment; \r\\\
\ tfilename = \readings.txt\,kSKPSMTPPartContentDispositionKey,[fileData encodeBase64ForData],kSKPSMTPPartMessageKey,@base64,kSKPSMTPPartContentTransferEncodingKey,nil] ;

testMsg.parts = [NSArray arrayWithObjects:plainPart,attached,nil];
[testMsg send];


解决方案

您正在使用 fileData encodeBase64ForData] 但我看到还有一个函数 encodeBase64ForDataWrapped 它添加换行符。也许你应该打电话,而如果你的附件是足够长的长base64线是混乱的人。


I have created aand sent a short email with a .txt attachment in an iPhone app.

  1. If the attachment is about 10 lines long, GMail opens it just fine.

  2. If it's more than 20 or so lines, GMail chokes - it won't open the attachment, download the attachment, or even forward the email.

  3. Also, if I send the same email to my colleague and he opens it with his Mac OS Mail client, everything works fine.

For example, the following is the content of the text file (this length will open in GMail just fine):

ACCELEROMETER READINGS
-0.0724487,-0.941833,-0.235458,2009-07-11 15:18:46 -0700
-0.0724487,-0.941833,-0.271683,2009-07-11 15:18:47 -0700
-0.0724487,-0.923721,-0.253571,2009-07-11 15:18:48 -0700
-0.0543365,-0.923721,-0.326019,2009-07-11 15:18:49 -0700
-0.0724487,-0.959946,-0.181122,2009-07-11 15:18:50 -0700
-0.0543365,-0.923721,-0.253571,2009-07-11 15:18:51 -0700
-0.108673,-0.923721,-0.380356,2009-07-11 15:18:52 -0700
-0.0724487,-0.923721,-0.271683,2009-07-11 15:18:53 -0700

GPS READINGS

HEADING READINGS
211.421,2009-07-11 15:18:46 -0700
206.421,2009-07-11 15:18:49 -0700
184.421,2009-07-11 15:18:50 -0700
195.421,2009-07-11 15:18:51 -0700
198.421,2009-07-11 15:18:53 -0700

If the file is twice this size, GMail can't deal ith it, but once again Mail can. So, what might be the problem? I created the email as follows:

SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
testMsg.fromEmail = @"founders@gmail.com";
testMsg.toEmail = @"andrewljohnson@trailbehind.com";
testMsg.relayHost = @"smtp3.webfaction.com";
testMsg.requiresAuth = YES;
testMsg.login = @"andrewljohnson";
testMsg.pass = @"********";
testMsg.subject = @"iPhone Instrument Readings";
testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!
testMsg.delegate = self;

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey, @"Hey Kevin,\nHere are some GPS readings for you to filter.\n\nLove, \nTrailBehind",kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];
NSData *fileData = [NSData dataWithContentsOfFile:fileName];    
NSDictionary *attached = [NSDictionary dictionaryWithObjectsAndKeys:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"readings.txt\"",kSKPSMTPPartContentTypeKey, @"attachment;\r\n\tfilename=\"readings.txt\"",kSKPSMTPPartContentDispositionKey,[fileData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];

testMsg.parts = [NSArray arrayWithObjects:plainPart,attached,nil];
[testMsg send];

解决方案

You're using [fileData encodeBase64ForData] but I see there's also a function called encodeBase64ForDataWrapped which adds line breaks. Perhaps you should be calling that instead, and if your attachment is sufficiently long the long base64 line is confusing somebody.

这篇关于GMail将不会打开由iPhone应用程序创建的.txt附件,根据大小 - 我认为在我的MIME中有一个Bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆