0
我有以下问题:未收到iPad应用程序发送的电子邮件?
我想附加一个文件邮件并通过邮件发送它在我的iPad应用程序。我认为一切顺利,日志输出表示邮件已发送,但我没有收到。
我尝试了一切,但仍然无法解决问题。
这里是我的代码,请看看,并告诉我,如果有什么奇怪或错误:
-(void)createCSVFile
{
NSMutableString *csv = [NSMutableString stringWithString:@"UniqueID,playerNumber,DateAndHour,Prize"];
NSUInteger counter = [playerNumber count];
NSLog (@"%d", counter);
// provided all arrays are of the same length
for (NSUInteger i=0; i < counter; i++)
{
[csv appendFormat:@"\n%@,%d,%@,%@",
[uniqueID objectAtIndex:i],
[[playerNumber objectAtIndex:i] intValue],
[dateAndHour objectAtIndex:i],
[prizeWon objectAtIndex:i]
];
// NSLog (@"%@, %d, %@, %@", [uniqueID objectAtIndex:i], [[playerNumber objectAtIndex:i]intValue], [dateAndHour objectAtIndex:i], [prizeWon objectAtIndex:i]);
// instead of integerValue may be used intValue or other, it depends how array was created
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [paths objectAtIndex:0];
filePath = [NSString stringWithFormat:@"%@/VictoryStats.csv", docDirectory];
NSString *outputFileName = [docDirectory stringByAppendingPathComponent:@"VictoryStats.csv"];
NSError *error;
BOOL res = [csv writeToFile:outputFileName atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (res)
{
NSLog (@"created");
}
if (!res) {
NSLog(@"Error %@ while writing to file %@", [error localizedDescription], outputFileName);
}
}
-(void)sendMail
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"CSV File"];
[mailer addAttachmentData:[NSData dataWithContentsOfFile:filePath]
mimeType:@"text/csv"
fileName:@"VictoryStats.csv"];
[self presentViewController:mailer animated:YES completion:NULL];
}
我觉得我的代码是好的,但看起来事实并非如此。
请看看。
在此先感谢。
是你在设备还是模拟器测试?而电子邮件窗口打开你看到csv文件被检测到。 –
请检查您的iPad设备中的代码,我认为它会起作用。 –
我做到了。我在iPad上运行应用程序,发送邮件,但没有收到它。是的,我看到附加的CSV文件。我不知道发生了什么。 – scourGINHO