Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.msg files and vbscript 1

Status
Not open for further replies.

Stunner01225

Technical User
Joined
Mar 13, 2002
Messages
150
Location
GB
Hi,
Anybody know how to get the built in properties for a .msg file. I have many .msg files saved into a directory for safe keeping outside outlook, but my getObject command is returning an error. Can anybody tell me why?
 
What is the code that you are using?

[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
but my getObject command is returning an error
Any chance you could post the error message ?
Can anybody tell me why?
I guess .msg files aren't registered.
To be sure, in an explorer windows, double-click a such one file to see if an application is defined for it.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
They open in outlook. and the error message is Active X cannot create Getobject...
 
What happens when, in an explorer windows, you double-click a .msg file ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hello stunner01225,

Depending on what you want to extract, here is how you do it.
Code:
const olFolderInbox=6
msgfilespec="d:\test\abc.msg"  '<<<input/edit

set oOL=createobject("outlook.application")
set oNS=oOL.GetNameSpace("MAPI")
oNS.logon
set oInBox=oNS.GetDefaultFolder(olFolderInbox)

set oMsg=oOL.CreateItemFromTemplate(msgfilespec, oInbox)
oMsg.Save   'if you do not need .size, you can bypass this step
with oMsg
    wscript.echo .subject & vbcrlf & .size & vbcrlf & .creationtime & vbcrlf & .unread
end with
set oMsg=nothing
oNS.logoff		'can spare no problem
oOL.quit
set oNS=nothing : set oOL=nothing
regards - tsuji
 
Spot on again tsuji, I don't know how you do it.
Thanks once again for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top