`
zhaozhongwei
  • 浏览: 54499 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

SWT: Drop an Outlook Email(转发)

阅读更多
I wanted to drop an outlook email to my RCP application and as always I asked google to help me. You don't find much on this, an older post was
http://www.eclipse.org/forums/index.php?t=msg&&th=147516&goto=464661

That got me startet. The damn it didn't work, I asked on the forum again and the answer made confusion even greater:

http://www.eclipse.org/forums/index.php?t=rview&goto=519397#msg_519397

gladly my wife gladly does some more windows thingy's with c# and with her help and a c# example i found out that i have to make an os call to get the type of the transfer that may change with every boot.

public static int registerType() {
// Look name up in the registry
// If name is not in registry, add it and return assigned value.
// If name already exists in registry, return its assigned value
TCHAR chFormatName = new TCHAR(0, "FileContents", true);
return OS.RegisterClipboardFormat(chFormatName);
}
Then at least the stuff from the first post started to do something, i could get an IStorage and enumerate over the STATSTG's

public Object nativeToJava(TransferData transferData) {

IDataObject idata = new IDataObject(transferData.pIDataObject);
idata.AddRef();
FORMATETC formatetc = new FORMATETC();

STGMEDIUM stgmedium = new STGMEDIUM();
formatetc.cfFormat = type;
formatetc.lindex = 0;
formatetc.ptd = 0;
formatetc.tymed = 4 | 8 | 1;
formatetc.dwAspect = COM.DVASPECT_CONTENT;
transferData.result = getData(idata, formatetc, stgmedium);
idata.Release();
if (transferData.result != COM.S_OK) {
System.out.println("Fehler" + transferData.result);
return null;
}

if ((stgmedium.tymed & 8) == 8) {
// IStorage
IStorage storage = new IStorage(stgmedium.unionField);
storage.AddRef();
long[] x = new long[1];
long ret = storage.EnumElements(0, 0, 0, x);

IEnumSTATSTG enumSTATSTG = new IEnumSTATSTG(x[0]);
enumSTATSTG.AddRef();
STATSTG[] data = new STATSTG[0];
// Loop over enumerator
long rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, STATSTG.sizeof);
int[] pceltFetched = new int[1];
enumSTATSTG.Reset();
while (enumSTATSTG.Next(1, rgelt, pceltFetched) == COM.S_OK && pceltFetched[0] == 1) {
STATSTG statstg = new STATSTG();
COM.MoveMemory(statstg, rgelt, STATSTG.sizeof);
STATSTG[] newData = new STATSTG[data.length + 1];
System.arraycopy(data, 0, newData, 0, data.length);
newData[data.length] = statstg;
data = newData;
}
OS.GlobalFree(rgelt);

enumSTATSTG.Release();

// do something with STATSTG[]

but i still did not know what the heck to do with these objects. I started to search again and finally found an example in the eclipse OleClient:

private byte[] readStream(IStorage storage, String stream) {
boolean success = false;

long[] address = new long[1];
// Look for a CONTENTS stream
if (storage.OpenStream(stream, 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) == COM.S_OK) {
IStream tempContents = new IStream(address[0]);
tempContents.AddRef();

try {
ByteArrayOutputStream w = new ByteArrayOutputStream();

int increment = 1024 * 4;
long pv = COM.CoTaskMemAlloc(increment);
int[] pcbWritten = new int[1];
while (tempContents.Read(pv, increment, pcbWritten) == COM.S_OK && pcbWritten[0] > 0) {
byte[] buffer = new byte[pcbWritten[0]];
OS.MoveMemory(buffer, pv, pcbWritten[0]);
w.write(buffer);
success = true;
}
COM.CoTaskMemFree(pv);

w.close();
return w.toByteArray();
} catch (IOException err) {
} finally {

tempContents.Release();
}

}
return null;
}

now with that I can read Streams from the IStorage. What streams there are is in the STATSTG's

// do something with STATSTG[]
Map result = new HashMap();
for (STATSTG s : data) {
String stream = getString(s.pwcsName);
result.put(stream, readStream(storage, stream));
}

storage.Release();
return result;
There we are. The IStorage contains the data in the .msg Format that I return in some strange way via the Map. I don't know how to get the .msg in one piece, but at least with some informations from

http://www.fileformat.info/format/outlookmsg/

I can now extract the contents of the message and push it to jackrabbit ;) The code in these examples is for x86_64, you may need some ints for the adresses on 32bit windows.
0
1
分享到:
评论

相关推荐

    org.eclipse.swt相关所有jar包,

    【标题】"org.eclipse.swt相关所有jar包"涵盖了用于JAVA应用程序与浏览器集成的关键库 【描述】中的"org.eclipse.swt"是指Eclipse Standard/Widgets工具包,这是一个开源的Java库,允许开发人员在多种平台上创建...

    SWT: The Standard Widget Toolkit, Volume 1

    The Standard Widget Toolkit (SWT) is a new class library for creating graphical user interfaces (GUIs) in Java. Created as part of the Eclipse project, SWT allows developers to build efficient, ...

    window搭建kettle源码环境swt依赖包切换

    org.eclipse.swt.win32.win32.x86_64-4.3.jar org.eclipse.swt.win32.win32.x86_64-4.6.jar org.eclipse.swt.win32.win32.x86-4.3.jar org.eclipse.swt.win32.win32.x86-4.6.jar linux和mac环境不需要,window环境...

    SWT深入内幕之消息机制探秘.pdf

    ### SWT深入内幕之消息机制探秘 #### 一、引言 SWT(Standard Widget Toolkit)作为一种用于构建Java应用程序的用户界面工具包,其在处理Windows操作系统的消息机制方面具有独特的设计和技术实现。本文旨在深入探讨...

    chromium.swt:SWT的Chromium小部件

    SWT用Chrome嵌入跨平台Chromium浏览器的SWT小部件。 它可以在Windows,Mac OS和Linux上运行。 这个新的小部件允许在Java SWT或Eclipse RCP应用程序中开发现代的Web UI。 使用与其他SWT浏览器相同的API,可以轻松地将...

    org.eclipse.swt 相关jar包

    org.eclipse.swt 相关jar包,JAVA调用火狐内核制作浏览器教程中所需,供各位下载,可在我的博客中查看详细用法。

    SWT,The Standard Widget Toolkit

    SWT Widget Fundamentals, Keyboard, Mouse, Control Fundamentals, Display, Tool Bars and Menus, Advanced Controls

    SWT.The.Standard.Widget.Toolkit.Volume.1

    The Standard Widget Toolkit (SWT) is a new class library for creating graphical user interfaces (GUIs) in Java. Created as part of the Eclipse project, SWT allows developers to build efficient, ...

    node-swt:使用 NodeJS 构建本机 GUI 应用程序的标准小部件工具包

    **Node-SWT: 将 NodeJS 与 SWT 结合** "Node-SWT" 是一个项目,它将 NodeJS 的强大功能与 SWT 的原生 GUI 支持相结合,使得开发者可以使用 JavaScript 来编写桌面应用程序的 UI 部分。通过 Node-SWT,你可以利用 ...

    org.eclipse.swt.win32的64位jar包

    《深入理解Eclipse SWT:64位Windows环境下的应用》 在Java开发中,Eclipse SWT(Standard Widget Toolkit)是一个非常重要的库,它为开发者提供了与操作系统原生GUI控件直接交互的能力,使得Java应用程序可以拥有...

    org.eclipse.swt相关jar包

    swt是一些用于javaGUI即图形界面设计用的插件,但是当执行打包好的exe文件时,容易出现找不到jar包的错误,这里提供下载资源

    lwjgl3-swt:LWJGL 3中对SWT的完全OpenGL支持

    创建OpenGL 3.0和3.2核心/兼容性上下文(包括调试/转发兼容) OpenGL ES上下文 没有错误上下文 浮点和sRGB像素格式 多重采样的帧缓冲区(也具有不同数量的颜色样本-仅限Nvidia) 垂直同步/交换控制 上下文刷新...

    swt:skynet 火焰图 flamegraph + debug 线上实时调试

    swt skynet 火焰图 flamegraph + debug, 运行过程中随时启停profiler,方便调试线上问题 使用说明 引入调试命令 SWT_RUN 让服务支持debug脚本执行 配置 preload = "./lualib/swt/debug.lua" 或者在服务启动时 require...

    org.eclipse.swt.win32.win32.x86_3.102.0.v20130605-1544.rar

    org.eclipse.swt.win32.win32.x86_3.102.0.v20130605-1544.rar org.eclipse.swt.win32.win32.x86_3.102.0.v20130605-1544.rar

    Java图形界面开发:SWT全接触教程

    #### SWT:Java GUI开发的新纪元 SWT是Eclipse项目组为开发其集成开发环境(IDE)而创建的一组底层图形界面API。不同于AWT和Swing,SWT采取了一种更为高效和接近原生的方式,即利用本地操作系统的图形构件API来构建...

    SWT常用组件

    - **SWT.DROP_DOWN**:下拉菜单,通常作为子菜单。 - **SWT.POP_UP**:弹出式菜单,常用于鼠标右键菜单。 **MenuItem式样** - **SWT.CASCADE**:带有子菜单的菜单项。 - **SWT.CHECK**:选中后前显示一个小勾。 - ...

    swt:SWT接口下的Java练习,这个练习处理矩阵,我们可以在其中随机创建一个新的,打开一个之前创建的矩阵,最后保存它们

    SWT(Standard Widget Toolkit)是Eclipse开源组织提供的一款用于创建图形用户界面(GUI)的Java库,它为Java开发者提供了丰富的控件和组件,与Java的AWT和Swing库相比,SWT更接近于操作系统原生的界面风格,因此在...

    org.eclipse.swt.win32

    org.eclipse.swt.SWT.class org.eclipse.swt.SWTError.class org.eclipse.swt.SWTException.class org.eclipse.swt.accessibility.ACC.class org.eclipse.swt.accessibility.Accessible.class org.eclipse.swt....

    swt-64.rar_64位swt_64的SWT_SWT64_swt.jar 64位_swt64位

    标题“swt-64.rar_64位swt_64的SWT_SWT64_swt.jar 64位_swt64位”表明这个压缩包包含了适用于64位Windows操作系统的SWT库。描述中提到的“64位windows操作系统使用的SWT库”进一步确认了这一点。 SWT的设计目标是...

    SWT JFace 按键、事件、监听

    ### SWT JFace 按键、事件、监听 #### 概述 SWT(Standard Widget Toolkit)是Eclipse平台下的图形界面开发工具包,而JFace则是基于SWT之上的高级用户界面工具集。SWT提供了低级别的组件,用于创建跨平台的图形...

Global site tag (gtag.js) - Google Analytics