i trying create small email apps. works correctly email not sending. whether have this. learning myself. lack something. here code..
-(void)viewdidload { uibutton *but01 = [uibutton buttonwithtype:uibuttontyperoundedrect]; //button but01.frame = cgrectmake(240,10, 70, 50); [but01 settitle:@"add" forstate:uicontrolstatenormal]; [but01 addtarget:self action:@selector(sendmail) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:but01]; } - (ibaction)sendmail { if ([mfmailcomposeviewcontroller cansendmail]) { mfmailcomposeviewcontroller *mfviewcontroller = [[mfmailcomposeviewcontroller alloc] init]; mfviewcontroller.mailcomposedelegate = self; [self presentmodalviewcontroller:mfviewcontroller animated:yes]; [mfviewcontroller release]; }else { uialertview *alert = [[uialertview alloc] initwithtitle:@"status:" message:@"your phone not configured send mail." delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; [alert release]; } } #pragma mark - #pragma mark mfmailcomposeviewcontrollerdelegate methods - (void)mailcomposecontroller:(mfmailcomposeviewcontroller*)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror*)error { uialertview *alert = [[uialertview alloc] initwithtitle:@"status:" message:@"" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; switch (result) { case mfmailcomposeresultcancelled: alert.message = @"message canceled"; break; case mfmailcomposeresultsaved: alert.message = @"message saved"; break; case mfmailcomposeresultsent: alert.message = @"message sent"; break; case mfmailcomposeresultfailed: alert.message = @"message failed"; break; default: alert.message = @"message not sent"; break; } [self dismissmodalviewcontrolleranimated:yes]; [alert show]; [alert release]; }
for getting message in console. can now?
29/04/11 4:03:04 pm springboard[3115] reloading application state 'com.yourcompany.sendmail' modification date has changed 29/04/11 4:03:04 pm com.apple.launchd.peruser.501[95] (uikitapplication:com.yourcompany.sendmail[0x38e1][3206]) exited: killed 29/04/11 4:03:04 pm springboard[3115] reloading , rendering application icons. 29/04/11 4:03:04 pm springboard[3115] application 'sendmail' exited abnormally signal 9: killed
mfmailcompose doesn't work in simulator, check on device
Comments
Post a Comment