/ Published in: Objective C
Expand |
Embed | Plain Text
-(void)sendMailByTitle:(BOOL)title andText:(NSString*)text byViewController:(UIViewController*)vCtr{ self.strText=text; self.strTitle=title; vRef=vCtr; [self emailThisNote]; } -(void)emailThisNote{ Class mailClass = (NSClassFromString(@"MFMailComposeViewController")); if (mailClass != nil) { // We must always check whether the current device is configured for sending emails if ([mailClass canSendMail]){ [self displayComposerSheet]; }else { [self launchMailAppOnDevice]; } }else { [self launchMailAppOnDevice]; } } #pragma mark - #pragma mark Compose Mail // Displays an email composition interface inside the application. Populates all the Mail fields. -(void)displayComposerSheet { MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; // load value from DocDetail.plist NSDictionary *d=[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DocDetail" ofType:@"plist"]]; [picker setSubject:[d valueForKey:@"DocTitle"]]; NSString *strToMail=[[NSString alloc] initWithFormat:@"<html><body><p><font family='Arial' size='3pt' color='darkblue'>%@</font></p><h3 style='color:brown'><u>%@</u></h3><p><font family='Arial' size='3pt' color='brown' style='background-color:yellow'>%@</font></p><p><font family='Arial' size='3pt' color='darkblue'>You can download this DocuApps™ document App for free by clicking this link:<a href='%@'>%@</a></font></p><p><font family='Arial' size='3pt' color='green' style='font-weight:bold'><img src='%@' height='88px' width='125px'><br>DocuApps™ is a product of The APP Company</font></p><img src='%@' width='175px' height='43px'><br><font family='Arial' style='font-weight:bold' color='blue'>For more information:</font><br><font family='Arial' size='3pt' color='brown'>Web :<a href='http://%@'>%@</a><br>Email: <a href='mailto:%@'>%@</a><br></font><font family='Century Gothic' size='1px' color='brown'>©2010 The APP Company. All Rights Reserved.</font><hr></body></html>",strDtlTitle,strDocTitle,self.strText,strDocLink,strDocLink,strImgzzzApp,zzzCompanympany,strWebLink,strWebLink,strEmailLink,strEmailLink]; [picker setMessageBody:strToMail isHTML:YES]; [strToMail release]; strToMail=nil; [vRef presentModalViewController:picker animated:YES]; [picker release]; } // Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation. - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [vRef dismissModalViewControllerAnimated:YES]; } #pragma mark - #pragma mark Workaround // Launches the Mail application on the device. -(void)launchMailAppOnDevice { UIAlertView *av=[[[UIAlertView alloc] initWithTitle:@"Message" message:@"Mail composer not available." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [av show]; }
You need to login to post a comment.
