새 전자 메일이받은 편지함에서 수신 될 때 파이썬 스크립트가 실행될 전망에 트리거를 만들어야합니다. 나는이 링크를 참조 않았다 How do I trigger a macro to run after a new mail is received in Outlook?를 다음과 같은 스크립트를 작성했습니다 :Outlook에서 새 전자 메일 수신시 스크립트 실행
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
default local Inbox
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub test_macro(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
If TypeName(item) = "MailItem" Then
Set Msg = item
Ret_Val = Shell("python <path-of-python-script>")
Debug.Print "Value: ", Ret_Val
If Ret_Val <> 0 Then
MsgBox "Couldn't run python script", vbOKOnly
End If
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
의 어떤 오류를 포기하지 않을하지만 때문에 몇 가지 이유에 내 파이썬 스크립트가 실행되지는 않지만. 이에 따라 Outlook에서 매크로 설정을 구성했으며 사용 가능한 문서에 따라 새로운 규칙을 만들었습니다. 그러나 여전히 의도 된 결과를 얻을 수는 없습니다.
도움을 주시면 감사하겠습니다.