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 3480588
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:22:05+00:00 2026-05-18T10:22:05+00:00

I’m having some hard time trying to send an email from my app. I

  • 0

I’m having some hard time trying to send an email from my app.
I tried this code from iCodeBlog (http://icodeblog.com/2009/11/18/iphone-coding-tutorial-in-application-emailing/)

-(void)sendEmail:(id)sender
{
    MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
    mail.mailComposeDelegate = self;
    if ([MFMailComposeViewController canSendMail]) {
            //Setting up the Subject, recipients, and message body.
        [mail setToRecipients:[NSArray arrayWithObjects:@"myEmail@email.com",nil]];
        [mail setSubject:@"Subject of Email"];
        [mail setMessageBody:@"Message of email" isHTML:NO];
            //Present the mail view controller
        [self presentModalViewController:mail animated:YES];
    }
        //release the mail
    [mail release];
}
    //This is one of the delegate methods that handles success or failure
    //and dismisses the mail
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    [self dismissModalViewControllerAnimated:YES];
    if (result == MFMailComposeResultFailed) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Failed!" message:@"Your email has failed to send" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}

It says it send the email and no error occurs but I never get the email in my inbox.
I tried sending them to different email accounts and tried sending them from different accounts as well, no error occurs but I never get the email.
Any ideas?

If it’s important, I get this message on the Debugger Console when I start typing the To: email

DA|Could not open the lock file at /tmp/DAAccountsLoading.lock. We’ll load the accounts anyway, but bad things may happen

===== EDIT ======

I just realized that all those emails were sent to my Outbox on Mail.app. Aren’t they sent automatically when I click send? If not, then what can I do to make them be sent when the user presses the Send button on MFMailComposeView? Or perhaps call the Mail.app and make those emails be sent.

  • 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-05-18T10:22:06+00:00Added an answer on May 18, 2026 at 10:22 am

    Use this code this will definitely work:

        -(IBAction)send{
    
            [self callMailComposer];
        }
    
        -(void)callMailComposer{
    
            Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
            if (mailClass != nil)
            {
            // We must always check whether the current device is configured for sending emails
                if ([mailClass canSendMail])
                    [self displayComposerSheet];
                else
                    [self launchMailAppOnDevice];
            }
    
            else
            {
                [self launchMailAppOnDevice];
            }
        }
    
    
        #pragma mark -
        #pragma mark Compose Mail
        #pragma mark 
    
        // Displays an email composition interface inside the application. Populates all the Mail fields. 
        -(void)displayComposerSheet{
    
            MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    
    
            picker.mailComposeDelegate = self;
            NSString *tosubject =@"";
            [picker setSubject:tosubject];
    
    
            // Set up recipients
            [picker setCcRecipients:nil];   
            [picker setBccRecipients:nil];
    
            [picker setToRecipients:nil];
    
    
    
            [picker setMessageBody:strNewsLink isHTML:NO];
    
            [self presentModalViewController:picker animated:YES];
    
            if(picker) [picker release];
            if(picker) picker=nil;
    
        }
    
    
        // Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
    
            - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
    {    
      NSString* alertMessage;
      // message.hidden = NO;
      // Notifies users about errors associated with the interface
      switch (result)
      {
        case MFMailComposeResultCancelled:
          alertMessage = @"Email composition cancelled";
          break;
        case MFMailComposeResultSaved:
          alertMessage = @"Your e-mail has been saved successfully";
    
          break;
        case MFMailComposeResultSent:
          alertMessage = @"Your email has been sent successfully";
    
          break;
        case MFMailComposeResultFailed:
          alertMessage = @"Failed to send email";
    
          break;
        default:
          alertMessage = @"Email Not Sent";
    
          break;
      }
    
      UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"My app name" 
                                                          message:alertMessage
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:nil];
      [alertView show];
      [self dismissModalViewControllerAnimated:YES];
    }
    
    
        #pragma mark 
        #pragma mark Workaround
        #pragma mark
        // Launches the Mail application on the device.
    
            -(void)launchMailAppOnDevice{
    
            NSString *recipients = @"mailto:?cc=&subject=";
            NSString *body = @"&body=";
            NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
            email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into

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.