iPhone 不使用 MessageUI 发送电子邮件

发布于 2024-10-20 03:41:51 字数 399 浏览 2 评论 0原文

您好,我正在寻求帮助,我是可可和 iPhone 编程的新手,

有没有一种方法可以使用设备上配置的标准帐户发送电子邮件,而无需打开撰写 UI?

我想编写一个应用程序来向我发送电子邮件提醒。

你有一个文本区域,你可以在其中输入一些内容,当你点击标题栏上的“发送”按钮时,它会将文本区域的内容发送到我的电子邮件,就是这样,

我已经完成了文本区域和按钮的操作,但它会打开一个撰写窗口,当我使用 MFMailComposeViewController...

或者可能使用撰写窗口,但隐藏某些字段,例如收件人、抄送、密件抄送...

我在互联网上找到的所有文章要么过时,要么关于 MFMailComposeViewController...

期待听到重播一下

谢谢...

HI, I am looking for help, I am new to cocoa and iphone programming

Is there a way to send an email, using standard account configured on the device WITHOUT opening a compose UI?

I want to write an app to send me email reminders.

you have a text area where you type something, when you hit button send at the titlebar it sends contents of text area to my email, that's it

I have done the text area and button thing, but it opens me a compose window, when I use MFMailComposeViewController...

or maybe using compose window, but hide certain fields, such as to, cc, bcc...

all of articles I've found on the internet are either outdated or about MFMailComposeViewController...

looking forward to hearing a replay from you

Thanks...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

耳根太软 2024-10-27 03:41:51

无需用户交互即可使用 MFMailComposeViewController 。这种技术显然依赖于未记录的 API,因此它可能随时崩溃。另外,向 App Store 提交执行此操作的应用程序也不是一个好主意……

- (void) sendStealthEmail
{
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
    mailComposeViewController.mailComposeDelegate = self;
    [mailComposeViewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [mailComposeViewController setSubject:@"Stealth email"];
    [mailComposeViewController setMessageBody:@"Pwned" isHTML:NO];
    [mailComposeViewController view];
}

- (void) mailComposeController:(MFMailComposeViewController*)mailComposeViewController bodyFinishedLoadingWithResult:(NSInteger)result error:(NSError*)error
{
    @try
    {
        id mailComposeController = [mailComposeViewController valueForKeyPath:@"internal.mailComposeController"];
        id sendButtonItem = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.sendButtonItem"];
        [mailComposeController performSelector:@selector(send:) withObject:sendButtonItem];
    }
    @catch (NSException *e) {}
    [mailComposeViewController release];
}

It is possible to use MFMailComposeViewController without user interaction. This technique obviously relies on undocumented APIs, so it may break anytime. Also, it wouldn't be a good idea to submit an app doing this to the App Store…

- (void) sendStealthEmail
{
    MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
    mailComposeViewController.mailComposeDelegate = self;
    [mailComposeViewController setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
    [mailComposeViewController setSubject:@"Stealth email"];
    [mailComposeViewController setMessageBody:@"Pwned" isHTML:NO];
    [mailComposeViewController view];
}

- (void) mailComposeController:(MFMailComposeViewController*)mailComposeViewController bodyFinishedLoadingWithResult:(NSInteger)result error:(NSError*)error
{
    @try
    {
        id mailComposeController = [mailComposeViewController valueForKeyPath:@"internal.mailComposeController"];
        id sendButtonItem = [mailComposeViewController valueForKeyPath:@"internal.mailComposeView.sendButtonItem"];
        [mailComposeController performSelector:@selector(send:) withObject:sendButtonItem];
    }
    @catch (NSException *e) {}
    [mailComposeViewController release];
}
百合的盛世恋 2024-10-27 03:41:51

MFMailComposeViewController是Apple提供的用于发送邮件的类。

如果您不想使用 Composer,则必须编写自己的 smtp 客户端。 (它可以是 php、.net、java 或任何其他技术)。您还可以尝试 skpsmtpmessage

MFMailComposeViewController is the class that is provided by Apple to send mails.

If you don't want to use the composer you have to write your own smtp client. (It could be php, .net, java or any other technolgy). You can also try skpsmtpmessage

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文