3

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.

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.

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.

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.

  • Matt
Matt
  • 31
  • 2

1 Answers1

2

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

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.

regulus6633
  • 18,848
  • 5
  • 41
  • 49
  • I would use the given AppleScript! For the user it is very nice to have all the mails which are sent "from him" in his sent folder. After all some people might "reply" to him, so can associate the reply to his invitation. – Angel O'Sphere Aug 19 '11 at 15:18