Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 05-23-2011, 04:14 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 122
architectpianist is on a distinguished road
Default MFMailComposeViewController not presenting with attachment

Hi,
I'm trying to attach a CSV file to an email.
The code I have is below:
Code:
if ([mailClass canSendMail]) 
	{
		MFMailComposeViewController *email = [[MFMailComposeViewController alloc] init];
		email.mailComposeDelegate = self;
			
		[email setSubject:subject];
		[email setMessageBody:body isHTML:isHTML];
		if (attachment) 
		{
			if ([attachment isKindOfClass:[NSString class]])
			{
				NSString *csvFile = (NSString *)attachment;
				NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
				NSString *thePath = [NSString stringWithFormat:@"%@/valuetable.csv", [paths objectAtIndex:0]];
				[csvFile writeToFile:thePath atomically:NO encoding:NSStringEncodingConversionAllowLossy error:NULL];
				NSData *attachmentData = [NSData dataWithContentsOfFile:thePath];
				[email addAttachmentData:attachmentData mimeType:@"text/csv" fileName:@"Values"];
				[[NSFileManager defaultManager] removeItemAtPath:thePath error:NULL];					
			}
		}
		[email setModalPresentationStyle:UIModalPresentationPageSheet];	
		[email.navigationBar setBarStyle:UIBarStyleBlackOpaque];
		[self changeKeyboardToNormal:nil];
		[self presentModalViewController:email animated:YES];
		[email release];
	}
The adding attachment code is definitely being called, and the attachmentData object is initialized properly. When I attach an NSData object containing a UIImage, it works. But when using a CSV file, the modal view controller doesn't present itself. Any explanations?
Thanks for any suggestions!

EDIT: Sorry, careless mistake! I was presenting the modal view controller from another modal view controller.

Last edited by architectpianist; 05-23-2011 at 05:14 PM. Reason: solved!
architectpianist is offline   Reply With Quote
Reply

Bookmarks

Tags
mfmailcompose, modal, nsdata, viewcontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 394
20 members and 374 guests
Absentia, AyClass, baja_yu, checkright, Diligent, dre, fvisticot, givensur, jbro, jPuzzle, momolgtm, Newbie123, Paul10, Punkjumper, revg, sacha1996, skrew88, taylor202, tomtom100
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0