File Stream issues

I am trying to write a script triggered from an Outlook email to parse the email (as a text file) and then update an excel spreadsheet with specific data extracted from the email. The email is a form email delineated by a "/" for field breaks and "//" for end of line. However, when I create a text stream to read in the data, the returned string does not include these delineations. Here is a copy of the code I am currently using to open and read the file. I don't want to open the entire email as a new workbook, so I can't use the workbook function.

Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile("file.txt", ForReading, TristateTrue)

check = True
Do
s = ts.Readline
endlinepos = InStr(s, "//")
Do While endlinepos = 0
tempstr = ts.Readline
s = s + tempstr
endlinepos = InStr(s, "//")
Loop

tempstr = Mid$(s, 1, endlinepos - 1)
s = Mid$(s, endlinepos + 2, Len(s) - endlinepos - 2)

ActiveCell.FormulaR1C1 = tempstr
ActiveCell.Offset(1, 0).Activate

When I debug this, I notice all instances of "/" have been removed from the string. I know this is normally the signaler for a special char, but how can I make sure the text stream sees this

Also if anyone has any suggestions for how to pass an argument in a script call FROM OUTLOOK RULES, I would appreciate it.

Thanks for the help.



Answer this question

File Stream issues