使用Java在Mac上发送电子邮件以编程方式(通过的Mac邮件客户端) [英] Sending email programmatically on a Mac using Java (through Mac Mail Client)

查看:182
本文介绍了使用Java在Mac上发送电子邮件以编程方式(通过的Mac邮件客户端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了这件事情相当多的研究,我似乎无法拿出一个坚实的解决我的问题。

I've done quite a bit of research on this matter and I can't seem to come up with a solid solution to my problem.

我开发一个Java客户端应用程序(应该)允许用户导入从Mac他们的接触通过列表格式读取它们并允许用户通讯簿选择一个子集/所有,然后点击一个按钮,就发送一个邀请给这些用户。

I am developing a Java client application that (should) allow users to import their contacts from Mac Address Book by fetching them in a list format and allowing the user to select a subset/all and click a button that would send an "invitation" to these users.

我能够抓住用Rococoa Java框架的接触,但我不确定如何发送电子邮件,或者如果它甚至有可能。我知道有这个安全问题,但我能够完成这个相同的任务上展望PC。

I was able to grab contacts using the Rococoa Java framework but I am uncertain as to how to send email or if it is even possible. I realize there are security concerns with this, but I was able to accomplish this same task on Outlook for PC.

看来,我可能必须从我的Java是手动打开的Mac邮件客户端并发送电子邮件使用的默认电子邮件帐户设置调用一个AppleScript。

It seems that I may have to call an Applescript from my Java that manually opens Mac Mail Client and sends email using their default mail account setup.

我可以完全关闭基地在这里......我应该甚至懒得通过用户的默认邮件帐户发送邮件?我想避免使用不同的邮件服务器,以避免垃圾邮件等。

I could be totally off-base here... should I even bother sending mail through the user's default Mail account? I wanted to avoid using a different mail server to avoid spam etc.

任何帮助将是AP preciated,感谢您的时间。

Any help would be appreciated, thank you for your time.


  • 马特

推荐答案

下面是使用邮件的AppleScript ...

Here's an applescript to use Mail...

set emailSender to "sender@email.com>"
set emailTo to "recipient@email.com"
set theSubject to "The subject of the mail"
set theContent to "message body"

tell application "Mail"
    set newMessage to make new outgoing message with properties {sender:emailSender, subject:theSubject, content:theContent, visible:true}
    tell newMessage
        make new to recipient at end of to recipients with properties {address:emailTo}
        send
    end tell
end tell

另一种选择,如果你知道SMTP信息,是用蟒蛇。我让你可以使用一个命令行程序。搜寻这里。还有例如code使用它在网页上。

Another option, if you know the smtp information, is to use python. I made a command line program you can use. Find it here. There's example code to use it on the web page.

这篇关于使用Java在Mac上发送电子邮件以编程方式(通过的Mac邮件客户端)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆