mardi 24 juin 2014

ios sending email with no attachment


Vote count:

0




I have implemented the module for sending the email from my iPhone device to server. When it comes to the implementation, there is no email file attach instead. I sweared I have added the attACHMENT . THE below is my working



-(IBAction)sendMail:(id)sender{


NSArray *toRecipents = [NSArray arrayWithObjects:@"birth.lo@sdsdfsfsdf-hk.com",@"jason.li@asdasdad-hk.com",@"lo.sdad@gmail.com",nil];
mailComposer = [[MFMailComposeViewController alloc]init];
if ([MFMailComposeViewController canSendMail]) {
mailComposer.mailComposeDelegate = self;

[mailComposer setSubject:@"NOXAV testing"];
[mailComposer setToRecipients:toRecipents] ;

[mailComposer setMessageBody:@"Testing message for the test mail" isHTML:NO];

NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

//make a file name to write the data to using the documents directory:
NSString *fileName = [NSString stringWithFormat:@"%@/textfile.txt",
documentsDirectory];
NSData *fileData = [NSData dataWithContentsOfFile:fileName];

NSString *mimeType = @"text/html";
[mailComposer addAttachmentData:fileData mimeType:mimeType fileName:fileName];

[self presentModalViewController:mailComposer animated:YES ];

}

}


-(void)mailComposeController:(MFMailComposeViewController *)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
if (result) {
NSLog(@"Result : %d",result);
}
if (error) {
NSLog(@"Error : %@",error);
}
[self dismissModalViewControllerAnimated:YES];

}


asked 20 secs ago






Aucun commentaire:

Enregistrer un commentaire