<%@ page import="java.io.*, java.util.*, java.text.*" %>
<%@ page import="oracle.portal.provider.v2.render.*,
                 oracle.portal.provider.v2.http.*" %>
<%@ page import="oracle.portal.sample.v2.devguide.webservices.*" %>


<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<TITLE>Mail Client for OTN Web Services</TITLE>
</HEAD>

<BODY>
<jsp:useBean id="otn" scope="session" class="oracle.portal.sample.v2.devguide.webservices.OTNMobileWrapperStub" />

<%
  PortletRenderRequest pr = (PortletRenderRequest)
    request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
            
  String otnUsername = pr.getQualifiedParameter("otnUsername");
  String otnPassword = pr.getQualifiedParameter("otnPassword");

  String device = pr.getQualifiedParameter("selectClient");
  String from = pr.getQualifiedParameter("from");
  String to = pr.getQualifiedParameter("to");
  String message = pr.getQualifiedParameter("message");
  if(from != null && to != null && message != null)
  {
      otn.sendTextMsgWrapper(otnUsername,otnPassword,"Email:"+from,device+to,message);
      out.println("Message successfully sent to " + to + ".");
  }
  else
  {
%>

<form name="emailThem" method="POST" action="<%=PortletRendererUtil.htmlFormActionLink(pr, PortletRendererUtil.PAGE_LINK)%>">
<%=PortletRendererUtil.htmlFormHiddenFields(pr, PortletRendererUtil.PAGE_LINK)%>
  <table border="0" width="93%" name="message">
    <tr> 
      <td bgcolor="#FF9966" width="21%"><b><font color="#FFFFFF">Client</font></b></td>
      <td width="79%"> 
        <select name="<%=PortletRendererUtil.portletParameter(pr, "selectClient")%>" size="1"> 
          <option value="Email:">email</option>
          <option value="sms:">sms</option>
        </select>
      </td>
    </tr>

    <tr> 
      <td bgcolor="#FF9966" width="21%"><b><font color="#FFFFFF">From </font></b></td>
      <td width="79%"> 
        <input type="text" name="<%=PortletRendererUtil.portletParameter(pr, "from")%>" size="30" maxlength="50">
      </td>
    </tr>

    <tr> 
      <td bgcolor="#FF9966" width="21%"><b><font color="#FFFFFF">To </font></b></td>
      <td width="79%"> 
        <input type="text" name="<%=PortletRendererUtil.portletParameter(pr, "to")%>" size="30" maxlength="50">
      </td>
    </tr>
    <tr> 
      <td bgcolor="#FF9966" width="21%"><font color="#FFFFFF"><b>Message</b></font></td>
      <td width="79%"> 
        <textarea name="<%=PortletRendererUtil.portletParameter(pr, "message")%>" rows="4" cols="50"></textarea>
      </td>
    </tr>
    <tr>
      <td bgcolor="#FF9966" width="21%">&nbsp;</td>
      <td width="79%">
        <input type="submit" name="submit" value="Send">
        <input type="reset" name="reset" value="Reset">
      </td>
    </tr>
  </table>
</form>
<% 
  }
%>
</BODY>
</HTML>
