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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:49:22+00:00 2026-05-13T05:49:22+00:00

I have send an attachment through iPhone application. But when I see the mail,

  • 0

I have send an attachment through iPhone application.

But when I see the mail, I can see the upin that shows that something is attached.

But when I open the mail I couldn’t found any attachment?

What is the problem behind this?

-(IBAction)btnPressedExport:(id)sender{

    NSArray *x=[[NSArray alloc] initWithArray:[DatabaseAccess getAllTransactionsForUserID:[BudgetTrackerAppDelegate getUserID] profileID:[BudgetTrackerAppDelegate getProfileID]]];
    int i=-1,j=[x count];
    NSDictionary *tmp;
    NSMutableString *stringToWrite=[[NSMutableString alloc] init];
    for(;i<j;i++){
        if(i==-1){
            [stringToWrite appendString:@"TransactionID,TransactionDate,ProfileName,ProfileType,GroupName,GroupType,CategoryName,TransactionAmt\n"];
        } else {
            tmp=[x objectAtIndex:i];
            [stringToWrite appendFormat:@"%@,%@,%@,%@,%@,%@,%@,%@\n",
             [tmp valueForKey:@"TraID"],[tmp valueForKey:@"TraDate"],[tmp valueForKey:@"ProfileName"],[tmp valueForKey:@"ProfileType"],[tmp valueForKey:@"GroupName"],[tmp valueForKey:@"GroupType"],[tmp valueForKey:@"CatName"],[tmp valueForKey:@"TraAmt"]];
        }
    }
    [stringToWrite writeToFile:[self pathOfCSVForExport] atomically:YES encoding:NSStringEncodingConversionAllowLossy error:nil];
//  [stringToWrite writeToFile:[self pathOfCSVForExport] atomically:YES];


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

    [picker setSubject:@"Hello from Sugar!"];


     //Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@"sugar.srk@pqr.com"]; 
//  NSArray *ccRecipients = [NSArray arrayWithObjects:@"xyz.dalal@pqr.com", @"kandarp.dave@phptalent.com", nil]; 
//  NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

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

    // Attach an image to the email
    NSString *path = [[NSBundle mainBundle] pathForResource:@"myExport" ofType:@"csv"];
    NSData *myData = [NSData dataWithContentsOfFile:path];

    NSString *fileNameToSend=@"BudgetTracker.csv";//[NSString stringWithFormat:@"%@.csv",[x valueForKey:@"ProfileName"]];

    [picker addAttachmentData:myData mimeType:@"text/plain" fileName:fileNameToSend];
    // text/html/
    // Fill out the email body text
    NSString *emailBody = [NSString stringWithFormat:@"%@",@"Hello! This is export test."];
    [picker setMessageBody:emailBody isHTML:NO];

    [self presentModalViewController:picker animated:YES];

}

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
//  NSLog(@"here2");
    switch (result)
    {
        case MFMailComposeResultCancelled: break;
        case MFMailComposeResultSaved: break;
        case MFMailComposeResultSent: break;
        case MFMailComposeResultFailed: break;
        default: break;
    }
//  self.navigationController.navigationBarHidden=NO;
//  [self becomeFirstResponder];
    [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-05-13T05:49:22+00:00Added an answer on May 13, 2026 at 5:49 am

    This looks wrong, unless it’s just for testing:

    // Attach an image to the email
    NSString *path = [[NSBundle mainBundle] pathForResource:@"myExport" ofType:@"csv"];
    NSData *myData = [NSData dataWithContentsOfFile:path];
    

    the path you’re using is to a file in your application bundle, which is read-only, so it can’t be the CSV file you just made.

    if you want to write a temporary file and email it, you need to write it to someplace like your Documents directory, i.e. a path like

    NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
    NSString *docDirectory = [sysPaths objectAtIndex:0];
    NSString *filePath = [NSString stringWithFormat:@"%@/myexport.csv", docDirectory];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have created a form that can send and email with a specified attachment,
i have function to send mail with attachment to microsoft exchange server. My problem
I have send an email using php mailer class. mail was sending successfully but
Can i send a pdf file through javascript ? i have a link ,when
I am developing an application in which I have to send an image through
I have to send HTML file via email but not as attachment. Message simpleMessage
i have a java code in that i must send a attachment , it
I'm trying to send a PDF attachment through JavaMail, but when I receive the
I have been reading through the forums that it is not possible to send
I am using Lotus Notes Java API for my application. I have send one

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.