Hi all,
I have a vbscript that renames msg files to Sender - Subject. What I am looking to do is change the modified date of the msg file to be the received date of the email. The thing is I could swear the following code was doing this last week. Upon double checking this week the name was changing but not the modified date. Any help would be great as this is my first vbscript.
[CODE=vb]On Error Resume Next
Dim olkApp, olkMessage, objFSO, objFile, varFile, varNewFileName
Set olkApp = GetObject(,"Out look.Applicatio n")
If TypeName(olkApp ) <> "Applicatio n" Then
Set olkApp = CreateObject("O utlook.Applicat ion")
End If
Set objFSO = CreateObject("S cripting.FileSy stemObject")
For Each varFile In WScript.Argumen ts
Set olkMessage = olkApp.CreateIt emFromTemplate( varFile)
varNewFileName = ReplaceIllegalC haracters(olkMe ssage.SenderNam e & "-" & olkMessage.Subj ect) & ".msg"
Set objFile = objFSO.GetFile( varFile)
objFile.Name = varNewFileName
ModFileDT varNewFileName, olkMessage.Rece ivedTime
Next
Set objFile = Nothing
Set objFSO = Nothing
Set olkMessage = Nothing
Set olkApp = Nothing
WScript.Quit
Function ReplaceIllegalC haracters(strSu bject)
Dim strBuffer
strBuffer = Replace(strSubj ect, ":", "")
strBuffer = Replace(strBuff er, "\", "")
strBuffer = Replace(strBuff er, "/", "")
strBuffer = Replace(strBuff er, "?", "")
strBuffer = Replace(strBuff er, Chr(34), "'")
strBuffer = Replace(strBuff er, "|", "")
ReplaceIllegalC haracters = strBuffer
End Function
Sub ModFileDT (strFileName, DateTime)
Dim objShell, objFolder
Set objShell = CreateObject("S hell.Applicatio n")
objFolder.Items .Item(strFileNa me).ModifyDate = DateTime
End Sub[/CODE]
Cheers
Strychtur
I have a vbscript that renames msg files to Sender - Subject. What I am looking to do is change the modified date of the msg file to be the received date of the email. The thing is I could swear the following code was doing this last week. Upon double checking this week the name was changing but not the modified date. Any help would be great as this is my first vbscript.
[CODE=vb]On Error Resume Next
Dim olkApp, olkMessage, objFSO, objFile, varFile, varNewFileName
Set olkApp = GetObject(,"Out look.Applicatio n")
If TypeName(olkApp ) <> "Applicatio n" Then
Set olkApp = CreateObject("O utlook.Applicat ion")
End If
Set objFSO = CreateObject("S cripting.FileSy stemObject")
For Each varFile In WScript.Argumen ts
Set olkMessage = olkApp.CreateIt emFromTemplate( varFile)
varNewFileName = ReplaceIllegalC haracters(olkMe ssage.SenderNam e & "-" & olkMessage.Subj ect) & ".msg"
Set objFile = objFSO.GetFile( varFile)
objFile.Name = varNewFileName
ModFileDT varNewFileName, olkMessage.Rece ivedTime
Next
Set objFile = Nothing
Set objFSO = Nothing
Set olkMessage = Nothing
Set olkApp = Nothing
WScript.Quit
Function ReplaceIllegalC haracters(strSu bject)
Dim strBuffer
strBuffer = Replace(strSubj ect, ":", "")
strBuffer = Replace(strBuff er, "\", "")
strBuffer = Replace(strBuff er, "/", "")
strBuffer = Replace(strBuff er, "?", "")
strBuffer = Replace(strBuff er, Chr(34), "'")
strBuffer = Replace(strBuff er, "|", "")
ReplaceIllegalC haracters = strBuffer
End Function
Sub ModFileDT (strFileName, DateTime)
Dim objShell, objFolder
Set objShell = CreateObject("S hell.Applicatio n")
objFolder.Items .Item(strFileNa me).ModifyDate = DateTime
End Sub[/CODE]
Cheers
Strychtur
Comment