我正在寻求帮助,我是 iphone 编程新手
有没有办法发送电子邮件,使用设备上配置的标准帐户而不打开撰写 UI,没有 Pagesheet?
我想编写一个应用程序来向我发送电子邮件提醒。
期待听到你的重播
谢谢...
您必须将信息发送到您管理的服务器,然后通过 smtp 类型的方法发送电子邮件。
您可以使用任何作曲家窗口在后台发送电子邮件
请参阅此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;
}
}
1)有没有办法发送电子邮件,使用设备上配置的标准帐户而不打开撰写 UI
你不能。
替代方式:
您可以编写一个将电子邮件发送到特定地址的 Web 服务。