Reputation: 2284
I am working on a mail application. I have a table view in a view, I need to load a mail page when I click on a button in the same view. I have implemented this using MFMailComposeViewController.
The mail view loaded, but I need to send the content of the table view as body/ attach of the body of mail, instead of icon image.
-(void)displayComposerSheet
{
MFMailComposeViewController *mailpage = [[MFMailComposeViewController alloc] init];
mailpage.mailComposeDelegate = self;
[mailpage setSubject:@"summary of chronology"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@""];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"",nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@""];
[mailpage setToRecipients:toRecipients];
[mailpage setCcRecipients:ccRecipients];
[mailpage setBccRecipients:bccRecipients];
//Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"iCon" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailpage addAttachmentData:myData mimeType:@"image/png" fileName:@"iCon"];
// Fill out the email body text
NSString *emailBody = @"";
[mailpage setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailpage animated:YES];
//[self.navigationController pushViewController:mailpage animated:YES];
[mailpage release];
}
Upvotes: 1
Views: 1147
Reputation: 1
This code helps to reload the parent page by making any changes(if there)#refresh
header("location:crud_admin.php"); echo 'parent.window.location.reload(true);';
Upvotes: 0
Reputation: 4920
Add to your displayComposerMethod this piece of code:
NSString *emailBody = [self generateHTMLBody];
[mailpage setMessageBody:emailBody isHTML:YES];
and method like this:
//assume that you have objects in NSArray* dataArray
- (NSString *)generateHTMLBody {
NSString *res = @"<HTML><body><table>\n";
for (int i=0; i < dataArray.count; i++) {
NSString *tmp = (NSString *)[dataArray objectAtIndex:i];
res = res = [res stringByAppendingString:@"<tr><td>"];
res = res = [res stringByAppendingString:tmp];
res = res = [res stringByAppendingString:@"</td></tr>\n"]; //fix in this line
}
res = [res stringByAppendingString:@"</table></body></html>\n"];
return res;
}
// I didn't test this method.
This is of course only an example, and method generateHTMLBody can and should be more sophisticated.
Upvotes: 4