我試圖從文本字段和圖像發送數據的電子郵件,它不起作用,請指教。這裏是我的代碼:如何從應用程序內發送電子郵件
- (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:@"[email protected]"];
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];
}
這應該是你的解決方案! – MasterRazer
謝謝,但我不想看到電子郵件屏幕,我希望它自動發送 – user1763326
ohh好吧我的錯我會尋找它 – MasterRazer