<?vsp 
--  
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2018 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  

  declare err varchar;
  err := '';
  if ({?'get'} = 'Get')
    {
      declare ma any;
      declare i, l integer;
      declare exit handler for sqlstate '*' { err := __SQL_MESSAGE;  goto endr;};
      ma := pop3_get ({?'s'}, {?'u'}, {?'p'}, 10000000);
      i := 0; l := length (ma);
      while (i < l)
        {
          INSERT INTO SM_S_5 (ID,BODY) VALUES (ma[i][0], ma[i][1]);
          i := i + 1;
	}
      if (i > 0)
	{
	  http_request_status ('HTTP/1.1 302 Found');
	  http_header ('Location: sm_s_5_sample_2.vsp\r\n');
	}

    }
  if (isstring({?'clr'}))
    {
      delete from SM_S_5;
    }

 endr:
?>

<html>
<HEAD><link rel="stylesheet" type="text/css" href="../demo.css" /></HEAD>
<body>
  <p style="color: red"><?=err?></p>
  <form method="post" action="sm_s_5_sample_1.vsp">
    <table class="tableentry">
      <tr><td>1. Enter the address&amp;port of POP3 server</td>
             <td><input type="text" name="s"></td></tr>
      <tr><td>2. Enter the POP3 account</td>
             <td><input type="text" name="u"></td></tr>
      <tr><td>3. Enter the POP3 password</td>
             <td><input type="password" name="p"></td></tr>
      <tr><td><input type="submit" name="get" value="Get"></td>
      <td><input type="submit" name="clr" value="Clear all"></td></tr>
    </table>
  </form>
</body>
</html>
