Excel VBA, how to Reply to a specific email message

丶灬走出姿态 提交于 2019-12-05 19:56:08

You shoud use: Tools->References. Find Microsoft Outlook 15.0 Object Library, check it and close the window.

Or just use late binding

Const olFolderInbox = 6
Sub Test()

Dim olApp As Object
Dim olNs As Object
Dim Fldr As Object
Dim olMail
Dim i As Long

Set olApp = CreateObject("Outlook.Application")
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
i = 1

For Each olMail In Fldr.Items
    If InStr(olMail.Subject, "email message object text") <> 0 Then
    olMail.Display
    olMail.ReplyAll
i = i + 1
End If
Next olMail
End Sub
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!