Writing E-mails from NetBeans IDE 4.1 (Part 2)

In yesterday's blog entry I showed how you can use Ant to write and send an e-mail from NetBeans IDE 4.1 (or 4.0). However, the e-mail was hardcoded in an Ant script. Whenever you want to send an e-mail to a different person, you have to change the address in the Ant script. The same goes for the subject line and the message. Therefore, even though it's kind of cute that you can send e-mails from NetBeans IDE 4.1, via Ant, it's not very usable. However, a few blog entries ago, I outlined an Ant-prompted deployment scenario. Thanks to Ant's input handler, you're able to write an Ant script that lets you select a deployment server on the fly. That same input handler can be used, of course, for setting or selecting an e-mail address, subject line, and message body.

Here's the Ant script that makes it all possible:

<target name="Create E-mail" description="E-Mail">
            
 <input message="Who do you want to write to?"
    addproperty="email.destination"
   defaultvalue="geertjan.wielenga@sun.com"/>
                    
 <input message="What should the subject line be?"
    addproperty="email.subject"
   defaultvalue="E-mail from Ant"/>
                 
 <input message="What would you like to say?"
    addproperty="email.message"
   defaultvalue="Ant-integration in NetBeans IDE 4.x is great!"/>
                    
 <mail mailhost="mymailhost" mailport="mymailport" subject="${email.subject}">
    <from address="geertjan.wielenga@sun.com"/>
    <to address="${email.destination}"/>
    <message>${email.message}</message>   
 </mail>          
                  
</target>

Now, after hooking the above target to the IDE's Tools menu, I can choose it there:

When I choose that menu item, the first input handler pops up and I fill in the destination address:

When I click OK, the email.destination property is set. Then the next input handler appears and I fill in the subject line of my e-mail:

When I click OK, the email.subject property is set. The next input handler appears and I type in my message. Sure, the input handler is small and this whole e-mail implementation is very wobbly and anything but versatile, however it gets the job done. For sending small messages and reminders to others (or to myself) the input handler is perfect:

When I click OK in the input handler above, the email.message property is set and the mail task -- which is part of the same target -- sends the e-mail to its destination. I could also attach a logfile, for example, so this scenario could be quite a bit more useful than it might seem. Maybe it would be better to hook the target up to a simple shortcut so that I can call it really quickly whenever I want, to quickly remind myself of something while I'm in the middle of something else. And, by the way, notice that the Ant script sets a default value for each input handler.

Comments:

That's cool but are you aware of any way you can have multiple inputs on the one form? That would probably involve writing you own InputHandler. Are you aware of any resources for doing this? Thanks!

Posted by Duana on August 03, 2006 at 11:07 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
23
24
25
26
27
28
29
30
   
       
Today