有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

使用org通过java代码发送电子邮件。日食swt。好啊

我正在尝试使用org通过java程序发送邮件。日食swt。ole库。 我使用的是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)

共 (1) 个答案

  1. # 1 楼答案

    这听起来像Eclipse bug 361543中描述的问题。这在Eclipse中不是问题。似乎无法从64位SWT(或任何64位程序)调用32位Outlook