Howto: Get the MIME of an item from a mailbox.
This VBSript sample uses WebDAV to read the mime of a message item and write it to disk.
dim sHREF
dim sUserName
dim sPassword
dim sResponse
dim HttpWebRequest
dim sHREF
dim sUserName
dim sPassword
dim sResponse
dim HttpWebRequest
sHREF = "https://myserver/exchange/Administrator/Inbox/testabcd.EML" ' TODO: change as needed
sUserName = "Administrator" ' TODO: change - needed for Basic Authentication
sPassword = "test" ' TODO: change - needed for Basic Authentication
set HttpWebRequest = CreateObject("microsoft.xmlhttp")
' TODO: If Windows authentication used, use the line below
'HttpWebRequest.Open "GET", sHREF, False
' TODO: If Basic authentication used, use the line below
HttpWebRequest.Open "GET", sHREF, False, sUserName, sPassword
HttpWebRequest.setRequestHeader "Content-type:", "text/xml" ' Comment out if not going to Exchange
HttpWebRequest.setRequestHeader "Translate:", "f" ' Comment out if not going to Exchange
HttpWebRequest.Send
sResponse = HttpWebRequest.ResponseText ' Returns as text
Set HttpWebRequest = Nothing
'wscript.echo sResponse ' write to screen
WriteFileText "c:\test.txt", sResponse ' write to file
Private Sub WriteFileText(sFilePath, sText)
Dim objFSO 'As FileSystemObject
Dim objTextFile 'As Object
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(sFilePath, True)
' Write a line.
objTextFile.Write (sText)
objTextFile.Close
'objTextFile.Close
End Sub