This repository has been archived by the owner on Jan 26, 2019. It is now read-only.
forked from rumpelstiel/rumpel-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlanetPress-EMF-MailAdressFetcher_v2.vbs
111 lines (97 loc) · 3.93 KB
/
PlanetPress-EMF-MailAdressFetcher_v2.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
' Get Mail Adress
' from EMF Spool
'
' rewrite of Spoolfile-Checker script
'
'
'
'
Watch.Log "***********************************************************************", 4
Watch.Log "**** START Get Mail from Spool ****", 4
Watch.Log "***********************************************************************", 4
Dim JobFileName 'String JobFile Name (Spoolfile)
JobFileName = ""
Dim sJobFile 'String JobFile Data
sJobFile = ""
Dim sParsingColor 'Special Color
sParsingColor = "1 0.996 0.992 1 scol" 'Special EMF Command for Set Color to 255, 254, 253
Dim iParseStartLine ' Parser StartLine
iParseStartLine = 0
Dim iParseStopLine ' Parser StopLine
iParseStopLine = 0
Dim sTempMailGarbage 'Garbage .. pre Parsing
sTempMailGarbage = ""
Dim sMailAdress 'when "PRINT" then no Mail Adress found
sMailAdress = "PRINT"
Dim sMailStartTag
sMailStartTag = "#email#"
Dim sMailEndTag
sMailEndTag = "#/email#"
Dim iEMFRowNum
iEMFRowNum = 0
' FileSystemObject-Objekt erzeugen
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Dateiname des Spoolfiles auslesen
JobFileName = Watch.GetJobFileName
' Datei öffnen (1, zum Lesen)
Set oFileStream = oFSO.OpenTextFile(JobFileName, 1)
' Inhalt als String komplett einlesen
sJobFile = oFileStream.ReadAll
' Datei können wir jetzt schließen
oFileStream.Close
' Handles zerstören
Set oFileStream = Nothing
Set oFSO = Nothing
' Split Files zu Array Lines
arrJobFile = Split(sJobFile, chr(10)) 'Split by LineFeed
sJobFile = "" 'CleanUp
' nach sParsingColor suchen (spezielle Farbe für Parsing)
For ItemIndex = 0 To UBound(arrJobFile)
If InStr(arrJobFile(ItemIndex), sParsingColor) > 0 Then
Watch.Log ItemIndex & " .. found ParserColor .." , 4
'Watch.Log ItemIndex & " Line: " & arrJobFile(ItemIndex) , 4
iParseStartLine = ItemIndex
Exit For
End If
Next
' nach ColorChange suchen.. = Ende Parsing
For ItemIndex = iParseStartLine + 1 To UBound(arrJobFile)
If InStr(arrJobFile(ItemIndex), "scol") > 0 Then
Watch.Log ItemIndex & " .. found scol, stop parsing there .." , 4
'Watch.Log ItemIndex & " Line: " & arrJobFile(ItemIndex) , 4
iParseStopLine = ItemIndex - 1
Exit For
End If
Next
'Parse Text in Klammern
If iParseStartLine > 0 Then
For ItemIndex = iParseStartLine To iParseStopLine
If InStr(arrJobFile(ItemIndex), "(") > 0 Then
iStartParse = InStr(arrJobFile(ItemIndex), "(") + 1
iStopParse = InStr(arrJobFile(ItemIndex), ")")
iLengthParse = iStopParse - iStartParse
sTempParse = Mid(arrJobFile(ItemIndex), iStartParse, iLengthParse)
sTempMailGarbage = sTempMailGarbage & sTempParse
'Watch.Log ItemIndex & " garbage: " & sTempParse , 4
End If
Next
End If
Watch.Log "Garbage: " & sTempMailGarbage , 4
' Auslesen der Mail Tags aus dem Garbage
If InStr(sTempMailGarbage, "#email#") > 0 Then
If InStr(sTempMailGarbage, "#/email#") > 0 Then
iStartPos = InStr(sTempMailGarbage, "#email#") + 7
iEndPos = InStr(sTempMailGarbage, "#/email#")
iLenghtPos = iEndPos - iStartPos
tempMail = Mid(sTempMailGarbage, iStartPos, iLenghtPos)
tempMail = Trim(tempMail)
sMailAdress = tempMail
End If
End If
Watch.SetVariable "mailAdress", sMailAdress
Watch.Log "Parsed: " & sMailAdress , 4
' 1 Sekunde warten
Watch.Sleep 1000
Watch.Log "***********************************************************************", 4
Watch.Log "**** ENDE Get Mail from Spool ****", 4
Watch.Log "***********************************************************************", 4