First, I setup windows to open the .ant extension with the ant interpreter:
- Open Explorer
- Select Tools->Folder Options
- Select the File types tab
- If ant is not present, click New.
- Select the ant entry, and click advanced
- In the edit file type dialog, select new action
- Enter "open" (no quotes) for the action
- For application used, enter (with quotes) "C:\apache-ant-1.6.5\bin\ant.bat" -file "%1"
C:\apache-ant-1.6.5\bin\ant.bat -f c:\utils\testing\ant\ant_mail.ant -Dfilename=
It's important to note that the -Dfilename= doesn't hard code the file name because it is fed to the shortcut when you do the Send To.
Here's the script it calls (ant_mail.ant):
<project name="ant_mail_file" default="mail_success" basedir="c:\utils\testing\ant">
<property file="ant_mail.properties" />
<description>Email a file passed as a parameter</description>
<target name="mail_success">
<mail mailhost="mailhost.mydomain.com" mailport="25" subject="${filename} ${subject}">
<from address="${from_address}"/>
<replyto address="${from_address}"/>
<to address="${to_address}"/>
<message>Attached is ${filename}</message>
<fileset file="${filename}">
</fileset>
</mail>
</target>
</project>
Finally, I have the following ant_mail.properties file in the same directory as ant_mail.ant:
subject=
from_address=john.mcdevitt@mydomain.com
to_address=john.mcdevitt@mydomain.com
If I'm planning ahead (rarely), I can mess with the addresses or the subject properties to make the email a little more meaningful than just having a subject line of the file name. However, the main goal is served, I can easily forward the message to whomever I wanted to send the doc to, and I get to avoid the ugly Notes attachment interface.
2 comments:
You are a picky, picky young man.
Talk about a typical engineer thing to do! Very you. Note to ISSS database, ANT support, OTHER category: John McDevitt.
Post a Comment