Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:10:24+00:00 2026-06-17T12:10:24+00:00

I’m trying to senda a mail with a iOS app. This is the method:

  • 0

I’m trying to senda a mail with a iOS app.

This is the method:

    MFMailComposeViewController  *picker = [[MFMailComposeViewController  alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Reclutamento pompieri"];

    // Set up the recipients.
    NSArray *toRecipients = [NSArray arrayWithObjects:@"test@gmail.com",nil];

    [picker setToRecipients:toRecipients];


    testoMail = [NSMutableString stringWithFormat: @"This is a test"];

    [picker setMessageBody:testoMail isHTML:YES]; //HTML!!!!!!

        [self presentViewController:picker animated:YES completion:nil];

//*******************************************************************************************

     // The mail compose view controller delegate method
            - (void)mailComposeController:(MFMailComposeViewController *)controller //**ERROR STAYS HERE**
            didFinishWithResult:(MFMailComposeResult)result
            error:(NSError *)error
            {
                [self dismissModalViewControllerAnimated:YES]

;

But the debugger says “Used undeclared identifier “mailComposerController“

I dont’t understand what it means.
Can you help me?

Tank you very much

PS. The header is:

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>

@interface Reclutamento : UIViewController <MFMailComposeViewControllerDelegate>
{

}

- (void)sendMail;

@end

the full .h code is

//
//  Reclutamento.h
//  Pompieri
//
//  Created by Reda Bousbah on 15.01.13.
//  Copyright (c) 2013 Reda Bousbah. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface Reclutamento : UIViewController <MFMailComposeViewControllerDelegate>
{
    UITextField *nameTextField;
    UITextField *surnameTextField;
    UITextField *bornDateTextField;
    UITextField *addressTextField;
    UITextField *zipTextField;
    UITextField *emailTextField;

    MFMailComposeViewController *email;
}

@property (nonatomic, retain) MFMailComposeViewController *email;

@property(nonatomic,retain) IBOutlet UITextField *nameTextField;
@property(nonatomic,retain) IBOutlet UITextField *surnameTextField;
@property(nonatomic,retain) IBOutlet UITextField *bornDateTextField;
@property(nonatomic,retain) IBOutlet UITextField *addressTextField;
@property(nonatomic,retain) IBOutlet UITextField *zipTextField;
@property(nonatomic,retain) IBOutlet UITextField *emailTextField;

@property NSString *name;
@property NSString *surname;
@property NSString *bornDate;
@property NSString *address;
@property NSString *zipCode;
@property NSString *miaEmail;


- (IBAction)checkData:(id)sender;
- (IBAction)backgroundTap:(id)sender;
- (IBAction)doneButtonPressed:(id)sender;

- (void)sendMail;

@end

and the implementation file is

//
//  Reclutamento.m
//  Pompieri
//
//  Created by Reda Bousbah on 15.01.13.
//  Copyright (c) 2013 Reda Bousbah. All rights reserved.
//

#import "Reclutamento.h"
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@interface Reclutamento ()

@end


@implementation Reclutamento

@synthesize nameTextField, surnameTextField, bornDateTextField, addressTextField, zipTextField, emailTextField;
@synthesize name, surname, bornDate, address, zipCode, miaEmail;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    nameTextField.text = nil;
    surnameTextField.text = nil;
    bornDateTextField.text = nil;
    addressTextField.text = nil;
    zipTextField.text = nil;
    emailTextField.text = nil;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

#pragma - getting info from the UI

//NSString *test = nil;


- (IBAction)checkData:(id)sender
{
    /*
    name = nameTextField.text;
    surname = surnameTextField.text;
    bornDate = bornDateTextField.text;
    address = addressTextField.text;
    zipCode = zipTextField.text;
    email = emailTextField.text;
    */

    //NSLog(@" Nome: %@ \n Cognome: %@ \n Data di nascita: %@ \n Indirizzo: %@ \n Zip: %@ \n email: %@ \n", name, surname, bornDate, address, zipCode, email);

    unsigned int x,a = 0;
    NSMutableString *messaggioErrore; //stringa variabile
    messaggioErrore = [NSMutableString stringWithFormat: @""]; //le stringhe mutabili vanno inizializzate in questo modo!


    for (x=0; x<6; x++)
    {
        switch (x) {
            case 0:
                if (nameTextField.text == nil) {
                    [messaggioErrore appendString:@"Nome, "];
                    a=1;

                }
                break;

            case 1:
                if (surnameTextField.text == nil)
                {
                    [messaggioErrore appendString:@"Cognome, "];
                    a=1;
                }
                break;

            case 2:
                if (bornDateTextField.text == nil)
                {
                    [messaggioErrore appendString:@"Data di nascita, "];
                    a=1;
                }
                break;

            case 3:
                if (addressTextField.text == nil)
                {
                    [messaggioErrore appendString:@"Indirizzo, "];
                    a=1;
                }
                break;

            case 4:
                if (zipTextField.text == nil)
                {
                    [messaggioErrore appendString:@"Zip Code, "];
                    a=1;
                }
                break;

            case 5:
                if (emailTextField.text == nil)
                {
                    [messaggioErrore appendString:@"Email, "];
                    a=1;
                }
                break;

            default:
                break;
        }

    }

    NSLog (@"Messaggio errore: %@", messaggioErrore);

     if (a == 1) {

         NSMutableString  *popupErrore;
         popupErrore = [NSMutableString stringWithFormat: @"Per inviare compilare i seguenti campi:  "];

         [popupErrore appendString:messaggioErrore]; //aggiungo i miei errori
         [popupErrore appendString: @" grazie della comprensione."]; //

         NSLog(@"%@", popupErrore);

        UIAlertView *chiamataEffettuata = [[UIAlertView alloc]
                                           initWithTitle:@"ATTENZIONE" //titolo del mio foglio
                                           message:popupErrore
                                           delegate:self
                                           cancelButtonTitle:@"Ok, correggo" //bottone con cui si chiude il messaggio
                                           otherButtonTitles:nil, nil];
        [chiamataEffettuata show]; //istanza per mostrare effettivamente il messaggio
     }

    else
    {
        name = nameTextField.text;
        surname = surnameTextField.text;
        bornDate = bornDateTextField.text;
        address = addressTextField.text;
        zipCode = zipTextField.text;
        email = emailTextField.text;

        NSMutableString *datiUtente;
        datiUtente = [NSMutableString stringWithFormat: @"<br><br> <b>Nome:</b> %@ <br> <b>Cognome:</b> %@ <br> <b>Data di nascita:</b> %@ <br> <b>Indirizzo:</b> %@ <br> <b>Zip:</b> %@ <br> <b>Email:</b> %@ <br>", name, surname, bornDate, address, zipCode, miaEmail];

        NSLog(@"Dati utente: %@", datiUtente);

        NSMutableString *testoMail;
        testoMail = [NSMutableString stringWithFormat: @"Salve, questa mail è stata generata automaticamente dalla applicazione per iPhone ''<b>Pompieri Locarno</b>'' <br> i dati relativi all'utente sono: %@", datiUtente];

        NSLog(@"%@", testoMail);


        //MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        MFMailComposeViewController  *picker = [[MFMailComposeViewController  alloc] init];
        picker.mailComposeDelegate = self;

        [picker setSubject:@"Reclutamento pompieri"];

        // Set up the recipients.
        NSArray *toRecipients = [NSArray arrayWithObjects:@"youporn@gmail.com",nil];

        //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com", nil];
        //NSArray *bccRecipients = [NSArray arrayWithObjects:@"four@example.com",nil];

        [picker setToRecipients:toRecipients];
        //[picker setCcRecipients:ccRecipients];
        //[picker setBccRecipients:bccRecipients];

        // Attach an image to the email.
        //NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano" ofType:@"png"];
        //NSData *myData = [NSData dataWithContentsOfFile:path];
        //[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"ipodnano"];

        // Fill out the email body text.
        //NSMutableString *emailBody;
        testoMail = [NSMutableString stringWithFormat: @"%@", testoMail];

        [picker setMessageBody:testoMail isHTML:YES]; //HTML!!!!!!

        // Present the mail composition interface.
        [self presentViewController:picker animated:YES completion:nil];

        // The mail compose view controller delegate method
        - (void)mailComposeController:(MFMailComposeViewController *)controller
        didFinishWithResult:(MFMailComposeResult)result
        error:(NSError *)error
        {
            [self dismissModalViewControllerAnimated:YES];
        }
    }
}

#pragma mark - Mandare email
/*
- (void)sendMail:(NSMutableString*)testoMail{

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Reclutamento pompieri"];

    // Set up the recipients.
    NSArray *toRecipients = [NSArray arrayWithObjects:@"reda.bousbah@gmail.com",nil];
    //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com", nil];
    //NSArray *bccRecipients = [NSArray arrayWithObjects:@"four@example.com",nil];

    [picker setToRecipients:toRecipients];
    //[picker setCcRecipients:ccRecipients];
    //[picker setBccRecipients:bccRecipients];

    // Attach an image to the email.
    //NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano" ofType:@"png"];
    //NSData *myData = [NSData dataWithContentsOfFile:path];
    //[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"ipodnano"];

    // Fill out the email body text.
    NSString *emailBody = @"It is raining in sunny California!";
    [picker setMessageBody:emailBody isHTML:NO];

    // Present the mail composition interface.
    [self presentViewController:picker animated:YES completion:nil];


}
*/

#pragma mark - methods to control the keyboard

- (IBAction)backgroundTap:(id)sender //method for resign the keyboard when the background is tapped
{
    [nameTextField resignFirstResponder];
    [surnameTextField resignFirstResponder];
    [bornDateTextField resignFirstResponder];
    [addressTextField resignFirstResponder];
    [zipTextField resignFirstResponder];
    [emailTextField resignFirstResponder];

}

- (IBAction)doneButtonPressed:(id)sender
{
    NSLog( @"done button pressed");
    [sender resignFirstResponder];
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:10:26+00:00Added an answer on June 17, 2026 at 12:10 pm

    It seems that you have defined - (void)mailComposeController:(MFMailComposeViewController *)controller inside a method.
    Please define this outside the method.


    Edit

    As I said move definition out side the method.
    Here is you full correct .m file

    //
    //  Reclutamento.m
    //  Pompieri
    //
    //  Created by Reda Bousbah on 15.01.13.
    //  Copyright (c) 2013 Reda Bousbah. All rights reserved.
    //
    
    #import "Reclutamento.h"
    #import <MessageUI/MessageUI.h>
    #import <MessageUI/MFMailComposeViewController.h>
    
    @interface Reclutamento ()
    
    @end
    
    
    @implementation Reclutamento
    
    @synthesize nameTextField, surnameTextField, bornDateTextField, addressTextField, zipTextField, emailTextField;
    @synthesize name, surname, bornDate, address, zipCode, miaEmail;
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    
        nameTextField.text = nil;
        surnameTextField.text = nil;
        bornDateTextField.text = nil;
        addressTextField.text = nil;
        zipTextField.text = nil;
        emailTextField.text = nil;
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    - (NSUInteger)supportedInterfaceOrientations {
        return UIInterfaceOrientationMaskLandscape;
    }
    
    #pragma - getting info from the UI
    
    //NSString *test = nil;
    
    
    - (IBAction)checkData:(id)sender
    {
        /*
         name = nameTextField.text;
         surname = surnameTextField.text;
         bornDate = bornDateTextField.text;
         address = addressTextField.text;
         zipCode = zipTextField.text;
         email = emailTextField.text;
         */
    
        //NSLog(@" Nome: %@ \n Cognome: %@ \n Data di nascita: %@ \n Indirizzo: %@ \n Zip: %@ \n email: %@ \n", name, surname, bornDate, address, zipCode, email);
    
        unsigned int x,a = 0;
        NSMutableString *messaggioErrore; //stringa variabile
        messaggioErrore = [NSMutableString stringWithFormat: @""]; //le stringhe mutabili vanno inizializzate in questo modo!
    
    
        for (x=0; x<6; x++)
        {
            switch (x) {
                case 0:
                    if (nameTextField.text == nil) {
                        [messaggioErrore appendString:@"Nome, "];
                        a=1;
    
                    }
                    break;
    
                case 1:
                    if (surnameTextField.text == nil)
                    {
                        [messaggioErrore appendString:@"Cognome, "];
                        a=1;
                    }
                    break;
    
                case 2:
                    if (bornDateTextField.text == nil)
                    {
                        [messaggioErrore appendString:@"Data di nascita, "];
                        a=1;
                    }
                    break;
    
                case 3:
                    if (addressTextField.text == nil)
                    {
                        [messaggioErrore appendString:@"Indirizzo, "];
                        a=1;
                    }
                    break;
    
                case 4:
                    if (zipTextField.text == nil)
                    {
                        [messaggioErrore appendString:@"Zip Code, "];
                        a=1;
                    }
                    break;
    
                case 5:
                    if (emailTextField.text == nil)
                    {
                        [messaggioErrore appendString:@"Email, "];
                        a=1;
                    }
                    break;
    
                default:
                    break;
            }
    
        }
    
        NSLog (@"Messaggio errore: %@", messaggioErrore);
    
        if (a == 1) {
    
            NSMutableString  *popupErrore;
            popupErrore = [NSMutableString stringWithFormat: @"Per inviare compilare i seguenti campi:  "];
    
            [popupErrore appendString:messaggioErrore]; //aggiungo i miei errori
            [popupErrore appendString: @" grazie della comprensione."]; //
    
            NSLog(@"%@", popupErrore);
    
            UIAlertView *chiamataEffettuata = [[UIAlertView alloc]
                                               initWithTitle:@"ATTENZIONE" //titolo del mio foglio
                                               message:popupErrore
                                               delegate:self
                                               cancelButtonTitle:@"Ok, correggo" //bottone con cui si chiude il messaggio
                                               otherButtonTitles:nil, nil];
            [chiamataEffettuata show]; //istanza per mostrare effettivamente il messaggio
        }
    
        else
        {
            name = nameTextField.text;
            surname = surnameTextField.text;
            bornDate = bornDateTextField.text;
            address = addressTextField.text;
            zipCode = zipTextField.text;
            email = emailTextField.text;
    
            NSMutableString *datiUtente;
            datiUtente = [NSMutableString stringWithFormat: @"<br><br> <b>Nome:</b> %@ <br> <b>Cognome:</b> %@ <br> <b>Data di nascita:</b> %@ <br> <b>Indirizzo:</b> %@ <br> <b>Zip:</b> %@ <br> <b>Email:</b> %@ <br>", name, surname, bornDate, address, zipCode, miaEmail];
    
            NSLog(@"Dati utente: %@", datiUtente);
    
            NSMutableString *testoMail;
            testoMail = [NSMutableString stringWithFormat: @"Salve, questa mail è stata generata automaticamente dalla applicazione per iPhone ''<b>Pompieri Locarno</b>'' <br> i dati relativi all'utente sono: %@", datiUtente];
    
            NSLog(@"%@", testoMail);
    
    
            //MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
            MFMailComposeViewController  *picker = [[MFMailComposeViewController  alloc] init];
            picker.mailComposeDelegate = self;
    
            [picker setSubject:@"Reclutamento pompieri"];
    
            // Set up the recipients.
            NSArray *toRecipients = [NSArray arrayWithObjects:@"youporn@gmail.com",nil];
    
            //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com", nil];
            //NSArray *bccRecipients = [NSArray arrayWithObjects:@"four@example.com",nil];
    
            [picker setToRecipients:toRecipients];
            //[picker setCcRecipients:ccRecipients];
            //[picker setBccRecipients:bccRecipients];
    
            // Attach an image to the email.
            //NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano" ofType:@"png"];
            //NSData *myData = [NSData dataWithContentsOfFile:path];
            //[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"ipodnano"];
    
            // Fill out the email body text.
            //NSMutableString *emailBody;
            testoMail = [NSMutableString stringWithFormat: @"%@", testoMail];
    
            [picker setMessageBody:testoMail isHTML:YES]; //HTML!!!!!!
    
            // Present the mail composition interface.
            [self presentViewController:picker animated:YES completion:nil];
        }
    }
    
    
    // The mail compose view controller delegate method
    - (void)mailComposeController:(MFMailComposeViewController *)controller
              didFinishWithResult:(MFMailComposeResult)result
                            error:(NSError *)error
    {
        [self dismissModalViewControllerAnimated:YES];
    }
    
    #pragma mark - Mandare email
    /*
     - (void)sendMail:(NSMutableString*)testoMail{
    
     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
     picker.mailComposeDelegate = self;
    
     [picker setSubject:@"Reclutamento pompieri"];
    
     // Set up the recipients.
     NSArray *toRecipients = [NSArray arrayWithObjects:@"reda.bousbah@gmail.com",nil];
     //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com", nil];
     //NSArray *bccRecipients = [NSArray arrayWithObjects:@"four@example.com",nil];
    
     [picker setToRecipients:toRecipients];
     //[picker setCcRecipients:ccRecipients];
     //[picker setBccRecipients:bccRecipients];
    
     // Attach an image to the email.
     //NSString *path = [[NSBundle mainBundle] pathForResource:@"ipodnano" ofType:@"png"];
     //NSData *myData = [NSData dataWithContentsOfFile:path];
     //[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"ipodnano"];
    
     // Fill out the email body text.
     NSString *emailBody = @"It is raining in sunny California!";
     [picker setMessageBody:emailBody isHTML:NO];
    
     // Present the mail composition interface.
     [self presentViewController:picker animated:YES completion:nil];
    
    
     }
     */
    
    #pragma mark - methods to control the keyboard
    
    - (IBAction)backgroundTap:(id)sender //method for resign the keyboard when the background is tapped
    {
        [nameTextField resignFirstResponder];
        [surnameTextField resignFirstResponder];
        [bornDateTextField resignFirstResponder];
        [addressTextField resignFirstResponder];
        [zipTextField resignFirstResponder];
        [emailTextField resignFirstResponder];
    
    }
    
    - (IBAction)doneButtonPressed:(id)sender
    {
        NSLog( @"done button pressed");
        [sender resignFirstResponder];
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.