Foxticity
Foxticity

Reputation: 333

Is .oft (outlook template) supported by java or another java API out there?

I would please like to know if .oft is supported by java?

What i basically want to do is on my java program, when i click the "email" button, it should open one of my .oft templates and automatically fill the address bar with some email address from my SQL database.

I'm currently using the Desktop API ("mailto:") to populate the address bar with different email address but it only opens an open email with nothing in it.

Also please note, I don't want the emails to be automated, it should open the template, because the user still needs to add input into the body of the email.

Please let me know of any suggestions.

Thanks!

Upvotes: 2

Views: 2463

Answers (3)

Foxticity
Foxticity

Reputation: 333

Thanks for all your answers, but found a great way to do this, i'm sharing the code for anyone who wants to do the same thing or similar:

        Shell shell = new Shell(getDisplay());
        OleFrame frame = new OleFrame(shell, SWT.NONE);
        // This should start outlook if it is not running yet
        OleClientSite site = new OleClientSite(frame, SWT.NONE, "OVCtl.OVCtl");
        site.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
        // Now get the outlook application
        OleClientSite site2 = new OleClientSite(frame, SWT.NONE, "Outlook.Application");
        OleAutomation outlook = new OleAutomation(site2);
        // 
        OleAutomation mail = invoke(outlook, "CreateItem", 0 /* Mail item */).getAutomation();
        setProperty(mail, "To", "[email protected]"); /*
                                                     * Empty but could also be
                                                     * predefined
                                                     */
        //setProperty(mail, "Bcc", ""); 
                                                    /*
                                                     * Empty but could also be
                                                     * predefined
                                                     */
        setProperty(mail, "BodyFormat", 2 /* HTML */);
        setProperty(mail, "Subject", filterComboBox.getSelectedItem().toString());
        setProperty(mail, "HtmlBody", w.toString());

        invoke(mail, "Display" /* or "Send" */); 

and:

private static Variant invoke(OleAutomation auto, String command,String value) 
{
    return auto.invoke(property(auto, command), new Variant[] { new Variant(value) });
}

private static Variant invoke(OleAutomation auto, String command) 
{
    return auto.invoke(property(auto, command));
}

private static Variant invoke(OleAutomation auto, String command, int value) 
{
    return auto.invoke(property(auto, command), new Variant[] { new Variant(value) });
}

private static boolean setProperty(OleAutomation auto, String name,
        String value) {
    return auto.setProperty(property(auto, name), new Variant(value));
}

private static boolean setProperty(OleAutomation auto, String name,
        int value) {
    return auto.setProperty(property(auto, name), new Variant(value));
}

private static int property(OleAutomation auto, String name) {
    return auto.getIDsOfNames(new String[] { name })[0];
}

Upvotes: 1

Hajo Thelen
Hajo Thelen

Reputation: 1135

May be it's possible to encode the template in the mailto url

may be a good starting points

Upvotes: 1

Hajo Thelen
Hajo Thelen

Reputation: 1135

There are connectors like http://www.moyosoft.com/joc/ may be this helps.

Upvotes: 0

Related Questions