Email Object



 
The Email object permits sending emails.


Members Table

    The following table lists the members provided by the Email object.

    Members
    Methods Description
    CreateJob Creates an object that provides email functionality.

Remarks
    This object is available through the main object SiteKiosk. Use the Email object to send emails.

    Note that the path of a file using SiteKiosk objects must be allowed in the
    SiteKiosk configuration (Security -> Access -> URL's With Script Permission)
    if it is not a browser skin file.
Examples
    The following example contains a form that sends an email to a specified address.

    <html>
    <head>
    <SCRIPT TYPE="text/javascript">
    window.external.InitScriptInterface();
    function disableradios()
    {
       emusername.disabled = true;
       empassword.disabled = true;
       popsvr.disabled = true;
       empopport.disabled = true;
    }
    function enableradios()
    {
       emusername.disabled = false;
       empassword.disabled = false;
       popsvr.disabled = false;
       empopport.disabled = false;
    }
    function emgetsettings()
    {
      myloadcfg = SiteKiosk.Email.CreateJob(true);
      emsmtpserver.value = myloadcfg.SMTPServer;
      popsvr.value = myloadcfg.POPServer;
      if (popsvr.value == "") popsvr.value = "pop.server.com";
      if (myloadcfg.Authentication == 2) atype[0].checked = true;
      if (myloadcfg.Authentication == 3) atype[1].checked = true;
      if (myloadcfg.Authentication == 1)
        {
           atype[2].checked = true;
           disableradios();
        }
    }
    function emsend()
    {
     
       if ((empopport.value > 0) && (empopport.value <= 1000) &&
           (emsmtpport.value > 0) && (emsmtpport.value <= 1000))
       {
         mymail = SiteKiosk.Email.CreateJob(false);
         mymail.OnStatusTextChange = OnStatusTextChange;
         mymail.POPServer = popsvr.value;
         mymail.POPPort = empopport.value;
         mymail.Username = emusername.value;
         mymail.Password = empassword.value;
         mymail.SMTPServer = emsmtpserver.value;
         mymail.SMTPPort = emsmtpport.value;
         if (atype[0].checked) mymail.Authentication = 2;
         if (atype[1].checked) mymail.Authentication = 3;
         if (atype[2].checked) mymail.Authentication = 1;
         mymail.SetSender(sndadr.value, emsendername.value);
         mymail.AddRecipient(emrecipient.value);
         mymail.Subject = emsubject.value;
         if (bdtype[0].checked) mymail.PlainBody = emtext.value;
         if (bdtype[1].checked) mymail.HTMLBody = emtext.value;
         mymail.Send(0, false, true);
       } else alert("Please enter a valid pop and smtp port");
    
    }
    function OnStatusTextChange(emsendstatus)
    {
       id_sstat.innerHTML = "Status: " + emsendstatus;
    }
    </SCRIPT>
    </head>
    <body>
    <table border="0" bgcolor="#ebebeb" width="600" cellspacing="5"
    cellpadding="5" style="font-family:verdana;font-size:8pt;"
    align="center">
    <tr><td bgcolor="f8f8f8">
    The following example contains a form that sends an email to
    a specified address.
    </td></tr>
    <tr><td style="font-family:verdana;font-size:8pt;">
    <pre>
    Recipient
    <input type="text" name="emrecipient" value="recipient@server.com"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    <br>
    Sender (name)
    <input type="text" name="emsendername" value="Name of the sender"
    style="width:100%;height:20px;">
    <br>
    Sender (Email address)
    <input type="text" name="sndadr" value="sender@server.com"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    <br>
    Subject
    <input type="text" name="emsubject" value="This is the subject"
    style="width:100%;height:20px;">
    <br>
    Content
    <textarea name="emtext" style="width:100%;height:100px;">
    This is the content of the mail.
    </textarea>
    <br>
    <u>Content type</u>:
    <input type="radio" name="bdtype" checked> Plain text
    <input type="radio" name="bdtype"> HTML text
    <br>
    <hr>
    
    <u>Authentication</u>:
    <input type="radio" name="atype" style="size:20;"
    onclick="enableradios()" checked> POP before SMTP
    <input type="radio" name="atype" onclick="enableradios()"> SMTP
    <input type="radio" name="atype" onclick="disableradios()"> none
    <br>
    Username
    <input type="text" name="emusername" value="Username"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    Password
    <input type="password" name="empassword" value="Password"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    <br>
    <u>POP server</u>:
    Address
    <input type="text" name="popsvr" value="pop.server.com"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    Port
    <input type="text" name="empopport" value="110" maxlength="5"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    <br>
    <u>SMTP server</u>:
    Address
    <input type="text" name="emsmtpserver" value="mail.server.com"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    Port
    <input type="text" name="emsmtpport" value="25" maxlength="5"
    style="width:100%;height:20px;" onfocus="mymerk=value;"
    onblur="if (value == '') value = mymerk;">
    <br>
    <br>
    <span style="color:#cc3300;" id="id_sstat">Status: None.</span>
    </pre>
    </td></tr>
    </table>
    <br><br>
    <div align="center">
    <a href="javascript:emsend()">
    Send
    </a>
    </div>
    <script language="javascript">
    emgetsettings();
    </script>
    </body>
    </html>
    

Applies to
    SiteKiosk v5.0 (and later versions).

Back to top