在 Mac 上使用 Java 以编程方式发送电子邮件(通过 Mac 邮件客户端)

编程入门 行业动态 更新时间:2024-10-21 16:38:16
本文介绍了在 Mac 上使用 Java 以编程方式发送电子邮件(通过 Mac 邮件客户端)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我对这个问题进行了大量研究,但似乎无法为我的问题找到可靠的解决方案.

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 客户端应用程序,它(应该)允许用户通过以列表格式获取联系人并允许用户选择一个子集/全部并单击将发送邀请"给这些用户.

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 框架获取联系人,但我不确定如何发送电子邮件,或者是否可能.我意识到这存在安全问题,但我能够在 Outlook for 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 调用 Applescript,手动打开 Mac 邮件客户端并使用他们的默认邮件帐户设置发送电子邮件.

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.

任何帮助将不胜感激,感谢您的时间.

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

马特

推荐答案

这是一个使用邮件的小程序...

Here's an applescript to use Mail...

set emailSender to "sender@email>"
set emailTo to "recipient@email"
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信息,另一个选择是使用python.我做了一个你可以使用的命令行程序.在此处找到它.有示例代码可以在网页上使用它.

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.

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

更多推荐

[db:关键词]

本文发布于:2023-04-17 14:23:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/915882.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   发送电子邮件   邮件   方式   Mac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!