
보낸 항목 폴더에 규칙을 실행하기 위한 매크로를 생성하려고 합니다. 그러나 "개체 변수 또는 블록 변수가 설정되지 않음" 별표가 계속 표시됩니다. 저는 이 분야의 초보자이므로 도움을 주시면 감사하겠습니다.
또 다른 실패한 시도가 있습니다.
비공개 하위 Application_Startup() runRulesOnSentMailFolder End Sub
Sub runRulesOnSentMailFolder() Dim st As Outlook.Store Dim myRules As Outlook.Rules Dim rl As Outlook.Rule Dim count As Integer Dim ruleList As String Dim rulePrefix As String Dim ruleFolder As Long
'
Dim outlookApp As Outlook.Application
Dim objNS As NameSpace
ruleFolder = olFolderSentMail
rulePrefix = "SENT_Mail_"
Set objNS = Application.GetNamespace("MAPI")
Set objSentmailfolder = objNS.GetDefaultFolder(ruleFolder)
' get default store (where rules live)
Set st = Application.Session.DefaultStore
' get rules
Set myRules = st.GetRules
' myRules의 각 rl에 대해 모든 규칙을 반복합니다. ' 받은 편지함 규칙이고 규칙 이름 접두사가 일치하는지 확인합니다. If rl.RuleType = olRuleReceive And Left(rl.Name, Len(rulePrefix)) = rulePrefix Then
' if so, run it
rl.Execute ShowProgress:=True, Folder:=objSentmailfolder
count = count + 1
ruleList = ruleList & vbCrLf & rl.Name
End If
****Next****
' tell the user what you did
ruleList = "These rules were executed against the folder: " & objSentmailfolder.Name & vbCrLf & ruleList
MsgBox ruleList, vbInformation, "Macro: runRulesOnSentMailFolder"
Set rl = Nothing
Set st = Nothing
Set myRules = Nothing
Set objSentmailfolder = Nothing
Set objNS = Nothing
서브 끝