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 = @"
[email protected]";
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.