vb.net

[VBA] OUTLOOK 偵測主旨做事情

Private WithEvents myOlItems 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”)
Set myOlItems = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub myOlItems_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
If TypeName(item) = “MailItem” Then
Set Msg = item

If Msg.Subject Like “*關鍵字*” Then

Set objHTTP = CreateObject(“MSXML2.ServerXMLHTTP”)
URL = “http://127.0.0.1/index.phpsubject=” & Msg.Subject
objHTTP.Open “POST”, URL, False
objHTTP.setRequestHeader “User-Agent”, “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”
objHTTP.Send (“”)
End If
‘MsgBox Msg.Subject
‘MsgBox Msg.Body
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & ” -” & Err.Description
Resume ProgramExit
End Sub

Be the First to comment.

Leave a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

(若看不到驗證碼,請重新整理網頁。)