我每个星期三都会收到来自特定发件人的邮件。此电子邮件的主题有时会发生变化
主题“暴露声明 - COB 20150217”的示例#1
主题“保证金通知 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 = "[email protected] /cdn-cgi/l/email-protection;[email protected] /cdn-cgi/l/email-protection"
.CC = "[email protected] /cdn-cgi/l/email-protection;[email protected] /cdn-cgi/l/email-protection"
.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
to
If olMail.SenderEmailAddress = "[email protected] /cdn-cgi/l/email-protection" And olMail.ReceivedTime = Now() Then
但这不起作用...
这是唯一可以让我找到确切消息的搜索组合(SenderEmailAddressthat 和 ReceivedTime)...
您应该使用:工具->参考。寻找Microsoft Outlook 15.0 Object Library
,检查它并关闭窗口。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)