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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:07:33+00:00 2026-06-11T19:07:33+00:00

I have create program to send mail with my some detail from sqlite database

  • 0

I have create program to send mail with my some detail from sqlite database

It is working fine if I am not using attachment but if i uncomment that like i m getting exception like this:

Thread 1: EXC_BAD_ACCESS(code=1, address=0x474e5091

here is My code:

MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];

    mailView.mailComposeDelegate = (id) self;

    NSArray *recipients = [NSArray arrayWithObject:@"chintan_zwt@yahoo.com"];

    [mailView setToRecipients:recipients];
    [mailView setSubject:@"Try Mail From User Application"];

    NSString *body = [[NSString alloc] initWithFormat:@"First Name : %@ <br>",lblFirstName.text];

    body = [body stringByAppendingFormat:@"Last Name : %@<br>",lblLastName.text];
    body = [body stringByAppendingFormat:@"Username  : %@<br>",lblUsername.text];
    body = [body stringByAppendingFormat:@"Password  : %@<br>",lblPassword.text];
    body = [body stringByAppendingFormat:@"Birthdate : %@<br>",lblBD.text];

    [mailView addAttachmentData:[UIImagePNGRepresentation(u.Img1) bytes]
                       mimeType:@"image/png"
                       fileName:@"a.png"];

    [mailView setMessageBody:body isHTML:YES];

    [self presentModalViewController:mailView animated:YES];

I m getting data correctly from database and i m able to display image on screen but problem is only when i attach image to mail

Here in

UIImagePNGRepresentation(u.Img1)

U is an object of User Class (user define class) and Img1 is object of UIImage

  • 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-11T19:07:34+00:00Added an answer on June 11, 2026 at 7:07 pm

    First of the addAttachmentData:mimeType:fileName: method need a NSData object, so there is not need o call the bytes method on the NSData.

    If you try this in you code you can check wether the UIImagePNGRepresentation() method returns a valid NSData object. Just place a breakpoint on the line and check what the values are in the debugger.

    NSData *imageDate = UIImagePNGRepresentation(u.Img1);
    [mailView addAttachmentData:imageDate mimeType:@"image/png" fileName:@"a.png"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project to create a program, which prevents the user from escaping
I am trying to create a simple chat program using Java. I have create
I have to write program that create process using pipe() . My first task
I am trying to send an email from a C++ program using imap library.
I have to create a tester program for a C project (codetester.c). The user
I have to create a cipher program that shifts the letters of a message
For a school assignment I have to create a C++ program that will create
I have a program that is used to create other program and compile it
I have been trying to create a simple program with Python which uses OpenCV
I have a small program that I'm trying to create to get ip addresses

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.