gpt4 book ai didi

Excel VBA,如何回复特定电子邮件

转载 作者:行者123 更新时间:2023-12-02 18:18:04 24 4
gpt4 key购买 nike

我每个星期三都会收到一封来自特定发件人的邮件。此电子邮件的主题有时会发生变化

主题“暴露声明 - COB 20150217”的示例 #1

主题“ margin 通知 COB 2015-Feb-10”的示例 #2

发件人附加的日期是我收到邮件的前一天。

我有以下代码,可以搜索该电子邮件,然后使用自定义正文回复它,但我无法让代码找到主题中包含该日期的特定邮件。

有没有办法通过主题以外的其他参数进行搜索?

Sub ReplyMail_No_Movements()

Dim olApp As Outlook.Application
Dim olNs As Namespace
Dim Fldr As MAPIFolder
Dim olMail As Variant
Dim SigString As String
Dim Signature As String
Dim i As Integer

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

SigString = Environ("appdata") & _
"\Microsoft\Signatures\MCC.txt"

If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If

On Error Resume Next

For Each olMail In Fldr.Items
If InStr(olMail.Subject, "Exposure Statement - COB date") <> 0 Then 'where date is a date that changes every wednesday
With olMail.Reply
.to = "email1@domain.com;email2@domain.com"
.CC = "email3@domain.com;email4@domain.com"
.Body = "Dear All," & Chr(10) & _
Chr(10) & "we agree with your portfolio here attached and according to it we see no move for today." & _
Chr(10) & " Best Regards." & _
Chr(10) & _
Chr(10) & Signature
.Display
End With
i = i + 1
End If
Next olMail
End Sub

编辑:我更改了这段代码

If InStr(olMail.Subject, "Exposure Statement - COB date") <> 0 Then

If olMail.SenderEmailAddress = "email1@gdomain.com" And olMail.ReceivedTime = Now() Then

但是这不起作用...

这是唯一可以让我找到确切消息的搜索组合(SenderEmailAddressthat 和 ReceivedTime)...

最佳答案

您应该使用:工具->引用。找到 Microsoft Outlook 15.0 对象库,选中它并关闭窗口。

关于Excel VBA,如何回复特定电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28612018/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com