-(IBAction)emailAction{
NSString *weekNo = @"";
if (item.weekNo != -1)
weekNo = [NSString stringWithFormat:@" WEEK %d",item.weekNo];
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"MM/d/yyyy"];
NSString *newDateString = [inputFormatter stringFromDate:item.dateDump];
[inputFormatter release];
NSString *subject = [NSString stringWithFormat:@"%@%@ - %@", item.title, weekNo, newDateString];
NSData *imageData = UIImageJPEGRepresentation(item.image, 90);
NSArray *array1 = [[NSArray alloc]initWithObjects:nil];
controller = [[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate = self;
[controller setToRecipients:array1];
[controller setSubject:[NSString stringWithFormat:@"%@%@ - %@", item.title, weekNo, newDateString]];
[controller setMessageBody:[NSString stringWithFormat:@"%@", jEntry.text] isHTML:NO];
[controller addAttachmentData: imageData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",item.image]];
// [controller addAttachmentData: levelData mimeType:@"text/xml" fileName: @"contacts.plist"];
[self presentModalViewController:controller animated:YES];
[controller release];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", @"",[subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ,[jEntry.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
NSLog(@"Mail Sent...!");
UIAlertView *mailSend = [[UIAlertView alloc] initWithTitle:@"Email Sender"
message:@"Mail has been sent..."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[mailSend show];
[mailSend release];
}
[self dismissModalViewControllerAnimated:YES];
}
NSString *weekNo = @"";
if (item.weekNo != -1)
weekNo = [NSString stringWithFormat:@" WEEK %d",item.weekNo];
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"MM/d/yyyy"];
NSString *newDateString = [inputFormatter stringFromDate:item.dateDump];
[inputFormatter release];
NSString *subject = [NSString stringWithFormat:@"%@%@ - %@", item.title, weekNo, newDateString];
NSData *imageData = UIImageJPEGRepresentation(item.image, 90);
NSArray *array1 = [[NSArray alloc]initWithObjects:nil];
controller = [[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate = self;
[controller setToRecipients:array1];
[controller setSubject:[NSString stringWithFormat:@"%@%@ - %@", item.title, weekNo, newDateString]];
[controller setMessageBody:[NSString stringWithFormat:@"%@", jEntry.text] isHTML:NO];
[controller addAttachmentData: imageData mimeType:@"image/png" fileName:[NSString stringWithFormat:@"%@",item.image]];
// [controller addAttachmentData: levelData mimeType:@"text/xml" fileName: @"contacts.plist"];
[self presentModalViewController:controller animated:YES];
[controller release];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", @"",[subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ,[jEntry.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result
error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
NSLog(@"Mail Sent...!");
UIAlertView *mailSend = [[UIAlertView alloc] initWithTitle:@"Email Sender"
message:@"Mail has been sent..."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[mailSend show];
[mailSend release];
}
[self dismissModalViewControllerAnimated:YES];
}
No comments:
Post a Comment