
Estoy intentando crear una macro para ejecutar una regla en mi carpeta de elementos enviados. Pero sigo encontrando asteriscos "Variable de objeto o Con variable de bloque no configurada". Soy un novato en esto, por lo que se agradece cualquier ayuda.
Aquí hay otro intento fallido.
Sub privado Application_Startup() runRulesOnSentMailFolder End Sub
Sub runRulesOnSentMailFolder() Dim st como Outlook.Store Dim myRules como Outlook.Rules Dim rl como Outlook.Rule Dim count como entero Dim ruleList como cadena Dim rulePrefix como cadena 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
' itera todas las reglas para cada rl en myRules ' determina si es una regla de Bandeja de entrada y el prefijo del nombre de la regla coincide Si rl.RuleType = olRuleReceive And Left(rl.Name, Len(rulePrefix)) = rulePrefix Entonces
' 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
Subtítulo final