team2005
asked on
Convert VBA from outlock to vb script
Hi!
In outlock you have a function to save email as MSG file.
I can make a function in vba in outlock for this job:
Dim Message As MailItem
Dim t1 As Integer
Dim s1 As String
Set myNameSpace = Application.GetNamespace(" MAPI")
'Set myJobber = myNameSpace.GetDefaultFold er(olFolde rJobber)
Set myInboks = myNameSpace.GetDefaultFold er(olFolde rInbox).Fo lders("tes t1")
t1 = 1
s1 = "Fil"
For Each Message In myInboks.Items
s1 = s1 & Str(t1)
Message.SaveAs "C:\tt1\" & s1 & ".msg", olMSG
s1 = Message.MarkForDownload
s1 = "Fil"
t1 = t1 + 1
Next Message
But need to have the same function in VB.SCRIPT
Is this possible in VB.SCRIPT ?
Please help ASAP
In outlock you have a function to save email as MSG file.
I can make a function in vba in outlock for this job:
Dim Message As MailItem
Dim t1 As Integer
Dim s1 As String
Set myNameSpace = Application.GetNamespace("
'Set myJobber = myNameSpace.GetDefaultFold
Set myInboks = myNameSpace.GetDefaultFold
t1 = 1
s1 = "Fil"
For Each Message In myInboks.Items
s1 = s1 & Str(t1)
Message.SaveAs "C:\tt1\" & s1 & ".msg", olMSG
s1 = Message.MarkForDownload
s1 = "Fil"
t1 = t1 + 1
Next Message
But need to have the same function in VB.SCRIPT
Is this possible in VB.SCRIPT ?
Please help ASAP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"Here ---> End Message"
Sorry, I don't see that anywhere in the code. Can you give me a line number?
Sorry, I don't see that anywhere in the code. Can you give me a line number?
ASKER
Hi!
Sorry , my mistace
Next Message ---> Line 19
Sorry , my mistace
Next Message ---> Line 19
Well, that's your code. I just made the changes necessary to run from VBScript. I made no change to that line nor to the loop it's a part of. If it fails in VBScript, then it should fail int he VBA original too. That aside, I don't see why it should fail. That type of FOR ... NEXT loop should never fail so long as no items are being removed from the original collection. I don't see any Delete or Move commands, so that shouldn't be the case.
ASKER
Hi!
When i tryed your code in VBA in outlock.
Its working just fine, so what is the different
using VB.SCRIPT ???
Strange....
When i tryed your code in VBA in outlock.
Its working just fine, so what is the different
using VB.SCRIPT ???
Strange....
Good question. Try taking Message off of line 19, leaving just Next.
ASKER
Hi!
Tryed to remove Message like you say.
And now its making the files.
But when i dobbelclick the created file, it do not show this email
in outlock. But give me a message like:
Cannot open file <filename> The file may not exist , you may not have permission to open it, or it may be
open in another program. Right click the folder that contains the file , and then click Properties to check
your permissions for the folder.
Why dosent this work, when the same code work in outlock ???
Very very strange
Tryed to remove Message like you say.
And now its making the files.
But when i dobbelclick the created file, it do not show this email
in outlock. But give me a message like:
Cannot open file <filename> The file may not exist , you may not have permission to open it, or it may be
open in another program. Right click the folder that contains the file , and then click Properties to check
your permissions for the folder.
Why dosent this work, when the same code work in outlock ???
Very very strange
Ummm, I think I missed something. Add this line to the top of the file.
Const olMSG = 3
Const olMSG = 3
ASKER
Hi!
YES, its working now.
Thank you so mutch for BIG help
YES, its working now.
Thank you so mutch for BIG help
ASKER
Thanks
Cool. Glad I could help.
ASKER
Tryed your code, but get a error message:
Error message is : Expected end of statment
Here ---> End Message (gives the error)
???