Skip to main content

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

4 replies [Last post]
michaelchanjava
Offline
Joined: 2005-12-23
Points: 0

Is it possible with the current api?

Thanks,

Michael

Reply viewing options

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

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).

    @SuppressWarnings("nls")
    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");
        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, "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" */);

    }
hwbbh
Offline
Joined: 2008-07-28
Points: 0

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

Regards,
Lionel

uta
Offline
Joined: 2007-01-10
Points: 0

MS Outloook integration demo:
https://jdic.dev.java.net/documentation/incubator/JDICplus/ws/DocViewDem...

The source is in demo/DocViewDemo folder.

uta
Offline
Joined: 2007-01-10
Points: 0

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