java - 使用 org.eclipse.swt.ole 通过 java 代码发送电子邮件

标签 java swt 64-bit sendmail ole

我正在尝试使用 org.eclipse.swt.ole 库通过 java 程序发送邮件。 我使用的是 64 位 JVM 和 32 位 Outlook。当我尝试运行该程序时,它显示“无法创建 OLEClientSite”。在浏览了互联网上的许多论坛后,我认为问题是由于 64 位 jvm 和 32 位 Outlook 造成的。我附上创建 OLEClientSite 的代码。如果这开始工作,我可以进一步编写程序。

import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.OLE;    
import org.eclipse.swt.ole.win32.OleAutomation;  
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class OleTest {


    public static void main(String[] args) {

            Email("test@gmail.com","test email", "test");
  }
    public static void Email(String sRecipient, String sSubject, String sReportName)     
{
        Display display = new Display();
        Shell shell = new Shell(display);
        OleFrame frame = new OleFrame(shell, SWT.NONE);

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

        // Now get the outlook application
        OleClientSite site2 = new OleClientSite(frame, SWT.NONE,
                "Outlook.Application");
        OleAutomation outlook = new OleAutomation(site2);

    }


}

The error which I am getting is:
Exception in thread "main" org.eclipse.swt.SWTException: Failed to create Ole Client.     
result = -2147221164
    at org.eclipse.swt.ole.win32.OLE.error(Unknown Source)
    at org.eclipse.swt.ole.win32.OleClientSite.<init>(Unknown Source)
    at OleTest.Email(OleTest.java:22)
    at OleTest.main(OleTest.java:14)

最佳答案

这听起来像 Eclipse bug 361543 中描述的问题。这已关闭,因为在 Eclipse 中不是问题。看来无法从 64 位 SWT(或任何 64 位程序)调用 32 位 Outlook。

关于java - 使用 org.eclipse.swt.ole 通过 java 代码发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22033128/

相关文章:

在 Linux 64 位上结合 C 和汇编(32 位代码)

dll - 尝试使用 mingw-w64 编译 64 位 DLL

python - 在 Windows Vista x64 上部署 PyQt 应用程序

java - 复制 Paint 对象

java - 如何让 spring boot mvc 理解 observables?

java - Eclipse - JFace 表列未显示在自定义对话框中

swt - 高级 SWT 表格部件

java - 用java解析高级XML

java - Mockito,无法初始化 JNDI 或来自 servlet 容器的任何内容

Java SWT 显示 StyledText 的行号