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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:08:11+00:00 2026-05-28T15:08:11+00:00

All,In my requirement need to send a mail with attached text file, which is

  • 0

All,In my requirement need to send a mail with attached text file, which is in document directory,Here i can get the path of file which is in document directory,How do i attach the file from my ipad to send.

here is the code which i have tried

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

if ([MFMailComposeViewController canSendMail]){
    // Create and show composer
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
    NSLog(@"directry path %@",paths);
    NSString *fullPath = [[paths lastObject] stringByAppendingPathComponent:@"Logs/log-858743.txt"];

    NSLog(@"directry full path %@",fullPath);
    NSData *data = [NSData dataWithContentsOfFile: fullPath];
    NSLog(@"Data value %@",data);

    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fullPath];
    if (fileExists) {
        NSLog(@"file is there");
    }else{
        NSLog(@"file is not there");
    }

    [picker setSubject:@"Backup"];
    [picker addAttachmentData:data mimeType:@"text/rtf" fileName:@"log.txt"];
    [picker setMessageBody:@"testing." isHTML:NO];
    [self presentModalViewController:picker animated:YES];
    [picker release];    }
else{
    // Show some error message here
}
  • 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-28T15:08:13+00:00Added an answer on May 28, 2026 at 3:08 pm

    Here a sample, try this

    MFMailComposeViewController *mViewController = [[MFMailComposeViewController alloc] init];
    mViewController.mailComposeDelegate = self;
    
    //Imposto l'oggetto
    [mViewController setSubject:@"Invio Copia Commissione"];
    
    //Preparo l' A: Devo spezzare gli indirizzi E-mail
    NSArray *toRecipients = [NSArray arrayWithArray:[Globals.AEmail componentsSeparatedByString:@";"]];
    [mViewController setToRecipients:toRecipients];
    
    
    //Preparo il Cc: Devo spezzare gli indirizzi E-mail
    if ([Config.EmailAgg length] != 0) {
        NSArray *CcRecipients = [NSArray arrayWithArray:[Config.EmailAgg componentsSeparatedByString:@";"]];
        [mViewController setCcRecipients:CcRecipients];
    }
    
    //Setto il corpo dell'E-mail
    [mViewController setMessageBody:Globals.TestoEmail isHTML:NO];
    
    
    //A questo punto visto che ho fatto 30 salvo il testo anche come file allegato dell'E-mail
    [Globals.TestoEmail writeToFile:[NSString stringWithFormat:@"%@/CopiaCommissione.txt", Globals.DocumentsPath] atomically:TRUE encoding:NSUTF8StringEncoding error:nil];
    NSData *Allegato = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/CopiaCommissione.txt", Globals.DocumentsPath]];
    [mViewController addAttachmentData:Allegato mimeType:@"text/plain" fileName:@"CopiaCommissione.txt"];
    
    
    [self presentModalViewController:mViewController animated:YES];
    [mViewController release];
    

    try to change mimeType in your code like this

    [picker addAttachmentData:data mimeType:@"text/plain" fileName:@"log.txt"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a requirement where I need to clear off the select all checkbox
Hey all, I have something of an interesting requirement for my project. I need
I have requirement where I need to allow users to upload a Word document
I have unpredictable frequency of Incoming csv data file which I need to store
I have a requirement where I need to send some data from my server
Good day, i have a requirement where i need to send files(image/videos.. etc) through
I currently have a requirement where I need to validate that all the files
I have a specific requirement that all children of a particular JComponent have double
We have a requirement in project to store all the revisions(Change History) for the
We have a requirement to log IP address information of all users who use

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.