RIAS
asked on
Saving .msg files to .doc +vb6.0
Hi,
Can anyone please suggests on how can I save .msg files to .doc +vb6.0
Can anyone please suggests on how can I save .msg files to .doc +vb6.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
THe problem is I have .msg files in folder so not using outlook.exe directly..any suggestions on objMessage.SaveAs "Some File Name", olDoc
Cheers
THe problem is I have .msg files in folder so not using outlook.exe directly..any suggestions on objMessage.SaveAs "Some File Name", olDoc
Cheers
ASKER
Hi tbsgad,
Can you please copy and paste the code in here as cannot access this url ..security issue
Cheers
Can you please copy and paste the code in here as cannot access this url ..security issue
Cheers
Open the message in Outlook using the code I posted to your other question, then use the command above to save to .doc format. Unless you are going to learn enhanced MAPI programming, then the only way I know of to read a .msg file is using Outlook. There may be 3rd-party programs that use enhanced MAPI to read .msg files without Outlook, the one Gary linked to appears to require Outlook, but I'm not familiar with any.
ASKER
oki mate will try .....
ASKER
Hi,
Tried it but it doesnt convert it to doc format it saves it as file type
Code used:
olkMsg.SaveAs Foldername & olkMsg.Subject, olDoc
Am I going wrong somewhere?
Tried it but it doesnt convert it to doc format it saves it as file type
Code used:
olkMsg.SaveAs Foldername & olkMsg.Subject, olDoc
Am I going wrong somewhere?
Sorry, typo. I omitted the extension. Use this instead
olkMsg.SaveAs Foldername & olkMsg.Subject & ".doc", olDoc
olkMsg.SaveAs Foldername & olkMsg.Subject & ".doc", olDoc
ASKER
Hi,
Sorry no luck ..it errrors
Sorry no luck ..it errrors
What's the error?
ASKER
Hi,
It justs jumps out of the function on that linedon't really know
Cheers
It justs jumps out of the function on that linedon't really know
Cheers
So it just stops running and doesn't display any error messages?
ASKER
Yup..it jumps out of the function
ASKER
Hi,
Manage to save it in txt ile thats fine..you r previous solution did work.thanks for that.
Now I need to set a printer which is different from default printer how do i set it and get the .msg file printed with all its attachments in vb.
I tried your solution on other qustions:
Public Sub PrintMessagesAndAttachment s()
Dim objFSO As Object, _
objFolder As Object, _
objFile As Object, _
objTempFolder As Object, _
olkMsg As Object, _
olkAttachment As Object
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objTempFolder = objFSO.GetSpecialFolder(2)
'Change the folder path on the following line'
Set objFolder = objFSO.GetFolder("C:\eeTes ting")
For Each objFile In objFolder.Files
If objFSO.GetExtensionName(ob jFile.Path ) = "msg" Then
ShellExecute 0&, "print", objFile.Path, 0&, 0&, 0&
Set olkMsg = Application.CreateItemFrom Template(o bjFile.Pat h)
For Each olkAttachment In olkMsg.Attachments
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.fileName
ShellExecute 0&, "print", objTempFolder & "\" & olkAttachment.fileName, 0&, 0&, 0&
Next
End If
Next
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
Set objTempFolder = Nothing
Set olkMsg = Nothing
Set olkAttachment = Nothing
End Sub
but it errors on the line
Set olkMsg = Application.CreateItemFrom Template(o bjFile.Pat h)
Should I post another question for this?
Cheers
Manage to save it in txt ile thats fine..you r previous solution did work.thanks for that.
Now I need to set a printer which is different from default printer how do i set it and get the .msg file printed with all its attachments in vb.
I tried your solution on other qustions:
Public Sub PrintMessagesAndAttachment
Dim objFSO As Object, _
objFolder As Object, _
objFile As Object, _
objTempFolder As Object, _
olkMsg As Object, _
olkAttachment As Object
Set objFSO = CreateObject("Scripting.Fi
Set objTempFolder = objFSO.GetSpecialFolder(2)
'Change the folder path on the following line'
Set objFolder = objFSO.GetFolder("C:\eeTes
For Each objFile In objFolder.Files
If objFSO.GetExtensionName(ob
ShellExecute 0&, "print", objFile.Path, 0&, 0&, 0&
Set olkMsg = Application.CreateItemFrom
For Each olkAttachment In olkMsg.Attachments
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.fileName
ShellExecute 0&, "print", objTempFolder & "\" & olkAttachment.fileName, 0&, 0&, 0&
Next
End If
Next
Set objFSO = Nothing
Set objFolder = Nothing
Set objFile = Nothing
Set objTempFolder = Nothing
Set olkMsg = Nothing
Set olkAttachment = Nothing
End Sub
but it errors on the line
Set olkMsg = Application.CreateItemFrom
Should I post another question for this?
Cheers
No need to open another question. Here's the code for printing to a specific printer.
Sub PrintAttachmentToSpecificPrinter(Item As Outlook.MailItem)
Dim wshNet As Object, _
strCurrentDefault As String, _
objFSO As Object, _
objTempFolder As Object, _
olkAttachment As Outlook.Attachment
strCurrentDefault = GetDefaultPrinter()
Set wshNet = CreateObject("Wscript.Network")
'Change the printer name on the next line to that of the printer you want attachments printed to
wshNet.SetDefaultPrinter "Microsoft Office Document Image Writer"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTempFolder = objFSO.GetSpecialFolder(2)
For Each olkAttachment In Item.Attachments
olkAttachment.SaveAsFile objTempFolder & "\" & olkAttachment.FILENAME
ShellExecute 0&, "print", objTempFolder & "\" & olkAttachment.FILENAME, 0&, 0&, 0&
Next
wshNet.SetDefaultPrinter strCurrentDefault
Set wshNet = Nothing
Set objFSO = Nothing
Set objTempFolder = Nothing
Set olkAttachment = Nothing
End Sub
Function GetDefaultPrinter() As String
Dim strPrinter As String, _
intReturn As Integer
strPrinter = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", strPrinter, Len(strPrinter))
If intReturn Then
strPrinter = UCase(Left(strPrinter, InStr(strPrinter, ",") - 1))
End If
GetDefaultPrinter = strPrinter
End Function
ASKER
Cheers mate
http://www.bestshareware.net/download/outlook-eml-and-msg-converter.htm
Good Luck!
Gary