1
我從我的應用程序發送一些數據到服務器。如下圖所示如何從設備獲取發件人電子郵件?
-(void)createXML
{
xmlStr = @"<?xml version='1.0'?>\n<jand_req>\n<inquiryList>\n<productArr>\n";
NSString *nameStr=[NSString stringWithFormat:@"<name>%@</name>\n",name.text];
xmlStr=[xmlStr stringByAppendingString:nameStr];
NSString *compNameStr=[NSString stringWithFormat:@"<comp_name>%@</comp_name>\n",compName.text];
xmlStr=[xmlStr stringByAppendingString:compNameStr];
NSString *cityStr=[NSString stringWithFormat:@"<city>%@</city>\n",city.text];
xmlStr=[xmlStr stringByAppendingString:cityStr];
NSString *countryStr=[NSString stringWithFormat:@"<country>%@</country>\n",[nameToCode objectForKey:country.text]];
xmlStr=[xmlStr stringByAppendingString:countryStr];
NSString *commentsStr=[NSString stringWithFormat:@"<comment>%@</comment>\n",commentsBox.text];
xmlStr=[xmlStr stringByAppendingString:commentsStr];
xmlStr=[xmlStr stringByAppendingString:@"</userDetail>\n</inquiryList>\n</jand_req>"];
}
我的代碼,在這之後我的數據由不同領域的我上面的數據發送到服務器如下圖所示
- (void)submitForm
{
[self createXML];
NSLog(@"myaccesscode%@",[fn getValFromSettings:@"accessCode"]);
NSString *serviceUrlStr=[NSString stringWithFormat:@"%@/%@/API_sendmail.php?access_code=%@",domainName,apiFolderPath,[fn getValFromSettings:@"accessCode"]];
NSLog(@"%@",serviceUrlStr);
NSURL * serviceUrl = [NSURL URLWithString:[serviceUrlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest * serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:100];
[serviceRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
[serviceRequest setHTTPMethod:@"POST"];
[serviceRequest setHTTPBody:[xmlStr dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn=[[[NSURLConnection alloc] initWithRequest:serviceRequest delegate:self startImmediately:YES] autorelease];
}
所有上面的代碼我的代碼爲我工作正常,但現在我希望在此代碼中包含另一個功能其中包含發件人電子郵件地址,但此發件人電子郵件必須從設備中獲取,與在應用程序中使用MFMailComposeViewController時相同,然後自動獲取發件人來自Device.Email的發件人電子郵件地址。將受到感謝。
感謝您的快速響應,但我們在向服務器發送數據時如何將其添加到xmlStr中。 – NSCool
@NSCool你可以在任何你想使用它的地方使用emailAddr!請看我最新的答案來看看! –
oky它看起來不錯只有最後一件事情告訴我使用這個代碼,如果有任何答覆來自服務器然後它去哪裏?我希望回覆必須發送到發件人的電子郵件地址。 – NSCool