Javascript: Open Outlook and add attachments to new email
<p>I am trying to add attachment to new email in Outlook. </p>

<p>Like below (taken from <a href="https://stackoverflow.com/questions/31405586/how-to-open-outlook-using-javascript-on-client-machine">here</a>): </p>

<pre><code>function sendEmail(){
  try{
    var theApp = new ActiveXObject("Outlook.Application");
    var objNS = theApp.GetNameSpace('MAPI');
    var theMailItem = theApp.CreateItem(0); // value 0 = MailItem
    theMailItem.to = ('test@gmail.com');
    theMailItem.Subject = ('test');
    theMailItem.Body = ('test');
    //theMailItem.Attachments.Add("C\\file.txt");
    theMailItem.display();
   }
    catch (err) {
       alert(err.message);
    } 
}
</code></pre>

<p>It is working (new email window opened in Outlook and prefilled with above data), but only when line that supposed to add attachment is commented out. </p>

<p>In case it is uncommented exception is thrown like "File cannot be found", but file is exist. It can be manually added in Outlook as attachment. </p>

<p>It looks like Outlooks trying to find file but cannot for some reason. 
I tried with forward slash, backslash, and double backslash -- no luck. </p>

<p>Tested in Windows 7 and 8 with same result. 
It required to work only from IE.</p>

<p>Maybe somebody can provide fix to above code or have working piece of code that adds attachment to Outlook?</p>

<p>Or may be aware of some IE or Outlook settings which need to be changed? </p>

<p>A lot of thanks, anyway.</p>