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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:54:58+00:00 2026-06-12T16:54:58+00:00

I’m trying to send mail in iPhone using SKPSMTPMessage and I added the libraries,

  • 0

I’m trying to send mail in iPhone using “SKPSMTPMessage” and I added the libraries,

In my class I added the following code:

- (IBAction)sendMail:(id)sender 
{
// if there are a connection
if ([theConnection isEqualToString:@"true"]) {
    if ([fromEmail.text isEqualToString:@""] || [toEmail.text isEqualToString:@""]) {
        UIAlertView *warning = [[UIAlertView alloc] initWithTitle:@"تحذير" message:@"لم يتم ادخال جميع المجالات" delegate:self cancelButtonTitle:@"موافق" otherButtonTitles:nil, nil];
        [warning show];
    }else {

        SKPSMTPMessage *test_smtp_message = [[SKPSMTPMessage alloc] init];
        test_smtp_message.fromEmail = fromEmail.text;
        test_smtp_message.toEmail = toEmail.text;
        test_smtp_message.relayHost = @"smtp.gmail.com";
        test_smtp_message.requiresAuth = YES;
        test_smtp_message.login = @"ebookmsg@gmail.com";
        test_smtp_message.pass =  @"myPass";
        test_smtp_message.wantsSecure = YES;

        NSString *subject= @"Suggest a book for you";
        test_smtp_message.subject = [NSString stringWithFormat:@"%@ < %@ > ",fromEmail.text, subject];
        test_smtp_message.delegate = self;

        NSMutableArray *parts_to_send = [NSMutableArray array];


        NSDictionary *plain_text_part = [NSDictionary dictionaryWithObjectsAndKeys:
                                         @"text/plain\r\n\tcharset=UTF-8;\r\n\tformat=flowed", kSKPSMTPPartContentTypeKey,
                                         [messageBody.text stringByAppendingString:@"\n"], kSKPSMTPPartMessageKey,
                                         @"quoted-printable", kSKPSMTPPartContentTransferEncodingKey,
                                         nil];
        [parts_to_send addObject:plain_text_part];

        // to send attachment

        NSString *image_path = [[NSBundle mainBundle] pathForResource:BookCover ofType:@"jpg"];
        NSData *image_data = [NSData dataWithContentsOfFile:image_path];        
        NSDictionary *image_part = [NSDictionary dictionaryWithObjectsAndKeys:
                                    @"inline;\r\n\tfilename=\"image.png\"",kSKPSMTPPartContentDispositionKey,
                                    @"base64",kSKPSMTPPartContentTransferEncodingKey,
                                    @"image/png;\r\n\tname=Success.png;\r\n\tx-unix-mode=0666",kSKPSMTPPartContentTypeKey,
                                    [image_data encodeWrappedBase64ForData],kSKPSMTPPartMessageKey,
                                    nil];


        [parts_to_send addObject:image_part];



        test_smtp_message.parts = parts_to_send;

        Spinner.hidden = NO;
        [Spinner startAnimating];
        ProgressBar.hidden = NO;
        HighestState = 0;

        [test_smtp_message send];

    }

}else {
    UIAlertView *alertNoconnection = [[UIAlertView alloc] initWithTitle:@"تحذير" message:@"لا يوجد شبكة " delegate:self cancelButtonTitle:@"الغاء" otherButtonTitles:nil, nil];
    [alertNoconnection show];
}
}

but when I tried to send it gives me the following Exception:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString appendString:]: nil argument'

and it highlighted this line in SKPSMTPMessage.m

 [message appendString:[part objectForKey:kSKPSMTPPartMessageKey]];

and I Can’t understand what is nil exactly
Can Anyone help me in this issue?
Thanks in Advance.

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

    I found the solution, the problem was because the image_data was null and I replaced it by:

            NSString *image_path = [NSString stringWithFormat:@"%@/%@",[[NSBundle mainBundle] bundlePath],[NSString stringWithFormat:@"%@.jpg",BookCover]];
    
            NSString *imgLink = [NSString stringWithFormat:@"http://iktab.com/global/modules/bookstore/files/book_cover_photo/%@",BookCover];
    
            NSString *urlString = [imgLink stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    
            NSURL *url = [NSURL URLWithString:urlString];
    
            NSData* image_data = [NSData dataWithContentsOfURL:url];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.