小编har*_*ane的帖子

Excel VBA检测Outlook是否打开,如果不是,则打开它

我编写了代码来下载附件到指定的文件夹.

Const olFolderInbox = 6

Sub detectpp_plate_record1()

Dim oOutlook As Object
Dim oOlns As Object
Dim oOlInb As Object
Dim unRead, m As Object, att As Object

'~~> Get Outlook instance
Set oOutlook = GetObject(, "Outlook.application")
Set oOlns = oOutlook.GetNamespace("MAPI")
Set oOlInb = oOlns.GetDefaultFolder(olFolderInbox)

'~~> Check if there are any actual unread emails
Set unRead = oOlInb.Items.Restrict("[UnRead] = True")

' File_Path = "D:\Attach\"

File_Path = "C:\Users\Desktop\pocket setter excel\"

If unRead.Count = 0 Then
    MsgBox "NO Unread Email In Inbox"
Else …
Run Code Online (Sandbox Code Playgroud)

excel outlook vba excel-vba

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

excel ×1

excel-vba ×1

outlook ×1

vba ×1