Jump to content
Sign in to follow this  
dabus

Reading ansi/binary

Recommended Posts

Hallo all,

I would like to read the first lines from outlook-msg-files to get the date when the original message was sent.

The only problem I have is that I don't get the data as I can see it in scite.

The line where the information is located in is partly binary nonsense and partly clear ansi.

Anyone got an idea how to read this line correctly? I tested FileOpen with all parameters, but it's not of any success.

Searched some time but didn't get what I needed.

The output of scite is attached.

Any idea how to get these lines?

THX.

post-3338-1197895163_thumb.jpg

Share this post


Link to post
Share on other sites

Hallo all,

I would like to read the first lines from outlook-msg-files to get the date when the original message was sent.

The only problem I have is that I don't get the data as I can see it in scite.

The line where the information is located in is partly binary nonsense and partly clear ansi.

Anyone got an idea how to read this line correctly? I tested FileOpen with all parameters, but it's not of any success.

Searched some time but didn't get what I needed.

The output of scite is attached.

Any idea how to get these lines?

THX.

Are you opening the actual data file directly from AutoIT, or going through the Outlook object (hint) to access the data?

Post some code on what you've attempted so far.

Share this post


Link to post
Share on other sites

I don't know outlook com/vba. So I open the actual msg-file (it's called outlook-element on my pac on my computer).

It' just that I discovered the string right in the picture I attached to the first post. Since that'd be all I need, I thought I'd do a fileopen>filereadline>If StringInStr() ExitLoop> Stringslit>whatsoever to get the string that represents the time the mail was sent.

Since it all failed (and it's really just filereadline until I get the keyword), I'm not able to give you any working code -- you could as well use the filereadline-example :) .

I just thought anyone could give me a hint on fileopen/handling binary files to get this string. Maybe I should read binary and translate to ansi somehow...

Share this post


Link to post
Share on other sites

Anyone?

I know that I don't give you msg-files, but you may create on by dragging mails out of your outlook-window (if you have one at hand - I don't have right now). You could see my problem right away.

Sorry for being persistent, but it kind of "burns under my fingernails".

Edited by dabus

Share this post


Link to post
Share on other sites

You can do this to get the binary cleanly:

$sFile = "C:\Temp\MyMessage.msg"
$hFile = FileOpen($sFile, 16) ; 16 = binary
$binData = FileRead($hFile, 1024) ; read first 1KB
FileClose($hFile)
ConsoleWrite("Debug: First 1KB = " & $binData & @LF)

After that, you'll have to figure out how to interpret what you've got.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I opened the .msg file in SciTe and I could have saved the file as a .txt file. Try to automate that process or just use FileMove to rename the file with a .txt extension if necessary, and then open the file with FileOpen using the function StringInStr() to look for the line that begins "Date: ", removing from the string all that isn't on that line.

Share this post


Link to post
Share on other sites

@PsaltyDS: Yeah, I did that yesterday afternoon, but I got the knot in my head untied tonight.

I just have to do:

$sFile = "D:\Temp\Outlook\X.msg"
$hFile = FileOpen($sFile, 4)
$binData = FileRead($hFile, 20480)
FileClose($hFile)
$startdef=StringTrimLeft(Binary('p=exchange-name;l='), 2)
$enddef=StringTrimLeft(Binary('Z-'), 2)
$binData=StringTrimLeft($binData, StringInStr($binData, $startdef)+StringLen($startdef)-1)
$binData=StringLeft($binData, StringInStr($binData, $enddef)-1)
ConsoleWrite(BinaryToString('0x'&$binData) & @LF)

The output is just what I wanted. Basicly, I just convert the strings I need to search for into binary format, cut the strings at the correct position, convert the rest into a string again and I'm done.

It's good to know that I can handle that kind of files, too. Thx.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...