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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:52:44+00:00 2026-06-03T06:52:44+00:00

I am trying to attached NSMutableArray data to E-mail body. Here is my NSMutableArray

  • 0

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 ];

Now if my viewArray Contain 3 UILabel along with all these properties which is mention above .Then how Can attached this viewArray With E-mail body.here is My E-mail Code.

   - (IBAction)sendEmail
  {

  if ([MFMailComposeViewController canSendMail])
  {
     NSArray *recipients = [NSArray arrayWithObject:@"example@yahoo.com"];
     MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] 
          init];
    controller.mailComposeDelegate = self;
    [controller setSubject:@"Iphone Game"];

    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:viewArray];
   [controller addAttachmentData:data mimeType:@"application/octet-stream";  
    fileName:nil]; 

     NSString *emailBody = @"Happy Valentine Day!";
    [controller setMessageBody:emailBody isHTML:NO
    [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];
}

}

I got NO Error .but not See any data in E-mail body..which is in viewArray.please Any One guide me how Can attached my viewArray data with Email.

  • 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-03T06:52:45+00:00Added an answer on June 3, 2026 at 6:52 am

    Check NSData is not nil before sending.

    ie;

    [controller setSubject:@"Iphone Game"];
    
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:viewArray];
    
    if(!data){
        NSLog(@"Data is nil");
    
        return;
    }
    [controller addAttachmentData:data mimeType:@"application/octet-stream";  
    fileName:nil]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My NSMutableArray data are in NSData formate.I am trying to attached NSMutableArray data to
I'm trying to send email with some images attached in django. Code used is
In the attached flex code, I am trying to call a javascript function in
In my code attached below, I'm trying to upload a file via ASP.NET. I
I'm trying to use attached properties to add some presentation logic to my data
I'm trying to bind a data value to an attached property. However, it just
I'm trying to record an objects movements with an attached attribute called data-settings so
I'm trying to convert a Hex NSString to NSData (I'm using the below attached
I am trying to convert (or copy?) a NSMutableArray into a NSString . I
I am trying to create a layout as show in the image attached here:

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.