英文:
meeting can not be found in the calendar of organizer
问题
我正在尝试使用ical4j 1.0.4和javax mail 1.5.0库发送Outlook会议邀请(Outlook版本2013)。我按照这篇文章的步骤进行操作 - https://stackoverflow.com/questions/1121715/how-to-send-an-ical-meeting-request-using-java-mail-and-receive-the-response,我成功地发送了Outlook会议邀请。但是组织者未能收到日历邀请。如果我从我的电子邮件ID发送会议邀请给自己,我会收到该事件,但显示“在日历中找不到会议”。所有与会者都能收到该事件,他们可以接受/拒绝,并在他们的日历中看到条目。有没有办法将会议添加到组织者的日历中?
英文:
I am trying to send outlook meeting invite (outlook version 2013) using ical4j 1.0.4 and javax mail 1.5.0 libraries.
I followed this article - https://stackoverflow.com/questions/1121715/how-to-send-an-ical-meeting-request-using-java-mail-and-receive-the-response and i was able to send outlook meeting invite.
But organizer is not receiving the calendar invite.
If i send meeting invite from my email id to myself, i receive the event but it says "meeting can not be found in the calendar".
All Attendees receive the event and they can accept/decline and also see entry in their calendar.
Is there any way to get meeting added to organizer's calendar ?
答案1
得分: 0
如果您想在组织者的日历中创建会议,我建议您从您的基于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 int property(OleAutomation auto, String name) {
return auto.getIDsOfNames(new String[] { name })[0];
}
}
有关更多信息,请参阅如何在Outlook中创建电子邮件并使其对用户可见。
有关Outlook对象模型中属性和方法调用的顺序,您可以在以下文章中找到:
英文:
If you want to create a meeting in the organizer calendar I'd suggest automating Outlook from your Java-based application. You may consider using the Ole automation technology for automating Outlook, for example:
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];
}
}
See How to create an E-Mail in Outlook and make it visible for the User for more information.
The sequence of property and method calls from the Outlook object model you can find in the following articles:
专注分享java语言的经验与见解,让所有开发者获益!
评论