我正在尝试发送包含文本字段和图像数据的电子邮件,但它不起作用,请告知。这是我的代码:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==1)
{
Cocktails*c=[[Cocktails alloc]init];
_arrTextField=[NSArray arrayWithObjects:_txtName,_txtIngredients,_txtPreper,_txtServe,_txtFrom ,nil];
NSLog(@"send email");
if ([MFMailComposeViewController canSendMail])
{
NSMutableArray*recipients=[[NSMutableArray alloc]init];
[recipients addObject:@"maya1580@gmail.com"];
MFMailComposeViewController *controller= [[MFMailComposeViewController alloc]init];
controller.mailComposeDelegate= self;
[controller addAttachmentData:_imgDrink mimeType:@"image/png" fileName:@"Myimage"];
[controller setSubject:@"my cocktail"];
[controller setMessageBody: _arrTextField isHTML:NO];
[controller setToRecipients:recipients];
}
else
{
UIAlertView* alert=[[UIAlertView alloc]initWithTitle:@"Alert" message:@"Your devise is not set up for Email" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:Nil, nil];
[alert show];
// [alert release];
}