Using JScript/ActiveScript
Getting Familiar with JScript
JScript is a powerful programming language that supports COM/ActiveX automation. From JScript you can deal with MS Excel documents, MS Access databases and other widely used applications that support COM/ActiveX technology. To learn more about the language, see examples and download the language documentation, visit Microsoft web site.
In Emex 3, JScript program is used to "approve" e-mail address. If the address meets all the requirements defined in Emex 3 settings, JScript is to say the last desisive word - whether to add the address to the list of addresses found or not. To make the decision, it can, for example, check the address through Advanced Maillist Verify, compare the mailbox and/or the mailbox domain to the list of mailboxes/domains needed in the program itself or in an external source (e.g., in a MS Excel document).
JScript Objects
Emex 3 extends the JScript name space with an object named emex3 that contains the following properties and methods:
Name | Type | Description |
DataField | Return field of result row. Example: var f = emex3.DataField(0); | |
URL | Return URL of parsed document | |
Document | Return content of parsed document | |
URLDomain | Return domain of URL to parsed document | |
URLDocument | Return document file name | |
GetEmailDomain | Return email address domain of argument. E.g. var x = emex3.GetEmailDomain("user@mail.cc"); returns mail.cc | |
GetEmailUser | Return email account. E.g. var x = emex3.GetEmailUser("user@mail.cc"); returns user | |
AddDomainToIgnoreList | Add domain to ignore list. Argument may be domain or URL. E.g. emex3.AddDomainToIgnoreList("wikipedia.org"); | |
StopProcessCurrentDomain | Add current document domain to ignore list. | |
Stop | Stop project execution. | |
Pause | Pause download queue. | |
Start | Resume download queue. | |
Approve | If this method is not invoked during the script running, e-mail address will not be "approved" and will not be added to the list of addresses found. |
Limitations
Please note that JScript program is executed for each new address found. If your program is using "heavy" ActiveX objects, this might result in serious performance problems due to tough usage of CPU resources and to insufficient RAM available. As addresses found are being processes one by one in one stream, use of slow objects and agorythm might affect scan speed negatively.
Please note that creating ActiveX components from script is not permitted in unregistered copy of Emex 3.
Program Examples
Example 1. A program that doesn't allow adding addresses with mailboxes postmaster, webmaster and info to the list.
var vMailBox = emex3.GetEmailUser(emex3.DataField(0)); if (vMailBox != "webmaster" && |
Example 2. A program that doesn't allow addings addresses that contain the word SPAM in the owner's name, e-mail address or web-page address. Regular expression is used for keyword search.
var re = "/spam/i"; |
Example 3. A program approves only addresses with mail domains listed in C:\domains.txt file. The example will work in registered Advanced Email Extractor copy. Also, domains.txt file of the following format must be created in the root directory on C:
mail.com aol.com email.com microsoft.com altavista.net |
Each string must contain only one domain, with no spaces or tabs around. With the data file shown above, the program will approve addresses test@mail.com, john@aol.com etc.
Program code:
var fs, f, s, domain; fs = new ActiveXObject("Scripting.FileSystemObject"); f = fs.OpenTextFile("C:\\domains.txt", 1); domain = emex3.GetEmailDomain(emex3.DataField(0));; domain = domain.toLowerCase(); while (!f.AtEndOfStream) { s = f.ReadLine(); if (s == domain) { emex3.Approve(); break; } } f.Close(); |
Example 4. A program approves only actually existing addresses. Address is checked with Advanced Maillist Verify, you must have version 3.0 or newer. The example will work only in registered copy of Advanced Email Extractor. Please note that checking an address will take up to one minute, Advanced Email Extractor will freeze during the check; the program will not approve addresses which check failed (e.g., recipient's mail server was unavailable), though they might exist.
var st, amv; amv = new ActiveXObject('AdvancedMaillistVerify.EmailVerifier'); if (amv) { amv.Email = emex3.DataField(0); do { st = amv.Status; amv.Sleep = 300; } while (st != 3); if (amv.Result == 0) { // Email is exist emex3.Approve(); } amv = ""; } |
Example 5. The program checks whether there is such address in D:\list.xls document, adds new addresses into the document and approves them. The example will work provided document D:\list.xls exists, Microsoft Excel is installed on the computer and Emex 3 copy is registered.
var f = "D:\\list.xls"; var xl = new ActiveXObject("Excel.Application"); if(xl) { var wb = xl.Workbooks.Open(f); if(wb) { var ws = wb.Worksheets(1); var item = ws.Columns(1).Find(emex3.DataField(0)); if(!item) { var cnt = ws.Rows.Count; var idx = 1; while(idx < cnt) { if(ws.Cells(idx, 1).Value == null) break; idx++; } ws.Cells(idx, 1) = emex3.DataField(0); aee.Approve(); } wb.Close(true); } } |
Example 6. How to add only Spanish (.es) emails to list?
var domain = emex3.GetEmailDomain(emex3.DataField(0)); if(domain.substring(domain.length-3,domain.length)=='.es') |
Example 7. How to add emails from Spanish sites (.es) only to list?
if(emex3.URL.match('.es/')!=null ) |