Clicky

20150920

Document scan with VBSscript and WIA

Windows Image Acquisition (WIA) is the still image acquisition platform in the Windows family of operating systems

In 2007 I published a VBscript that was used to create a BMP file from a document scan. That WIA method is obsolete so I updated the script to this:

OPTION EXPLICIT

'--- dim objects...
dim wsh, fso, objWIAdialog, objImage, imgFilename
set wsh=CreateObject("wscript.shell")

set fso=CreateObject("scripting.filesystemobject")
set objWIAdialog = CreateObject("WIA.CommonDialog")

'--- Start the Scanner dialog box, where a scanner can be selected...
set objImage = objWIADialog.ShowAcquireImage

'--- Save and show the scan if the scan was successful...

If Not objImage Is Nothing Then 
    Randomize
    imgFilename=
fso.GetSpecialFolder(2) & "\Scan2BMP" &  Int((999999 - 100000 + 1) * Rnd + 100000) & ".bmp" 

    wscript.echo "Scan stored as BMP in file: " & imgFilename
    objImage.SaveFile imgFilename
    wsh.run(imgFilename)
End if    


The script will start a WIA dialog that let you select the scanner and set scan properties.


After the scan, the BMP file started in the default BMP viewer.


20150909

TLD filter in hMailserver 5

As I wrote in a previous post hMailserver can be tweaked. In this post I will show a simple TLD filter. This filter is used to block emails from certain Top Level Domains, especially from countries that host many attackers.

Add this code to the hMailserver 'EventHandlers.vbs' script:

Sub OnSMTPData(oClient, oMessage)

'--- Space before the first and after the last country name are required (see TK's comment)...
 Const BlackList=" AR VN CN CO IN BR KE MX TH RO BG KZ TW RU TH "
 Dim TLD

  TLD=Mid(oMessage.FromAddress,Instr(oMessage.FromAddress,".") + 1)
    if Instr(Blacklist,uCase(TLD))>0 then
      Eventlog.Write("OnSMTPdata: TLD in Blacklist " & oMessage.FromAddress & ". 542 Rejected" )
      result.value=1
    End if    
 End Sub

That's all! Happy emailing!
Real Time Web Analytics