Skip to main content

How to send outlook message with HTML format instead of plain test

4 replies [Last post]
Joined: 2005-12-23

Is it possible with the current api?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-12-03

I was able to open an HTML email in MS Outlook 2007 only by using SWT OLE API.
Please see the tutorial on Vogella about Microsoft and Java Integration with Eclipse

It says it will work also with standard Java (non-RCP).

    public void sendEMail()

        OleFrame frame = new OleFrame(getShell(), SWT.NONE);

        // This should start outlook if it is not running yet
        OleClientSite site = new OleClientSite(frame, SWT.NONE, "OVCtl.OVCtl");

        // 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, "BodyFormat", 2 /* HTML */);
        setProperty(mail, "Subject", subject);
        setProperty(mail, "HtmlBody", content);

        if (null != attachmentPaths)
            for (String attachmentPath : attachmentPaths)
                File file = new File(attachmentPath);
                if (file.exists())
                    OleAutomation attachments = getProperty(mail, "Attachments");
                    invoke(attachments, "Add", attachmentPath);

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

Joined: 2008-07-28

Hi all,

I have a bunch of question regarding mail support and HTML messaging. They are only partially answered by your post uta and I need more details.

- JDICplus depends on Java 1.6. The product that i develop does not support java 1.6 (only 1.5). Does Desktop.mail(msg) allows to send a message with html as the body? it does not seem that it does on jdic-0.9.3.

- Does JDic offer support for ICal and VCal format in any way ?

One more point,as another constraints, i have a very short timeframe to dedicate myself to this problem. so any solution would have to be working out of the box so to speak.

Thanks for your answers


Joined: 2007-01-10

MS Outloook integration demo:

The source is in demo/DocViewDemo folder.

Joined: 2007-01-10

You can do it by using embedded Outlook in HTML and JS or VB scenario. Google will help you. Hope the JDICplus v0.2.2 will contain draft example for MS Office integration.

Message was edited by: uta