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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:06:54+00:00 2026-05-20T18:06:54+00:00

i am trying to implement the functionality of email in my application. i have

  • 0

i am trying to implement the functionality of email in my application. i have added MessageUI-framework, along with header and MFMailComposeViewControllerDelegate protocol but i am facing problem. here is my code:

- (void)viewDidLoad {
    [super viewDidLoad];
if(isViewPushed == NO) {
        self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] 
                                                  initWithBarButtonSystemItem:UIBarButtonSystemItemCompose 
                                                  target:self action:@selector(email)] autorelease];
        }
    }
-(void) email
{
    NSMutableString *emailBody = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];

[emailBody appendString:@"<p>type text here</p>"];
    UIImage *emailImage = [UIImage imageNamed:@"20-gear2.png"];
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
    [emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64.....,.......%@'></b></p>",imageData]];
    [emailBody appendString:@"</body></html>"];
    MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
    emailDialog.mailComposeDelegate = self;
    [emailDialog setSubject:@"My Inline Image Document"];
    [self presentModalViewController:emailDialog animated:YES];
    [emailDialog release];

    if(! [MFMailComposeViewController canSendMail])
    {
        UIAlertView *cantMailAlert  = [[UIAlertView alloc]
                                       initWithTitle:@"cant email"
                                       message:@"nt able to send email"
                                       delegate:NULL
                                       cancelButtonTitle:@"ok"
                                       otherButtonTitles:NULL];

        [cantMailAlert show];
        [cantMailAlert release];
        return;
    }
    MFMailComposeViewController *mailController = [[[MFMailComposeViewController alloc] init] autorelease];
    [mailController setMessageBody:@"can send my mail" isHTML:NO];
    mailController.mailComposeDelegate = self;
    [self presentModalViewController:mailController animated:YES];
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    if (error)
    {
        UIAlertView *cantMailAlert  = [[UIAlertView alloc]
                                       initWithTitle:@"mail error"
                                       message: [error localizedDescription]
                                       delegate:NULL
                                       cancelButtonTitle:@"ok"
                                       otherButtonTitles:NULL];

        [cantMailAlert show];
        [cantMailAlert release];
        return;
    }
    NSString *resultString;
    switch (result)
    {
        case MFMailComposeResultSent:
            resultString = @"sent mail";
            break;

        case MFMailComposeResultSaved:
            resultString = @"saved";
            break;
        case MFMailComposeResultCancelled:
            resultString = @"cancel";
            break;
        case MFMailComposeResultFailed:
            resultString = @"failed";
            break;
    }

    if (resultString = @"saved")
    {
        NSString *msg = [NSString stringWithFormat:@"%@ at %@\n", resultString, [NSDate date]];
        UIAlertView *MailAlert  = [[UIAlertView alloc]
                                   initWithTitle:@"status"
                                   message: msg
                                   delegate:NULL
                                   cancelButtonTitle:@"ok"
                                   otherButtonTitles:NULL];

        [MailAlert show];
        [MailAlert release];
        return;
    }

    [controller dismissModalViewControllerAnimated:YES];
    [controller release];
    //[self email];
}

but when i click on mail button then applictaion terminates and starts loading . it says can’t able to store privious value!!

  • 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-20T18:06:55+00:00Added an answer on May 20, 2026 at 6:06 pm

    Why are you presenting two instances of MFMailcomposeviewcontroller in viewDidLoad? Why are you creating two objects namely emailDialog and mailController and presenting them?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement PDF functionality to my application. So, I added some new
We are trying to implement a REST API for an application we have now.
I am trying to implement backtrace functionality for a large framework, which is used
I'm trying to implement zooming functionality using a UIScrollView in MonoTouch but I just
I'm trying to implement the export functionality for my database application. I'm using C#
I am trying to implement file upload functionality on my site. I have created
All I am currently trying implement something along the lines of dim l_stuff as
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I am trying to implement AJAX in my Google App Engine application, and so
I'm trying to implement functionality which when a link is clicked the corresponding anchor

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.