title: activex outlook bring to front
body: <p>How to bring the outlook application in front which is opened from JavaScript using ActiveX.The following is the code in which I need to bring outlook window on the top (i.e. bring to front), because it is opening behind the I.E. browser.</p>
  
  <pre><code>// Open outlook e-mail client application with the corresponding subject and the attachment link
  function openOutlook(emailSubject, emailAttach) {
      try {
          var app = new ActiveXObject('Outlook.Application');
          var objNS = app.GetNameSpace('MAPI');
          var mailItem = app.CreateItem(0);
          mailItem.Subject = (emailSubject);
          mailItem.to = 'test@test.com';
          mailItem.display();
          mailItem.Attachments.add(emailAttach);
      }
      catch (ex) {
          alert('Outlook configuration error : ' + ex.message);
      }
  }
  </code></pre>
  
  <p>So far, I've tried changing <strong>mailItem.display();</strong> to <strong>mailItem.display(false);</strong> and <strong>mailItem.display(true);</strong> and <a href="https://stackoverflow.com/questions/11554891/open-word-from-javascript-and-bring-to-front">open-word-from-javascript-and-bring-to-front</a> but it didn't help and there seems to be a glitch here i.e. when I change the code this way and run the app then outlook window comes on the top, but if I open it in another system or open after restarting the system then it doesn't work, I think maybe windows OS is making it come on the top somehow.</p>