我每个星期三都收到来自特定发件人的邮件。该电子邮件的主题有时会更改
主题“暴露声明-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];[email protected]"
.CC = "[email protected];[email protected]"
.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 = "[email protected]" And olMail.ReceivedTime = Now() Then
但这行不通...
这是唯一让我找到确切消息的搜索组合(SenderEmailAddressthat和ReceivedTime)...
您应该使用:工具->参考。查找Microsoft Outlook 15.0 Object Library
,检查并关闭窗口。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句