CCCPaste

wsf_CONVERT-MGS-TO-TXT

<job id="msg_to_txt">
<script language="VBScript">

Dim fso, shell, folderPath, outputPath, file, msg, txtFile, baseName
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")

' Current working directory (pwd)
folderPath = shell.CurrentDirectory & "\"

' Output folder inside pwd
outputPath = folderPath & "txt_out\"

' Create output folder if missing
If Not fso.FolderExists(outputPath) Then
fso.CreateFolder(outputPath)
End If

Set outlook = CreateObject("Outlook.Application")

For Each file In fso.GetFolder(folderPath).Files
If LCase(fso.GetExtensionName(file.Name)) = "msg" Then

Set msg = outlook.CreateItemFromTemplate(file.Path)
baseName = fso.GetBaseName(file.Name)

Set txtFile = fso.CreateTextFile(outputPath & baseName & ".txt", True)
txtFile.Write msg.Body
txtFile.Close

End If
Next

</script>
</job>