EmiaCtrlLite
version 20030717 and later, can now be easily installed as a web service.
We have provided a provided a simple utility to make your migration as
simple as possible.
To host this web service, the host must meet the following requirements:
- Microsoft Windows
2000 Professional (service pack 2) or later
- IIS (Internet Information
Server) 5.0 or later
- WSH (Windows Scripting
Host)
- Microsoft .Net
Framework 1.0 (with ASP.NET) or later
The utility to install
this web service, installews.exe
will place a wrapper around the EmiaCtrlLite.dll, named EmiaWebServiceLite.asmx.
We will be providing documentation, on how to manually install this service
for advanced configurations, in the future.
EmiaWebServiceLite.asmx
has the following methods:
SECURE METHODS
for POP3
- VT_VARIANT
get_stat_e(VT_BSTR pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR
password)
- VT_VARIANT get_list_e(VT_BSTR
pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password)
- VT_VARIANT get_message_e(
VT_BSTR pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password, VT_I4
msgnum, VT_I2 DELSWITCH*)
* DELSWITCH = 1 or
0, (1= delete message on server, 0 = keep message on server)
- VT_VARIANT del_remote_msg_e(VT_BSTR
pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password, VT_BSTR msgnum*
)
METHODS for
SMTP (Sending Mail)
- VT_VARIANT send_mail(VT_BSTR
smtphost , VT_I4 port,(VT_BSTR RecipientAddress, VTBSTR SenderAddress,
VT_BSTR message )
METHODS for
POP3 (Retrieving,Checking and Deleting Mail)
- VT_VARIANT get_stat(VT_BSTR
pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password)
- VT_VARIANT get_list(VT_BSTR
pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password)
- VT_VARIANT get_message(
VT_BSTR pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password, VT_I4
msgnum, VT_I2 DELSWITCH*)
* DELSWITCH = 1 or
0, (1= delete message on server, 0 = keep message on server)
- VT_VARIANT del_remote_msg(VT_BSTR
pop3host, VT_I4 port, VT_BSTR userid, VT_BSTR password, VT_BSTR msgnum*
)
* msgnum ( a string eg. to delete message 1 from server ="1",
or string keyword to remove all message on server="all"
Developing Clients
for "EmiaWebServiceLite.asmx"
For the Client, you
must install "Microsoft SOAP Toolkit". It is recommended that
the client should use the "secure methods", to avoid sending
passwords as clear text in soap messages. To use the secure methods, you
must first encrypt your POP3 password using RC4 encryption, then convert
it to BASE64 for transmission.All methods return "Strings",
so it is up to the developer to parse the data from the String. An example
is given below:
Dim mail
Dim sbox(255)
Dim key(255)
Set mail = CreateObject("MSSOAP.SOAPClient")
mail.ClientProperty("ServerHTTPRequest") = True
Call mail.mssoapinit("http://127.0.0.1:8080/emiawebservicelite/emiawebservicelite.asmx?wsdl","","","")
dim password
dim keyw
keyw = TimeKey(now)
WScript.Echo keyw
password = EnDeCrypt("pwd",keyw)
password = Base64Encode(password)
mail.send_mail "mail.host.com",25,"test1@host.com","test2@host.com","test
from webservice"
Dim message
message = CStr(message)
message = mail.get_message_e("mail.host.com",110,"userid",password,1,0)
WScript.Echo message
dim stat
stat = CStr(stat)
stat = mail.get_stat_e("mail.host.com",110,"userid",password)
WScript.Echo stat
list = mail.get_list_e("mail.host.com",110,"userid",password)
WScript.Echo list
-------------------------------------------------------------------------------------------------------------------------------------
function TimeKey(currTime)
TimeKey = FormatUTC(currTime)
dim keyarry
keyarry = split(TimeKey,":")
TimeKey = keyarry(0)+":"+keyarry(1)
end function
Sub RC4Initialize(strPwd)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine called by EnDeCrypt function. Initializes the
:::
'::: sbox and the key array) :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim tempSwap
dim a
dim b
intLength =
len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next
b = 0
For a = 0 To 255
b = (b + sbox(a) + key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next
End Sub
Function EnDeCrypt(plaintxt, psw)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine does all the work. Call it both to ENcrypt :::
'::: and to DEcrypt your data. :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher
i = 0
j = 0
RC4Initialize
psw
For a = 1 To
Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = temp
k = sbox((sbox(i) + sbox(j)) Mod 256)
cipherby =
Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
Next
EnDeCrypt =
cipher
End Function
Function Base64Encode(inData)
'rfc1521
'2001 Antonin Foller, PSTRUH Software, http://pstruh.cz
Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim cOut, sOut, I
'For each group of 3 bytes
For I = 1 To Len(inData) Step 3
Dim nGroup, pOut, sGroup
'Create one long from this 3 bytes.
nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _
&H100 * MyASC(Mid(inData, I + 1, 1)) + MyASC(Mid(inData, I +
2, 1))
'Oct splits the long To 8 groups with 3 bits
nGroup = Oct(nGroup)
'Add leading zeros
nGroup = String(8 - Len(nGroup), "0") & nGroup
'Convert To base64
pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1,
2)) + 1, 1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1,
1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1,
1) + _
Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1,
1)
'Add the part To OutPut string
sOut = sOut + pOut
'Add a new line For Each 76 chars In dest (76*3/4 = 57)
'If (I + 2) Mod 57 = 0 Then sOut = sOut + vbCrLf
Next
Select Case Len(inData) Mod 3
Case 1: '8 bit final
sOut = Left(sOut, Len(sOut) - 2) + "=="
Case 2: '16 bit final
sOut = Left(sOut, Len(sOut) - 1) + "="
End Select
Base64Encode = sOut
End Function
Function MyASC(OneChar)
If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)
End Function
function FormatUTC(ByVal vDate)
'================================================
'Converts input date/time to Universal Time
'Coordinate (UTC) in the same format as JScript's
'Date().toUTCString() method.
'
' dayabbreviation, dd monthname yy hh:mm:ss UTC
'
'Example: Fri, 2 July 1999 18:17:50 UTC
'
'================================================
if isdate(vdate) then
vdate = cdate(vdate)
else
err.raise &h7001,"FormatUTC","Argument is not
a valid date"
end if
set shell =
createobject("wscript.shell")
'ActiveTimeBias
is the number of minutes that UTC
'is offset from local time. It is added to local
'date/time to get UTC equivalent.
'
strValueName = _
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\"_
& "TimeZoneInformation\ActiveTimeBias"
tmpTimeOffset = shell.regread(strValueName)
'ActiveTimeBias can be REG_BINARY or REG_DWORD
'depending on the OS version...
'
if IsArray(tmpTimeOffset) then
'it's REG_BINARY w/ 2 bytes significant
lngTimeOffset = tmpTimeOffset(0) + (tmpTimeOffset(1)*(2^8))
else
'it's REG_DWORD
lngTimeOffset = tmpTimeOffset
end if
dt = DateAdd("n", lngTimeOffset, vDate)
'Extract the
"fields" of the date/time and
'reformat into UTC standard format.
'
dayabbr = weekdayname(weekday(dt),True) 'abbreviated
'JScript doesn't
include leading 0 on day,
'so we don't either.
'
dd = datepart("d",dt)
monnm = monthname(month(dt),true)
yyyy = year(dt)
hh = right("00"
& hour(dt),2)
mn = right("00" & minute(dt),2)
ss = right("00" & second(dt),2)
FormatUTC =
_
dayabbr & ", " _
& dd & " " & monnm & " " &
yyyy & " " _
& hh & ":" & mn & ":" &
ss _
& " UTC"
end function
|
|