我的應用程序中有一個按鈕叫我們聯繫我們!有沒有辦法在充滿To和Subject的iPhone中打開Eamil客戶端?如何在iPhone中使用To和Subject填寫電子郵件?
0
A
回答
1
您將需要使用MFMailComposeViewController類。下面是相關的部分從蘋果公司的MailComposer example:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Hello from California!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"];
[picker setToRecipients:toRecipients];
[self presentModalViewController:picker animated:YES];
[picker release];
的MailComposer樣本還說明了如何打開外部郵件程序:
NSString *recipients = @"mailto:[email protected]&subject=Hello from California!";
NSString *body = @"&body=It is raining in sunny California!";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
0
結帳MFMailComposeViewController。你可以設置Subject,To Field,甚至用HTML來填充正文。
0
當然可以。
- (void)emailExport:(NSString *)filePath
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
// Set the subject of email
[picker setSubject:@"My desired subject"];
// Add email addresses
// Notice three sections: "to" "cc" and "bcc"
NSString *valueForEmail = @"[email protected]";
NSString *valueForCCEmail = @"myCcEmail";
if(valueForEmail == nil || [valueForEmail isEqualToString:@""])
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Please set an email address before sending a time entry!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
return;
}
else {
[picker setToRecipients:[NSArray arrayWithObjects:valueForEmail, nil]];
}
if(valueForCCEmail != nil || ![valueForCCEmail isEqualToString:@""])
{
[picker setCcRecipients:[NSArray arrayWithObjects:valueForCCEmail, nil]];
}
// Fill out the email body text
NSString *emailBody = @"My email body text.";
// This is not an HTML formatted email
[picker setMessageBody:emailBody isHTML:NO];
// Show email view
[self presentModalViewController:picker animated:YES];
// Release picker
[picker release];
}
相關問題
- 1. 如何發送填寫主題和電子郵件地址的電子郵件?
- 2. 我如何確保我的郵件($ to,$ subject,$ msg);發送郵件
- 3. 有誰知道To/Subject控件a'la iPhone的郵件和短信應用程序?
- 4. 如何使用intel xdk在iphone/android中發送電子郵件?
- 5. $ _POST - 填寫電子郵件地址
- 6. 如何在tabView中使用撰寫電子郵件活動?
- 7. 在Gmail中使用預先填寫的html正文編寫電子郵件
- 8. 如何使用預先填寫的「to」字段啓動電子郵件應用程序?
- 9. 如何使用BCC在電子郵件中發送電子郵件3
- 10. 的Excel 2013 VBA - 設置電子郵件reciepients列表(TO和CC)填充Oulook電子郵件
- 11. 在iPhone中發送電子郵件
- 12. 在iPhone中驗證電子郵件
- 13. 輸入電子郵件和密碼使用Google+在iPhone
- 14. 當有人點擊電子郵件中的鏈接時,如何自動填寫電子郵件表單字段?
- 15. 填充電子郵件「抄送」和使用JavaScript和HTML
- 16. Convert Subject to Observable
- 17. 如何驗證電子郵件和替代電子郵件?
- 18. 如何在電子郵件中包含CC和BCC使用Go
- 19. 電子郵件與iPhone
- 20. iPhone電子郵件問題
- 21. iPhone - 電子郵件的API
- 22. JavaMail - 主題和To字段在電子郵件中爲空
- 23. 如何填充使用電子郵件部分鉻司機
- 24. iPhone iOS如何使用CSS樣式發送HTML電子郵件?
- 25. iPhone:在郵件應用中使用的UITableView號碼電子郵件樣式
- 26. 如何在電子郵件
- 27. PhoneGap:嘗試預先填寫使用電子郵件編輯器發送的電子郵件
- 28. 在電子郵件中使用TD填充的HTML表格
- 29. 如何使用IMAP從電子郵件服務器中檢索電子郵件?
- 30. 在實際電子郵件中刪除了Gmail電子郵件表格填充
請務必首先測試[MFMailComposeViewController canSendMail]。 – picciano
感謝您的幫助。 – HardCode