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

  • Home
  • SEARCH
  • 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 8269385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:12:32+00:00 2026-06-08T06:12:32+00:00

I am trying to send the device log file via email and using the

  • 0

I am trying to send the device log file via email and using the below code. I am able to send the email in iPod Touch and iPad in wi-fi network. But when I am trying to send the email in iPhone on 3G network there is crash. I debuted the code and came to know that this is crashing while doing presentModalViewController.

Please help me ,how to resolve this issue.

- (IBAction)sendEmail:(id)sender
{
  MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
  picker.mailComposeDelegate = self;
 
  // Set the subject of email
  [picker setSubject:@"Debug Log"];
 
  // Add email addresses
  [picker setToRecipients:[NSArray arrayWithObjects:@"emailaddress1@domainName.com", @"emailaddress2@domainName.com", nil]];
 
  // Fill out the email body text
  NSString *emailBody = @"Debug Log content…… ";
 
  // This is not an HTML formatted email
  [picker setMessageBody:emailBody isHTML:NO];
 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory   
stringByAppendingPathComponent:@"console.log"];
NSData *data = [NSData dataWithContentsOfFile:logPath];
  [picker addAttachmentData:data mimeType:@"text/xml" fileName:@"console.log"];
 
  // Show email view    
  [self presentModalViewController:picker animated:YES];//app crash
 
  // Release picker
  [picker release];
}
 
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
  // Called once the email is sent
  // Remove the email view controller   
  [self dismissModalViewControllerAnimated:YES];
}
  • 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-08T06:12:33+00:00Added an answer on June 8, 2026 at 6:12 am

    Before sending mail check that email is configured in the iOS device.

    You can check the capability for sending mail through code before sending mail as below.

    - (IBAction)sendEmail:(id)sender
    {
      MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
      picker.mailComposeDelegate = self;
     
      // Set the subject of email
      [picker setSubject:@"Debug Log"];
     
      // Add email addresses
      [picker setToRecipients:[NSArray arrayWithObjects:@"emailaddress1@domainName.com", @"emailaddress2@domainName.com", nil]];
     
      // Fill out the email body text
      NSString *emailBody = @"Debug Log content…… ";
     
      // This is not an HTML formatted email
      [picker setMessageBody:emailBody isHTML:NO];
     
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    
    NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *logPath = [documentsDirectory   
    stringByAppendingPathComponent:@"console.log"];
    NSData *data = [NSData dataWithContentsOfFile:logPath];
    
      [picker addAttachmentData:data mimeType:@"text/xml" fileName:@"console.log"];
     
      // Show email view    
     Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
      if (mailClass != nil) {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail]) {
          [self presentModalViewController:picker animated:YES];
        } else {
          //do something
        }
      } else {
       //do something
      } 
      // Release picker
      [picker release];
    }
    
    - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
    {
      // Called once the email is sent
      // Remove the email view controller   
      [self dismissModalViewControllerAnimated:YES];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send a PDF file for a Kindle device. If I send
am trying send an array to php file using $_POST ,still always getting an
I`m trying to send e-mail via c# and use the following code: public static
i couldn't send data from my device to my php file. i am trying
Hello I am trying to send a push message to my device using Java.
Here's the code: private void sendFile(InputStream file, OutputStream out) throws IOException { Log.d(TAG, trying
I'm trying to send push notifications to my device using javapns library in liferay
So I'm trying to send several iterations of a barcode file to a device.
I'm trying to send the device name over a network implemented with CFNetwork. My
I'm trying to send a network packet of data to a hardware device. I

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.