Answer the question
In order to leave comments, you need to log in
Outlook, VBS: Copying messages - how to kill an alert?
Outlook 2010. A simple VBS script copies last year's messages from one folder (located in a mailbox on the Exchange server) to another (located in a local pst-shnik).
Message keeps coming up
The userform cannot be opened. An Outlook form will be used instead. The object does not support the requested action.and, until you poke it, the script hangs on the line with copying.
Set oOApp = CreateObject("Outlook.Application")
Set oSrcFolder = oOApp.GetNamespace("MAPI").Folders.Item(folder0).Folders.Item(subfolder01)
Set oDestFolder = oOApp.GetNamespace("MAPI").Folders.Item(folder1).Folders.Item(subfolder11)
On Error Resume Next
For Each Item In oSrcFolder.Items
If Year(Item.CreationTime) < 2016 Then
WScript.Echo Item.CreationTime
Item.Copy.Move oDestFolder
End If
Next
Answer the question
In order to leave comments, you need to log in
Dopetril:
The thing is that in the mailbox, in addition to normal messages, there are all sorts of crap (for example, reviews). When Outlook, prompted by the script, comes to copying such messages, then it issues the aforementioned alert "Userform cannot be opened..." .
How to get rid of these annoying messages and ensure trouble-free copying? - obviously copy only "normal" messages, skipping everything else. You can distinguish ordinary messages from any crap by analyzing the name of the message class. In this case, the class name must begin with the text "IPM.Note":
If Left(Item.MessageClass, 8) = "IPM.Note" Then
Item.Copy.Move oDestFolder
End If
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question