OLE Automation in Java does not send e-mail from all computers [message #1742836] |
Thu, 08 September 2016 06:02 |
John Vanek Messages: 1 Registered: September 2016 |
Junior Member |
|
|
I am working on creating some applications to distribute with a small team where I work. Mostly just simplifying and creating some consistency with some processes. As such, I have created an application to send out an e-mail to a different team. The application sends an e-mail through outlook after collecting some information from the user.
The application works fine for me, but a co-worker who has been helping me do some bug testing has been unable to send the e-mail. I am unsure if it is because I have Outlook 2013 whereas he has Outlook 2010(I have a newer laptop and he hasn't gotten the upgrade yet). If that is the case, can I enable functionality for both?
Below is the method called when the user sends the e-mail:
public void sendEmail()
{
String strName = txtName.getText();
String strTis = txtTisFile.getText();
String strCDs = txtCDs.getText();
String strWorkID = txtWorkReqID.getText();
String strQueue = txtQueue.getText();
if (strCDs.length() == 0)
strCDs = "N/A";
Display display = new Display();
Shell shell = new Shell(display);
Date date = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
try
{
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", "Taxpay Schedule - " + sdf.format(date) + " Work Request Number: " + strWorkID);
//setProperty(mail, "From", "XXX@XXX.COM");
setProperty(mail, "To", "XXX@XXX.COM");
if (ccITOC == true)
setProperty(mail, "CC", "XXX@XXX.COM");
setProperty(mail, "HtmlBody", "<html><body>Hello, <p> Your XXX is complete.<p>Output is located in: " + strQueue + "<p>" + strTis + ".lis<p>Work Request #: " + strWorkID + "<p>#CDs: " + strCDs + "<p>Thank you,<p>" + strName + "<p> IT Operations Center</body></html>");
if (null != filePath) {
File file = new File(filePath);
if (file.exists()) {
OleAutomation attachments = getProperty(mail, "Attachments");
invoke(attachments, "Add", filePath);
}
}
invoke(mail, "Send");
}
catch (SWTException e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
catch (IllegalArgumentException e1)
{
JOptionPane.showMessageDialog(null, e1.getMessage());
}
catch (Exception e)
{
e.printStackTrace();
}
}
Any assistance would be greatly appreciated. This has been very frustrating.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02833 seconds