2012-07-17 80 views
-1

我正在開發一款應用,但我缺少一小部分。我準備了一個視圖,以便您可以將數據插入到UITextField中,然後我可以通過電子郵件發送這些信息。我嘗試了很多方法。每封郵件發送數據

#import <UIKit/UIKit.h> 
@interface RMAcpu : UIViewController <UITextFieldDelegate> 
@property IBOutlet UITextField *prodotto; 
@property IBOutlet UITextField *seriale; 
@property IBOutlet UITextField *cfiva; 
@property IBOutlet UITextField *email; 
@property IBOutlet UITextField *problema; 
- (IBAction)inviodati:(id)sender; 
@end 

關於.m,我試過但不發送信息。你能幫我通過電子郵件發送信息嗎?

#import "RMAcpu.h" 

@interface RMAcpu() 

@end 

@implementation RMAcpu 
@synthesize prodotto; 
@synthesize seriale; 
@synthesize cfiva; 
@synthesize email; 
@synthesize problema; 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
    } 
    return self; 
} 

- (BOOL)textFieldShouldReturn:(UITextField *)textField { 
    [textField resignFirstResponder]; 
    return YES; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 


    // Do any additional setup after loading the view. 
} 

- (void)viewDidUnload 
{ 
    [self setProdotto:nil]; 
    [self setSeriale:nil]; 
    [self setCfiva:nil]; 
    [self setEmail:nil]; 
    [self setProblema:nil]; 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

- (IBAction)inviodati:(id)sender { 
    NSString *stringaMail = [NSString stringWithFormat:@"mailto:[email protected]", [[prodotto text] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding], [[seriale text] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding], [[cfiva text] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; 


    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:stringaMail]]; 



} 
@end 
+0

我刪除了在這裏沒有任何作用的Italiano,但是請你能夠確切地說明問題是什麼? – 2012-07-17 07:52:41

回答

1

除非您實施自己的SMTP客戶端,否則無法直接從您的應用程序發送電子郵件。採用這種方法的當前項目是skpsmtpmessage

如果您不想嘗試這種方式,您將需要使用MessageUI框架中的MFMailComposeViewController。這將允許您創建電子郵件模板並預先填寫收件人,主題和郵件正文等字段,但用戶必須手動點擊發送按鈕。

+0

我正在嘗試蘋果示例 – user1530993 2012-07-17 09:33:30

+0

我已使用MFMailComposeViewController解決了這個問題: [mail setMessageBody:@「PRODOTTO:\ n \ nSERIALE:\ n \ nCF/P.IVA:\ n \ nEMAIL:\ n \ nSPECIFICARE IL問題:\ n \ n \ n \ n1。Danni da caduta \ n2。事實上的腐敗\ n3。Viti forzate「isHTML:NO]; – user1530993 2012-07-25 08:33:21