Hello,
I am new in VBA.
Can you help me with the following problem:
I need to copy and paste msg files from c:\msg\*.msg to Outlook 2007 folder (for example “for_send”)
I did it by copy function (see code below) but unfortunately outlook can't see it as mailitem.
Outlook also changes an icon of message into unread message.
When I do copy and paste – it works.
When I use attached macro – also works, but as mentioned before Outlook “does” something with msg file.
Can you tell me how to realize function copy and paste to work as doing it “by hand”?
Maybe completely different way… but how?
Yours faithfully,
Andrzej
Sub copy()
Dim inPath As String
Dim thisFile As String
Dim olApp As Outlook.Application
Dim msgFile As Object
Set olApp = CreateObject("Outlook.Application")
inPath = "C:\msg\"
thisFile = Dir(inPath & "\*.msg")
Do While thisFile <> ""
Set msgFile = olApp.CopyFile(inPath + thisFile, "for_send")
thisFile = Dir
Loop
End Sub
I am new in VBA.
Can you help me with the following problem:
I need to copy and paste msg files from c:\msg\*.msg to Outlook 2007 folder (for example “for_send”)
I did it by copy function (see code below) but unfortunately outlook can't see it as mailitem.
Outlook also changes an icon of message into unread message.
When I do copy and paste – it works.
When I use attached macro – also works, but as mentioned before Outlook “does” something with msg file.
Can you tell me how to realize function copy and paste to work as doing it “by hand”?
Maybe completely different way… but how?
Yours faithfully,
Andrzej
Sub copy()
Dim inPath As String
Dim thisFile As String
Dim olApp As Outlook.Application
Dim msgFile As Object
Set olApp = CreateObject("Outlook.Application")
inPath = "C:\msg\"
thisFile = Dir(inPath & "\*.msg")
Do While thisFile <> ""
Set msgFile = olApp.CopyFile(inPath + thisFile, "for_send")
thisFile = Dir
Loop
End Sub