0
私は以下のコードを使用しています。正常に動作し、電子メールが正常に送信されます。しかし、私のデフォルトのログインメールはfrom
アドレスになります。どのように私はそれをカスタマイズするのですか?ObjectUIを使用してMessageUIで受信者を設定する方法は?
- (IBAction)sendbutton:(id)sender {
if ([MFMailComposeViewController canSendMail])
{
NSString *emailTitle = self.subjecttextfield.text;
NSString *messageBody = self.messagetext.text;
NSString *recipents = self.totextfield.text;
NSMutableArray * myarray =[[NSMutableArray alloc]initWithObjects:@"%@",recipents,nil];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:myarray];
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];
}}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}
[self dismissViewControllerAnimated:YES completion:NULL];}