我已經通過messageUIFramework與MFMailComposeViewController一起工作。我有一個情況,我必須發送電子郵件給自己。我如何添加「from」地址MFMailComposeViewController委託?有什麼建議麼?使用iOS發送電子郵件給自己。
2
A
回答
7
如何在APP中發送電子郵件?
- (IBAction)sendMail:(id)sender {
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Message Pro"];
//Destination adress
NSArray *toRecipients = [NSArray arrayWithObjects:@"your adress", nil];
[mailer setToRecipients:toRecipients];
//Attachement Object
UIImage *myImage = [UIImage imageNamed:@"image.jpeg"];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"];
//Message Body
NSString *emailBody = @"message body";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
[mailer release];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert release];
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved: you saved the email message in the drafts folder.");
break;
case MFMailComposeResultSent:
NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
break;
default:
NSLog(@"Mail not sent.");
break;
}
// Remove the mail view
[self dismissModalViewControllerAnimated:YES];
}
不要忘記
- 添加一個按鈕與
IBAction
= Sendmail的 - 導入MessageUI.framework
- 附加委託在.h文件中
MFMailComposeViewControllerDelegate
0
MFMailComposeViewController
爲您指定了「發件人」地址(當用戶獲得撰寫郵件視圖時,他們可以覆蓋他們的任何配置郵件帳戶)。你,程序員,不必擔心獲取/設置「發件人」地址。
相關問題
- 1. onCreate在AppMaker中發送電子郵件給自己?
- 2. 不能發送電子郵件給我自己
- 3. 如何使用我們自己的API發送電子郵件?
- 4. 自動發送電子郵件使用
- 5. 如何使用php發送表單給自己的電子郵件?
- 6. 發送電子郵件給用戶
- 7. 該電子郵件發送給哪個電子郵件地址?
- 8. 發送電子郵件給匪徒電子郵件分機
- 9. 使用shell腳本發送電子郵件給電子郵件組
- 10. 從iOS發送電子郵件sdk
- 11. 如何發送電子郵件給trac?
- 12. 發送電子郵件給PayPal買家
- 13. 使用send_dbmail發送電子郵件表中的電子郵件
- 14. vb.NET SmtpClient無法使用電子郵件發送電子郵件
- 15. PHP發送電子郵件多次發送電子郵件
- 16. Rails的電子郵件發送作爲自己
- 17. 發送電子郵件與PHP /自己的seerver
- 18. ASP.NET不發送電子郵件到我自己的域名
- 19. 如何使用自定義電子郵件模板發送電子郵件
- 20. 如何使用php curl發送來自yahoo電子郵件的電子郵件
- 21. 用PHP郵件發送電子郵件()
- 22. 使用`郵件`本地發送消息給自己
- 23. 郵件通過電子郵件發送給用戶50,000-100,000
- 24. 使用php發送電子郵件
- 25. 不使用SMTP發送電子郵件
- 26. 發送電子郵件使用MFMailComposeViewController
- 27. 使用RoR發送電子郵件
- 28. 使用ASP.NET發送電子郵件
- 29. ORACLE使用SSL發送電子郵件
- 30. 使用.NET發送電子郵件