March 7, 2002 at 4:26 am
Hi,
please can anybody help with this... I need to import the content of a mail message into a table. The format of the mail is any number of lines that are all the same number of characters. The way I'm trying to do it at the moment is with an Active X Script Task: I try to import the message into a continuous text stream and attempt (without success) to break it down into lines. What happens is that the first line is fine, but the second line has an extra character at the beginning, the third line two characters (the last two characters of the previous line), and so on.
set fso = CreateObject ("Scripting.FileSystemObject")
'this is the output file, the path is defined in a variable
set fsofile = fso.CreateTextFile(strFileOut, True)
'for the moment, I'm hardcoding the length of the string - one problem at a time
iDataLen = 62406
iLineStart = 1
'this is the length of the line
iLineLength = 117
while iLineStart < iDataLen
'strData is the content of the email
strLine = mid(strData, iLineStart, iLineLength)
iLineStart = iLineStart + iLineLength
fsofile.Write(strLine & chr(13) & chr(10))
wend
I tried adding and subtracting 1 or 2 from iLineStart (eg. iLineStart = iLineStart + iLineLength + 2, iLineStart = iLineStart + iLineLength -1...) but that doesn't make any difference.
What am I doing wrong????
Is there any other way of doing this? Is it possible to save the email directly into a text file and tidy it up with SQL (I'm a lot more comfortable with SQL than VB)?
Thanks in advance.
March 7, 2002 at 6:06 am
I don't think anything wrong with your code, sounds like you are off by one on the length of the "record". Are you accounting for a record delimiter of some sort? Here is a different way to write the same thing:
For J = 1 To Len(strData) Step iLineLength
Debug.Print J, Mid(strData, J, iLineLength)
Next
You're using VBScript so it doesn't matter, but if you were going to compile in VB you'd want to type your iDataLen as a long rather than an integer, so would be lDataLen. You'd also use the Mid$ version rather than Mid - faster when you know its a string.
Andy
March 7, 2002 at 6:12 am
Can you show where you pull the data in, I ran you snippit here and when I supply a large string myself I get no problems with the output. Want to see if anything happening before you get to here.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply