1

In my app, I need to attach a video using SKPSMTPMessage. At first, I learned from Dunja's code,

NSData *videoData = [NSData dataWithContentsOfFile: videoPath];

NSDictionary *videoPart = [NSDictionary dictionaryWithObjectsAndKeys:@"video/quicktime;\r\n\tx-unix-mode=0644;\r\n\tname=\"video.mov\"",kSKPSMTPPartContentTypeKey,
                                     @"attachment;\r\n\tfilename=\"video.mov\"",kSKPSMTPPartContentDispositionKey,[videoData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];

but it's just can't work out. I tried all the solutions as I can imagined. Finally, I changed the encode type of videoData: from

... [videoData encodeBase64ForData],kSKPSMTPPartMessageKey ...

to

... [videoData encodeWrappedBase64ForData],kSKPSMTPPartMessageKey ...

and it works!

I have no idea what's the difference between this two api, can anyone help me out? Thank Dunja again, I learned a lot from your code.

Community
  • 1
  • 1
Jared Chen
  • 183
  • 1
  • 5

1 Answers1

0

Take a look at this answer: GMail won't open .txt attachment created by iPhone App, Depending on Size - I think There's a Bug in my MIME

A function called encodeBase64ForDataWrapped adds line breaks. Perhaps you should be calling that instead, and if your attachment is sufficiently long the long base64 line is confusing somebody.

Here you can see the source code of both: http://code.google.com/p/skpsmtpmessage/source/browse/trunk/SMTPSender/Classes/NSData%2BBase64Additions.m

Community
  • 1
  • 1
Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92
  • You are quite right, encodeBase64ForDataWrapped solved my problems, and this function add line breaks to my videoDatas as you said.But I really want to know if these link breaks are the only difference, And should I always using encodeBase64ForDataWrapped in stead of encodeBase64ForData? – Jared Chen Sep 04 '13 at 14:22
  • If you take a look at the source code you'll see, that the encodeBase64ForDataWrapped tried to use encodeBase64ForData first - so I mean, you can use always this one instead of encodeBase64ForData. – Leo Chapiro Sep 04 '13 at 14:27