How can I append text to the bottom of my MFMailComposeViewController?
-
02-10-2020 - |
Question
I would like to add the text "Sent from " to the bottom of the message
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:[NSString stringWithFormat:@"A message from: %@",self.profileName]];
[controller setMessageBody:[NSString stringWithFormat:@"%@",self.cellBody] isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
}
else {
UIAlertView *alertView;
alertView = [[UIAlertView alloc] initWithTitle:@"E-Mail Not Enabled" message:@"E-Mail is not supported on this device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
Solution
You could set the message body as isHTML:YES
and use line breaks <br>
or try using \n
in the setMessageBody
string
Then just add your "sent from" message after that.
OTHER TIPS
Try out this code I have changed the code as per your requirement
if([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:[NSString stringWithFormat:@"A message from: %@",self.profileName]];
[controller setMessageBody:[NSString stringWithFormat:@"%@\nSent from : %@",self.cellBody,self.profileName] isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
}
else {
UIAlertView *alertView;
alertView = [[UIAlertView alloc] initWithTitle:@"E-Mail Not Enabled" message:@"E-Mail is not supported on this device" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
Happy Coding...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow