Вы можете управлять Outlook из Java, используя библиотеку JACOB, как указано в предыдущем комментарии. Приведенный ниже пример работает с Microsoft Outlook 2010 и 2013. В этом примере создается черновик электронного письма и сохраняется его в папке «Черновики» в Outlook.
//---------------------------------------------------------------------
Map<String, Object> params = new HashMap<String, Object>();
param.put("subject", "Test subject");
param.put("body", "Please see attached.");
String attachment[] = new String[2];
attachment[0] = "C:/Test1.pdf";
attachment[1] = "C:/Test2.pdf";
param.put("attachments", attachment);
String to[] = new String[2];
to[0] = "test1@test.com";
to[1] = "test2@test.com";
param.put("to", to);
OutlookJACOB mail = new OutlookJACOB();
mail.createEmail(param);
//---------------------------------------------------------------------
import java.util.Map;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class OutlookJACOB
{
private ActiveXComponent ol;
private Dispatch outlook;
private Object mapi[] = new Object[1];
private Object email[] = new Object[1];
public OutlookJACOB()
{
mapi[0] = "MAPI";
email[0] = 0;
ol = new ActiveXComponent("Outlook.Application");
outlook = ol.getObject();
Dispatch.call(outlook,"GetNamespace",mapi).toDispatch();
}
public void createEmail(Map<String, Object> params)
{
Dispatch mail = Dispatch.call(outlook,"CreateItem",email).toDispatch();
Dispatch.put(mail, "Subject", params.get("subject"));
Dispatch.put(mail, "Body", params.get("body"));
String to[] = (String[]) params.get("to");
String attachments[] = (String[]) params.get("attachments");
if(to != null)
{
if(to.length>0)
{
String _to = "";
for(Object t : to)
{
_to += t + ";";
}
Dispatch.put(mail, "To", _to);
}
}
if(attachments != null)
{
if(attachments.length>0)
{
Dispatch attachs = Dispatch.get(mail, "Attachments").toDispatch();
for(Object attachment : attachments)
{
Dispatch.call(attachs, "Add", attachment);
}
}
}
Dispatch.call(mail, "Save");
}
}