MFMailComposeViewController attachment file size limit - iphone

I'm using MFMailComposeViewController to send a file. Everything works fine with files under 15mb. Anything over, and the file simply doesn't get attached to the MFMailComposeViewController view. It's not that the email server isn't accepting, its that it never gets attached in the first place.
Does anyone have any ideas if there's a way to resolve that?
I know many email services can't handle attachments over 5 or 10mb, but other services allow you much larger file size.
MFMailComposeViewController *mail = [[[MFMailComposeViewController alloc] init] autorelease];
mail.mailComposeDelegate = self;
NSString* path = [NSString stringWithFormat:#"%#/%#/%#", NSHomeDirectory(), #"Documents", fileName];
NSData *data = [NSData dataWithContentsOfMappedFile:path]; //also tried dataWithContentsOfFile with same results
[mail addAttachmentData:data mimeType:#"audio/x-caf" fileName:[NSString stringWithFormat:#"%#.caf", label]];
[appDelegate.tabBarController presentModalViewController:mail animated:YES];

Loading a 15 MB anything into RAM on a pre-2009 iPhone or iPod is going to really push the limits of your process's available memory, so it's not surprising there's a cap. I wouldn't try to convince the compose view to accept a larger attachment; instead, I'd suggest you transfer the file to some external server and either e-mail a link to it or send the mail from there.

Currently it has a 21mb limit (relevant to iOS 15). But I could sent at least 24mb when pressed Try. 25mb couldn't be attached and MFMailComposeViewController was closed by system at all.

Related

Loading PDF into UIWebView - Anything faster?

I'm doing an application, which loads PDFs from an URL, but is there anything better then using UIWebView? Or any way of loading it page-by-page instead of loading the whole file at once?
I mean it does the job, but it takes 30seconds - 3 minutes to load a PDF on an iPhone 5 while standing NEXT to the router...
I can't imagine what would happen when I ran this code on an iPhone 4 with crappy internet...
Code which does the loading:
CatalogsWebViewController *webViewController = [[CatalogsWebViewController alloc] initWithNibName:#"CatalogsWebView" bundle:nil];
NSString *urlString = [[NSString alloc] initWithFormat:#"http://%#.s3.amazonaws.com/%#",kAmazonAWSBucketName,[catalogs objectAtIndex:indexPath.row]];
NSLog(#"%#",urlString);
webViewController.pdfRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
[self.navigationController pushViewController:webViewController animated:YES];
//Here self is webViewController, which got pushed into the navigation controller.
[self.webView loadRequest:self.pdfRequest];
Hum... it turns out, it's not due to the webView, it's cause it takes an immense time to download the file from the S3 bucket. When loading it from [NSBundle mainBundle], it does it it seconds.
As the problem comes from network connectivity, you should display a loading bar while downloading the PDF so the user understands what is going on. Then, upon download completion, save the PDF in the documents folder of your app if the user wants to reopen it later

Attachments using email uri scheme in iOS

I am implementing an iphone application (iOS 4.2) from where I would like to trigger the email client to send messages with attachments. I could effectively use uri schemes in combination with the class NSURL in order to trigger the email app but I was wondering whether it is possible to attach images. I have tried with mailto:whoever#wherever.org?subject=sthg&body=sthgelse&attachment=/path/to/file but the attachments are not included. I know iphone applications are sandboxed therefore it is possible that the email utility were not able to access the path to my image since it is located in my application bundle. On the other hand I was considering to administer my images with the photo manager. (1) Is there a way to include attachments in this way? (2) If so, is it possible to reference images either from my app or from the photo client? I could not find any attachments argument in the mailto RFC but maybe Apple has provided some way to achieve this.
Thanks in advance for your help,
Luis
MFMailComposeViewController will be able to do that, some example of usage belows:
remember to add MessageUI.framework
MFMailComposeViewController *email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;
[email setSubject:#"Whatever"];
// Set up recipients
NSArray recipients = [NSArray arrayWithObject:#"whoever#wherever.org"];
[email setToRecipients:recipients];
// Attach an image to the email
UIImage *attachment = ...;
NSData *data = UIImagePNGRepresentation(attachment);
[email addAttachmentData:myData mimeType:#"image/png" fileName:#"ok.png"];
// Fill out the email body text
NSString *emailBody = #"test mail";
[email setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[email release];
Instead of using the mailto: URL scheme, you should use the MFMailComposeViewController which allows you to add attachments. It also has the added benefit that using will not leave your app.
If one does not have account MFMailComposeViewController simply crashes.
Yes, you can call canSendMail first with the result NO(!), what next?
The answer is - use 'mailto:'. It'll popup dialog to create account.

In-App SMS with pre-written body limited to 40 characters

I am using the MFMessageComposeViewController to send a message within the application.
Problem:
When I send the text message to a non-iPhone (e.g. Nexus One), the message is always split into two or more text messages.
But if I sent the same message directly from the native Messages app, the message is delivered in a single message.
And then I found this recently, Actually what is happening is the message body is splitting by 40 characters and I can not figure out the situation.
What could be wrong? Is there a work around for this?
CODE:
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = #"This is a sample body which is containing more than 40 characters...";
controller.recipients = phnNumbersArray;
controller.messageComposeDelegate = self;
[self.view presentModalViewController:controller animated:YES];
}
[controller release];
Never tried, but possible three workaround for this.
1) Try using [NSString stringWithFormat:#"%#", myMsgBody]; I don't think it would work / resolves the issue, most probably. :P
2) See if you can send NSUTF8StringEncoding way.
3) Or the problem is at the carrier's side, nothing to do with your code.
Explanation: In your scenario I see the texts are breaking up into multiple texts. Servers at the carriers' site thinks your message is too long. That means too heavy to be sent at once. This basically means it's xxmb more than what the servers takes. To reduce that size i gave you the idea of encoding way...

Email body not displayed after sending from iPhone via code

I have couple of iPhone apps that sends an email via code.
I've noticed quite a number of emails coming in from customers where everything is populated except for the body message (i always see their signature though).
I sent a test message, using the same app from my iPhone device, and i get the message (a simple "this is a test" message).
Wondering if there are any coding that needs to occur to handle different version of iOS, or perhaps different iPhone device hardwares?
Anybody noticed this before?
I would consider the possibility that the users are accidentally pressing send on a blank email. Perhaps to eliminate this as a possibility, guard against blank messages in code, then if it still happens you'll know it's a real issue.
set all delegates properly
and use this
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
NSString *sub= [NSString stringWithFormat:#"The Black Sheep App: %# Specials",[[BarSplArr objectAtIndex:0]objectForKey:#"barname"]];
NSString *message=[NSString stringWithFormat:#"Check out these specials for %# on %#, %# \n\n %#",[[BarSplArr objectAtIndex:0]objectForKey:#"barname"],day,date,[[BarSplArr objectAtIndex:0]objectForKey:#"drinkspecials"] ];
[controller setSubject:sub];
[controller setMessageBody:message isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];

MFMailComposeViewController adds null Content-Id

This is my first post to the group so please be kind :)
I am sending a couple of audio attachments from my app as follows:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
[picker setSubject:#"Test message"];
NSArray *toRecipients = [NSArray arrayWithObject:#"foo#bar.com"];
[picker setToRecipients:toRecipients];
// multiple attachments are made as follows
NSData *myData = [NSData dataWithContentsOfFile:filePath];
[picker addAttachmentData:myData mimeType:#"audio/x-caf" fileName:fileName];
[picker setMessageBody:#"test message" isHTML:NO];
[controller presentModalViewController:picker animated:YES];
A mailComposeController method takes care of dismissing the modal view.
Unfortunately, when the message is delivered the mime headers for the attachments land up having the Content-Id set to null. Here is what it looks like:
Content-Type: audio/x-caf; name="audio_1.caf"
Content-Transfer-Encoding: base64
Content-Id: <(null)>
Content-Disposition: attachment; filename="audio_1.caf"
If I manually delete the Content-Id field and reload the message in my Mac Mail program (Mail Version 3.6) the attachments show up correctly. In other words, I don't really need/want theContent-Id to be inserted in the mime header.
Also, its worth mentioning that for debugging purposes if I set the mime type to "image/jpeg" the mime header does get a valid Content-Id string. All my attachments show up in Mail. As is to be expected, in that case the attachments don't open correctly on the Mac or iPhone.
Any help would be greatly appreciated.
thanks,
apurva
According to this post, you cannot manually set the Content-ID
How to add a UIImage in MailComposer Sheet of MFMailComposeViewController
OK. Figured it out -- more by accident than anything else.
The null content ids seem to be inserted by the mail server (not my app or MFMailComposeViewController).
Initially I was testing the send with a personal yahoo account. Thats when I ran into the problem. When I switched to my work account the problem disappeared.
thanks,
apurva