title: Opening Outlook new email windows using jQuery using loop
body: <p>I have a list of records on a webpage (say html table).</p>
  
  <pre><code>&lt;table&gt; 
      &lt;tr&gt; 
          &lt;th&gt;checkbox&lt;/th&gt; 
          &lt;th&gt;id&lt;/th&gt;
          &lt;th&gt;name&lt;/th&gt;
      &lt;/tr&gt;
  &lt;tr&gt; 
  &lt;td&gt;&lt;input type="checkbox" name="email[]"&gt;1&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;Germany&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;input type="checkbox" name="email[]"&gt;2&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;Mexico&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="checkbox" name="email[]"&gt;3&lt;/td&gt;
  &lt;td&gt;3&lt;/td&gt;
  &lt;td&gt;Austria&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="checkbox" name="email[]"&gt;4&lt;/td&gt;
  &lt;td&gt;4&lt;/td&gt;
  &lt;td&gt;UK&lt;/td&gt;&lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Now, When I select different/all checkboxes and click on a button.</p>
  
  <p>It should open new outlook windows separately for each record.
  SO if I select all 4 checkboxes, than it should open 4 different new Email windows.
  I have already referred so many questions here. But could not figure it out.</p>
  
  <p>The biggest problem is that I can run the loop. But every time it CAN NOT open different windows. Sometimes it opens only 1/2 windows. I guess is the problem of loop and Settimeout.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    function sendMails() {
          sendMail_table.$('input:checked').each(function (i, value) {
              (function (that, m) {
                  var t = setTimeout(function () {
                  if (m.checked) {
                      var rowIndex = sendMail_table.row($(m).closest('tr')).data();
                      var party_name = rowIndex[6];
                      var find = $('#party_email_data td').filter(function () {
                          return $(this).text() === party_name;
                      });
                      emails = party_email_data.row(find.closest('tr')).data();
                      email_add = emails[1];
                      email_cc = emails[2];
                      wnd = window.open("mailto:email_id?subject=hello hi&amp;body=dfdsf", 
       "_blank", "sdf" + i);
                  }
              }, 1500);
          })(this, value);
      });
  }
  sendMails();
  </code></pre>
  
  <p>So, herecolumn names or variable names are not important for me for getting solution. I AM FACING PROBLEM IN LOOP AND SETTIMEOUT. All windows DO NOT open as they should be.</p>
  
  <p>Though loop runs number of times as it should be, but some how only1/2 new email outlook windows open. Which is wrong. I guess this happens because JS loop does not wait for response or anything else. </p>
  
  <p>I hope you all understood my problem.
  Let me know if anything else to be mentioned or clarified.</p>
  
  <p>I need this solution. Any help appreciated. </p>
  
  <p>Thank you.</p>