gpt4 book ai didi

java - 在组织者的日历中找不到 session

转载 作者:行者123 更新时间:2023-12-01 16:28:45 25 4
gpt4 key购买 nike

我正在尝试使用 ical4j 1.0.4 和 javax mail 1.5.0 库发送 Outlook session 邀请(Outlook 版本 2013)。

我关注了这篇文章 - How to send an iCal meeting request using Java Mail, and receive the response我能够发送 Outlook session 邀请。

但是组织者没有收到日历邀请。
如果我从我的电子邮件 ID 向自己发送 session 邀请,我会收到该 Activity ,但它显示“在日历中找不到 session ”。

所有与会者都会收到该 Activity ,他们可以接受/拒绝,还可以在日历中查看条目。

有什么方法可以将 session 添加到组织者的日历中吗?

最佳答案

如果您想在组织者日历中创建 session ,我建议您从基于 Java 的应用程序中自动执行 Outlook。您可以考虑使用 Ole 自动化技术来自动化 Outlook,例如:

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
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.ole.win32.Variant;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class OutlookMail {
public static void main(String[] args) {
sendEMail();
}

public static void sendEMail() {
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, "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", "My test subject");
// setProperty(mail, "From", "my@sender.org");
setProperty(mail, "To", "<John Doe> my@recipient.org");
setProperty(mail, "HtmlBody", "<html><body>This is an <b>HTML</b> test body.</body></html>");

// 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" */);

}

private static OleAutomation getProperty(OleAutomation auto, String name) {
Variant varResult = auto.getProperty(property(auto, name));
if (varResult != null && varResult.getType() != OLE.VT_EMPTY) {
OleAutomation result = varResult.getAutomation();
varResult.dispose();
return result;
}
return null;
}

private static Variant invoke(OleAutomation auto, String command,
String value) {
return auto.invoke(property(auto, command),
new Variant[] { new Variant(value) });
}

private static Variant invoke(OleAutomation auto, String command) {
return auto.invoke(property(auto, command));
}

private static Variant invoke(OleAutomation auto, String command, int value) {
return auto.invoke(property(auto, command),
new Variant[] { new Variant(value) });
}

private static boolean setProperty(OleAutomation auto, String name,
String value) {
return auto.setProperty(property(auto, name), new Variant(value));
}

private static boolean setProperty(OleAutomation auto, String name,
int value) {
return auto.setProperty(property(auto, name), new Variant(value));
}

private static int property(OleAutomation auto, String name) {
return auto.getIDsOfNames(new String[] { name })[0];
}
}

参见How to create an E-Mail in Outlook and make it visible for the User了解更多信息。

您可以在以下文章中找到来自 Outlook 对象模型的属性和方法调用的顺序:

关于java - 在组织者的日历中找不到 session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62093141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com