S
S
Sergey2016-01-19 11:43:05
Outlook
Sergey, 2016-01-19 11:43:05

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.
What kind of nonsense? What nah "user form"?
And, in fact, the main question: How to prevent the appearance of this fucking message?
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

1 answer(s)
S
Sergey, 2016-01-20
@mozers

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 question

Ask a Question

731 491 924 answers to any question