I want to create an E-Mail with a Java Application using Outlook and the OLE Client.
I searched for examples and found quite a few. They all start the same way:
Create the Display, the Shell, the OLE Frame and the OLE Client Site.
But I get an error with these few steps:
Display display = new Display(); Shell shell = new Shell(display); shell.setText("Outlook Automation"); shell.setLayout(new FillLayout()); OleFrame frm = new OleFrame(shell, SWT.NONE); OleClientSite site = new OleClientSite(frm, SWT.NONE, "Outlook.Application");
I get the following Error:
Exception in thread "main" org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221164 at org.eclipse.swt.ole.win32.OLE.error(OLE.java:302) at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:242) at outlooktest.Main.main(Main.java:27)
I don't know OLE and I'm not sure what I am doing wrong. Are there some dependencies I'm missing? Does somebody know what this error could be? I googled for the Error code but didn't find anything.
Well if nobody knows why OLE doesn't work for me I've got another question. Is it possible, or is there a Library, to create an Outlook E-Mail and set it up (subject, body etc) but not send it but make it visible for the User to change things?
The x86 and x64 jar files didn't work out, same error. Also I got the newest versions of SWT for x86 and x64. OS is x64 and java, too, so I can't use the x86 SWT libraries. With the x64 the error above occurs. The Outlook version is 15 (Outlook 2013).
Hopefully this helps?
I got the creation of E-Mail to work via Processbuilder but only with the mailto: parameter. The problem here is the folllowing:
- I want to track the status of the Process. I want to know when the E-Mail is closed/send whatsoever.
- I want to insert a picture (BufferedImage) out of the Clipboard into the Body, which is simply impossible with the mailto argument.