Sending Email in background in iphone sdk with body
<p>I am developing on app in that i want to send email at the back ground.
for that i used the "SKPSMTP" library but when i got the mail it is without body so can any one tell me where i m wrong in my code.
following is the code on button click..</p>

<pre><code>- (void)sendMessageInBack:(id)anObject
{
    if(![self validateEmail:txt_email.text])
    {
        if([txt_email.text isEqualToString:@""] )
        {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Mandatory field" message:@"Please fill complete email" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
        else
        {
            if(self.interfaceOrientation==UIInterfaceOrientationLandscapeLeft || self.interfaceOrientation==UIInterfaceOrientationLandscapeRight ) 
            {
                if(rotate)
                [btn_Send setImage:[UIImage imageNamed:@"send_button.png"] forState:UIControlStateNormal];
            }
            else if(self.interfaceOrientation==UIInterfaceOrientationPortrait || self.interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown )
            {
                if(rotate)
                [btn_Send setImage:[UIImage imageNamed:@"send button1.png"] forState:UIControlStateNormal];

            }   

                NSLog(@"Start Sending");
                NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                NSString *documentsDirectory = [paths objectAtIndex:0];
                NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"RequestReview.txt"];

                NSData *dataObj = [NSData dataWithContentsOfFile:writableDBPath];
                //NSString *mailid;
                SKPSMTPMessage *testMsg = [[SKPSMTPMessage alloc] init];
                testMsg.fromEmail =@"spymekdemo@gmail.com";
                testMsg.toEmail = @"priyanka.chinchmalatpure@gmail.com";// txtEmail.text;
                testMsg.relayHost = @"smtp.gmail.com";
                testMsg.requiresAuth = YES;
                testMsg.login = @"spymekdemo@gmail.com";
                testMsg.pass =@"spymek123";
                testMsg.subject =@"Sbject"; //[NSString stringWithFormat:@"Reply to Review From %@", txtName.text];
                testMsg.wantsSecure = YES; // smtp.gmail.com doesn't work without TLS!

                // Only do this for self-signed certs!
                testMsg.validateSSLChain = NO;
                testMsg.delegate = self;

                NSString *deviceIdentifier=[NSString stringWithFormat:@"%@",[[UIDevice currentDevice]uniqueIdentifier]];//[NSString stringWithFormat:@"%@",deviceToken.uniqueIdentifier];
                NSLog(@"%@",deviceIdentifier);

                //NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/plain",kSKPSMTPPartContentTypeKey,
                //                             [NSString stringWithFormat:@"Request Review\n\nDevice Identifier=%@\nProduct Name=%@\nProduct Download URL=%@\nUser Name=%@\nEmail=%@\nPromo Code=%@\nDescription Of Product=%@\n\n\n", deviceIdentifier, txtProduct.text,txtDownloadURL.text, txtName.text,txtEmail.text,txtPromocode.text, txtDescription.text]
                //                             ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

                NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:@"text/html",kSKPSMTPPartContentTypeKey,
                                           [NSString stringWithFormat:@"&lt;h2&gt;Request Review&lt;/h2&gt;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;Thank you for giving us your review&lt;/b&gt; &lt;br/&gt;Device Identifier=%@&lt;br/&gt;Product Name=&lt;br/&gt;Product Download URL=&lt;br/&gt;User Name=&lt;br/&gt;Email=&lt;br/&gt;Promo Code=&lt;br/&gt;Description Of Product=&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;", deviceIdentifier]
                                           ,kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];


                //   [NSString stringWithFormat:@"&lt;h3&gt;Review App&lt;/h3&gt; &lt;br/&gt; &lt;br/&gt;&lt;b&gt;Name=%@&lt;b&gt;&lt;br/&gt; &lt;br/&gt;,\n&lt;u&gt;Email=%@&lt;/u&gt;&lt;br/&gt; &lt;br/&gt;,\nPassword=%@,&lt;br/&gt;&lt;br/&gt; &lt;b&gt;\nComments=%@\n\n&lt;/b&gt;&lt;br/&gt;",txtName.text,txtMailId.text, txtPassword.text, txtComment.text],kSKPSMTPPartMessageKey,@"8bit",kSKPSMTPPartContentTransferEncodingKey,nil];

                // @"&lt;html&gt;&lt;body&gt;&lt;h1&gt;Review App&lt;/h1&gt; &lt;br/&gt; &lt;b&gt;Some text to include in body&lt;/b&gt;&lt;/body&gt;&lt;/html&gt;"
                NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"text/directory;\r\n\tx-unix-mode=0644;\r\n\tname=\"%@.txt\"",txt_name.text],kSKPSMTPPartContentTypeKey,
                                         [NSString stringWithFormat:@"attachment;\r\n\tfilename=\"%@.txt\"",txt_name.text],kSKPSMTPPartContentDispositionKey,[dataObj encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];


                testMsg.parts = [NSArray arrayWithObjects:plainPart,vcfPart, nil]; //vcfPart

                [testMsg send];
        }       
    }

    rotate=YES; 
}

- (void)messageFailed:(SKPSMTPMessage *)message error:(NSError *)error
{
        [message release];
                //open an alert with just an OK button
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to send email"
                                                               delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];   
        [alert release];
        NSLog(@"delegate - error(%d): %@", [error code], [error localizedDescription]);
                //[self ClearFile];
                //UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Request Review" message:@"Review Posting failed.. Try Again Later.." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Done",nil];
}


- (void)messageSent:(SKPSMTPMessage *)message
    {
    [message release];

    NSLog(@"delegate - message sent");
}
</code></pre>
