How to create a script to move the current active email address to the inbox in another folder in Outlook 2007

I sometimes get letters that I want to save, but moving them to the appropriate folder can be painful. How can I execute a script that will be moved (for example, using CSv) of the email that I am viewing, for example, in a specific folder called a "buffer"?

I am using Outlook 2007.

thanks.


EDIT: There are no criteria that can be created to automate this process, for example, using a rule. it’s just a challenge to the court that I make when I look at it.

+3
source share
3

, .

Sub MoveSelectedMessagesToFolder()
'Originally written by Chewy Chong
'Taken from http://verychewy.com/archive/2006/04/12/outlook-macro-to-move-an-email-to-folder.aspx
'Thanks Chewy!
'Ken
On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

    Set objNS = Application.GetNamespace("MAPI")
    Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
    'For the "Item" portion, I used the name of the folder exactly as it appear in the ToolTip when I hover over it.
    Set objFolder = objNS.Folders.Item("Personal Folders").Folders.Item("Buffer")

'Assume this is a mail folder

    If objFolder Is Nothing Then
        MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
    End If

    If Application.ActiveExplorer.Selection.Count = 0 Then
        'Require that this procedure be called only when a message is selected
        Exit Sub
    End If
    For Each objItem In Application.ActiveExplorer.Selection
        If objFolder.DefaultItemType = olMailItem Then
            If objItem.Class = olMail Then
                objItem.Move objFolder
            End If
        End If
    Next
+2

.

objFolder Nothing, . , For Each , .

Sub MoveSelectedMessagesToFolder()
  Dim objNS As Outlook.NameSpace
  Dim objFolder As Outlook.MAPIFolder
  Dim obj As Object
  Dim msg As Outlook.mailItem

  Set objNS = Application.GetNamespace("MAPI")
  On Error Resume Next
  Set objFolder = objNS.Folders.item("Personal Folders").Folders.item("Buffer")
  On Error GoTo 0

  If objFolder Is Nothing Then
    MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
    Exit Sub
  End If

  For Each obj In ActiveExplorer.Selection
    If TypeName(obj) = "MailItem" Then
      Set msg = obj
      msg.Move objFolder
    End If
  Next obj

End Sub
+5

, , , / / / .

Edit: If you do not want the / rule to not create a suitable rule, you can create a macro (Tools → Macro) to move it to a folder and then bind it to a shortcut.

+1
source

Source: https://habr.com/ru/post/1706831/


All Articles