6
전자 메일의 제목을 검사하는 Outlook 2010의 사용자 지정 규칙을 만들려고하고 있으며 정규식을 만들면 특정 폴더로 이동합니다. 내가 스크립트를 실행할 때 내가 노력하고 내가 메시지를 이동하려는 폴더에 대한 Outlook.Folder 객체를 얻을 때받는 메일 메시지를 특정 폴더로 이동하는 Outlook 2010 사용자 지정 VBA 스크립트
그러나 나는 다음과 같은 오류가 발생합니다 :
아래는 제가 이메일 제목을 확인하고 일치하는 경우 지정된 폴더로 메시지를 이동하기 위해 사용하고있는 VBA 스크립트 설정되지 않았습니다.런타임 오류 '91':
개체 변수 또는 With 블록 변수가
Sub MoveToETS(Item As Outlook.MailItem)
Dim Subject As String
Subject = Item.Subject
Dim FolderToMoveTo As Outlook.Folder
Set FolderToMoveTo = GetFolder("ETS")
If (CheckSubject(Subject, "^[Project|Bug] (\d+?) - \[[UPDATE|NEW|RESOLVED]\]")) Then
Item.Move (FolderToMoveTo)
End If
End Sub
Function CheckSubject(Subject As String, PatternToCheck As String)
Dim ObjRegExp As RegExp
Dim ObjMatch As Match
Set ObjRegExp = New RegExp
ObjRegExp.Pattern = PatternToCheck
If (ObjRegExp.Text(Subject) = True) Then
CheckSubject = True
End If
End Function
Function GetFolder(ByVal FolderName As String) As Outlook.Folder
Dim ObjFolder As Outlook.Folder
Set ObjFolder = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Folders("ETS")
GetFolder = ObjFolder
End Function