小编pra*_*900的帖子

查找主题以特定文本开头的电子邮件

我试图通过以特定文本开头的主题查找电子邮件,然后从该电子邮件下载附件。

我正在使用带有 Restrict 函数的变量,但是问题似乎是由于使用了通配符。

Sub findemail()

cntofmkts = Range("A" & Rows.Count).End(xlUp).Row
cntofmkts = cntofmkts - 1
ftodaydate = Format(Date, "yyyy-mm-dd")

Do
    If i > cntofmkts Then Exit Do

    MarketName = Range("A" & j).Value    
    Findvariable = "XXX_" & MarketName & "_ABC_" & ftodaydate

    For Each oOlItm In oOlInb.Items.Restrict("[Subject] = *Findvariable*")
        eSender = oOlItm.SenderEmailAddress
        dtRecvd = oOlItm.ReceivedTime
        dtSent = oOlItm.CreationTime
        sSubj = oOlItm.Subject
        sMsg = oOlItm.Body

        If oOlItm.Attachments.Count <> 0 Then
            For Each oOlAtch In oOlItm.Attachments
                '~~> Download the attachment
                oOlAtch.SaveAsFile NewFileName …
Run Code Online (Sandbox Code Playgroud)

excel outlook vba outlook-filter

3
推荐指数
1
解决办法
9350
查看次数

标签 统计

excel ×1

outlook ×1

outlook-filter ×1

vba ×1