If ([mfmailcomposeviewcontrollercansendmail]) {
Mfmailcomposeviewcontroller * mailvc = [[mfmailcomposeviewcontrolleralloc]
Init];
Mailvc. mailcomposedelegate = self;
[Mailvcsetsubject: @ "Email Subject"];
[Mailvcsettorecipients: [nsarrayarraywithobjects: @ "example@gmail.com", nil];
[Mailvc
Setmessagebody: @ "email content" ishtml: No];
[Self. navigationcontrollerpresentmodalviewcontroller: mailvc
Animated: Yes];
[Mailvcrelease];
} Else {
Nsstring * STR = [nsstringstringwithformat: @ "mailto: % @? Subject = % @ & Body = % @",
@ "Example@gmail.com ",
@ "Email Subject", @ "email content"];
STR = [STR stringbyaddingpercentescapesusingencoding: nsutf8stringencoding];
[[Uiapplicationsharedapplication]
Openurl: [nsurlurlwithstring: Str];
}
When no email address is set for the device, the setting page is displayed, prompting the user to add an email address;