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
extracting emailadresses from logfile
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You can use regular expressions. Try this example:
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 ...
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
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?