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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:39:09+00:00 2026-06-03T16:39:09+00:00

My NSMutableArray data are in NSData formate.I am trying to attached NSMutableArray data to

  • 0

My NSMutableArray data are in NSData formate.I am trying to attached NSMutableArray data to E-mail body.Here is my NSMutableArray code:

      NSUserDefaults *defaults1 = [NSUserDefaults standardUserDefaults];
      NSString *msg1 = [defaults1 objectForKey:@"key5"];
      NSData *colorData = [defaults1 objectForKey:@"key6"];
      UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
      NSData *colorData1 = [defaults1 objectForKey:@"key7"];
      UIColor *color1 = [NSKeyedUnarchiver unarchiveObjectWithData:colorData1];
      NSData *colorData2 = [defaults1 objectForKey:@"key8"];
      UIFont *color2 = [NSKeyedUnarchiver unarchiveObjectWithData:colorData2];
      CGFloat x =(arc4random()%100)+100;
      CGFloat y =(arc4random()%100)+250;  
      lbl = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 100, 70)];
      lbl.userInteractionEnabled=YES;
      lbl.text=msg1;
      lbl.backgroundColor=color;
      lbl.textColor=color1;
      lbl.font =color2;
      lbl.lineBreakMode = UILineBreakModeWordWrap;
      lbl.numberOfLines = 50;
      [self.view addSubview:lbl];
      [viewArray addObject:lbl ];

viewArray is my NSMutableArray .All the data store in viewArray are in NSData formate.I try this code to attached viewArray data in E-mail.

   - (IBAction)sendEmail {
          if ([MFMailComposeViewController canSendMail])
      {
     NSArray *recipients = [NSArray arrayWithObject:@"example@yahoo.com"];
    MFMailComposeViewController *controller = [[MFMailComposeViewController 
                                        alloc] init];
     controller.mailComposeDelegate = self;
     [controller setSubject:@"Iphone Game"];
     NSLog(@"viewArray: %@", viewArray);
     NSString *string = [viewArray componentsJoinedByString:@"\n"];
     NSString *emailBody = string; 
     NSLog(@"test=%@",emailBody);
     [controller setMessageBody:emailBody isHTML:YES];
     [controller setToRecipients:recipients];
     [self presentModalViewController:controller animated:YES];
    [controller release];
  }
 else 
 { 
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" 
        message:@"Your device is not set up for     email." delegate:self 
                                  cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];   
[alert release];
 } 
 }

Here i see objects store in viewArray.in console its look like this..[2012-05-07 18:48:00.065 Note List[279:207] test=UILabel: 0x8250850; frame = (140 341; 56 19); text = ‘Xxxxxxx’; clipsToBounds = YES; layer = > but in E-mail i see only this..>> please suggest any one how can i attached my viewArray data in E-mail.
]

  • 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-03T16:39:12+00:00Added an answer on June 3, 2026 at 4:39 pm

    in email attachement, you can only send NSData or string to email, now if you want to send it by string, then get all values you want to send email like, lable.text, lable.color, lable.alpha etc, with proper keys and place it in the body and parse there, else find some way to convert your object into NSData and attach it using mfmailcomposer attach data method

    read this to convert NSArray into NSData

    How to convert NSArray to NSData?

    and this to convert back the NSData to NSArray

    How can i convert a NSData to NSArray?

    and then write this data to file as,

    -(void)writeDataToFile:(NSString*)filename
    {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
    
        if(filename==nil)
        {
            DLog(@"FILE NAME IS NIL");
            return;
        }
        // the path to write file
        NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat: @"%@",filename]];
        /*NSData *writeData;
         writeData=[NSKeyedArchiver archivedDataWithRootObject:pArray]; */
        NSFileManager *fm=[NSFileManager defaultManager];
        if(!filePath)
        {
            //DLog(@"File %@ doesn't exist, so we create it", filePath);
            [fm createFileAtPath:filePath contents:self.mRespData attributes:nil];
        }
        else 
        {
            //DLog(@"file exists");
            [self.mRespData writeToFile:filePath atomically:YES];
        }
    
        NSMutableData *resData = [[NSMutableData alloc] init];
        self.mRespData=resData;
        [resData release];
    }
    

    and finally attach it to the email using

    - (void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to attached NSMutableArray data to E-mail body. Here is my NSMutableArray
I save my objects in NSMutablearray in NSData formate.No i am try to attached
I'm trying to access an NSMutableArray which is a data member of my AppDelegate
Here I got from JSON [{photo:null}] and I use this code NSMutableArray *jPhoto =
When I convert my NSMutableArray Into NSdata,I get NSMutableArray data in bytes. Now I
I'm having trouble with a method to read my plist: @synthesize data //NSMutableArray -(void)readPlist{
I'm facing a strange problem with NSUsrDefaults. Whenever I'm fetching the data from NSUserDefaults,
I'm trying to convert this Javascript code: self.userSerialEvent = function (join, value, tokens) {
ok so I am trying to parse XML data into a table, this is
I'm trying to read some data out of a plist and I'm getting this

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.