extracting emailadresses from logfile

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
matthiasR
Pro Scripter
Posts: 52
Joined: Tue Jan 20, 2004 3:45 pm
Location: Lübbecke, Germany

extracting emailadresses from logfile

Post by matthiasR » Fri Jul 21, 2006 3:52 pm

Hi,

i have to search serveral logfiles for emailadresses and put these emailadresses in a new text file. Btw: The logfiles contain information about non deliverable emails. The logfiles are all in the same folder.
How can this be done with MacroScheduler? The problem is that the lines in the logfiles are of different size, so there is no static place, where the email adresses can be found, becuase there are many reasons, why an email is not deliverable. I could read line by line, but how can i extract the emailadresse from each line. The other problem is: I have serveral logfiles and don´t want to specify each single file. I want macroscheduler to read all files (one after one of course) in a folder.

Any idea?

Best regards,

Matthias

matthiasR
Pro Scripter
Posts: 52
Joined: Tue Jan 20, 2004 3:45 pm
Location: Lübbecke, Germany

Post by matthiasR » Sat Jul 22, 2006 8:03 am

Does no one have an idea?

Please be assured, i am not planning to use it for any spamming.
I just have to correct our customer database and want this to be done automatically.

Best regards,

Matthias Rebbe

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Jul 22, 2006 8:28 am

You can use regular expressions. Try this example:

Code: Select all

VBSTART

Function GetEmailAddress(sLine)

  Dim oRegEx, sEmail
  Set oRegEx = CreateObject("VBScript.RegExp")
  oRegEx.Pattern = "[\w!#$%&'*+-./=?^`{|}~]+@[\w-.]+"
  Select Case oRegEx.Test(sLine)
    Case True sEmail = oRegEx.Execute(sLine)(0)
    Case Else sEmail = "No valid email address found."
  End Select
  GetEmailAddress = sEmail
End Function

VBEND

Let>line=From: "Smith, John" <john>
//Double quote quote marks for VBScript
StringReplace>line,","",line
VBEval>GetEmailAddress("%line%"),email
MessageModal>email
To read in the log files use GetFileList and Separate - see example in help file under topic GetFileList. For each log file use ReadLn in a loop - see example under ReadLn in help file. For each line in log file run the StringReplace line and the VBEval>GetEmailAddress ... line ...
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

matthiasR
Pro Scripter
Posts: 52
Joined: Tue Jan 20, 2004 3:45 pm
Location: Lübbecke, Germany

Post by matthiasR » Sun Jul 23, 2006 9:18 pm

Hi,

thank you very much. That helps.

Best regards,

Matthias

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts