我正在寻求帮助,我是iphone编程新手
有没有办法发送电子邮件,使用设备上配置的标准帐户而无需打开撰写用户界面,而不使用Pagesheet?
我想写一个应用程序给我发送电子邮件提醒。
期待听到您的重播
...谢谢
答案 0 :(得分:1)
您必须将信息发送到您管理的服务器,并通过smtp类型方法发送电子邮件。
答案 1 :(得分:1)
您可以使用任何作曲家窗口以背景方式发送电子邮件
请参阅this SMTPSender示例
示例:
- (BOOL)send
{
NSAssert(sendState == kSKPSMTPIdle, @"Message has already been sent!");
if (requiresAuth)
{
NSAssert(login, @"auth requires login");
NSAssert(pass, @"auth requires pass");
}
NSAssert(relayHost, @"send requires relayHost");
NSAssert(subject, @"send requires subject");
NSAssert(fromEmail, @"send requires fromEmail");
NSAssert(toEmail, @"send requires toEmail");
NSAssert(parts, @"send requires parts");
if (![relayPorts count])
{
[delegate messageFailed:self
error:[NSError errorWithDomain:@"SKPSMTPMessageError"
code:kSKPSMTPErrorConnectionFailed
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to connect to the server.", @"server connection fail error description"),NSLocalizedDescriptionKey,
NSLocalizedString(@"Try sending your message again later.", @"server generic error recovery"),NSLocalizedRecoverySuggestionErrorKey,nil]]];
return NO;
}
// Grab the next relay port
short relayPort = [[relayPorts objectAtIndex:0] shortValue];
// Pop this off the head of the queue.
self.relayPorts = ([relayPorts count] > 1) ? [relayPorts subarrayWithRange:NSMakeRange(1, [relayPorts count] - 1)] : [NSArray array];
NSLog(@"C: Attempting to connect to server at: %@:%d", relayHost, relayPort);
self.connectTimer = [NSTimer scheduledTimerWithTimeInterval:connectTimeout
target:self
selector:@selector(connectionConnectedCheck:)
userInfo:nil
repeats:NO];
[NSStream getStreamsToHostNamed:relayHost port:relayPort inputStream:&inputStream outputStream:&outputStream];
if ((inputStream != nil) && (outputStream != nil))
{
sendState = kSKPSMTPConnecting;
isSecure = NO;
[inputStream retain];
[outputStream retain];
[inputStream setDelegate:self];
[outputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
[outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]
forMode:NSRunLoopCommonModes];
[inputStream open];
[outputStream open];
self.inputString = [NSMutableString string];
return YES;
}
else
{
[self.connectTimer invalidate];
self.connectTimer = nil;
[delegate messageFailed:self
error:[NSError errorWithDomain:@"SKPSMTPMessageError"
code:kSKPSMTPErrorConnectionFailed
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to connect to the server.", @"server connection fail error description"),NSLocalizedDescriptionKey,
NSLocalizedString(@"Try sending your message again later.", @"server generic error recovery"),NSLocalizedRecoverySuggestionErrorKey,nil]]];
return NO;
}
}
答案 2 :(得分:0)
1)是否有办法使用设备上配置的标准帐户发送电子邮件无需打开撰写用户界面
不,你不能。
替代方式:
您可以编写将电子邮件发送到特定地址的Web服务。