I have to run a vba script as a rule in Outlook that 1. "Catch" specific mail with attachment(Excel) 2. save this attachment as a file and do some changes in this file 3. send by email this "changed" file.
P.1 and P.2 I've already done, but I can't send and email. I try this simple code as a rule when I've got a message with specific words in subject run this script:
Sub sendemail()
Dim OutlApp As Object
On Error Resume Next
Set OutlApp = GetObject(, "Outlook.Application")<---use this instance of outlook
If Err Then
Set OutlApp = CreateObject("Outlook.Application")
IsCreated = True
End If
OutlApp.Visible = True
On Error GoTo 0
With OutlApp.CreateItem(0)
.To = "[email protected]"
.Subject = "test"
.Display
End With
Set OutlApp = Nothing
End Sub
when I run as a macro (F5) in VBA Project everything went OK, mail appears, but nothing happened when I run the rule. Any Ideas? regards,