Hi, I am facing a difficult question. I am writing a macro to reply a specific email. However, I can't exact all mail in the outlook. Here is the code
Sub ReplyMail()
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
Dim subj As String
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox).Folders("ABCDE")
i = 1
For Each olMail In Fldr.Items
subj = olMail.Subject
If InStr(olMail.Subject, "Exposure Statement - COB date") <> 0 Then 'where date is a date that changes every wednesday
With olMail.Reply
.to = "******@domain.com;******@domain.com"
.CC = "******@domain.com;******@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
The code was copy from the other post. Although this code can read so email, the extracted email was several days ago. It would be much appreciated if the code can read the newest email from outlook.