Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » OLE Automation in Java does not send e-mail from all computers
OLE Automation in Java does not send e-mail from all computers [message #1742836] Thu, 08 September 2016 06:02 Go to next message
John Vanek is currently offline John VanekFriend
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.
Re: OLE Automation in Java does not send e-mail from all computers [message #1746845 is a reply to message #1742836] Sat, 05 November 2016 22:56 Go to previous message
Ludger Heisterkamp is currently offline Ludger HeisterkampFriend
Messages: 2
Registered: October 2015
Junior Member
Hello John,

is it possible that your co-worker uses a 32-bit Outlook and you are using 64-bit Outlook or vice versa? The used Outlook version has to correspond to the used swt version.

Kind regards,
Ludger
Previous Topic:Customize shell title bar
Next Topic:Newcomer with SWT has no idea what to do...
Goto Forum:
  


Current Time: Wed Dec 13 17:00:00 GMT 2017

Powered by FUDForum. Page generated in 0.02062 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software