I'm trying to open an Outlook email from a form that contains the date, recipient and subject of a previously emailed request for approval.
I am having trouble finding a method to determine the sent on date of the original email which belongs to the incoming response.
Here is the code of a button I am adding to the form:
Any help would be greatly appreciated!
Sup
I am having trouble finding a method to determine the sent on date of the original email which belongs to the incoming response.
Here is the code of a button I am adding to the form:
Code:
Private Sub cmdOpenEmail_Click()
Dim olApp As Outlook.Application
Dim Inbox As Outlook.MAPIFolder
Dim InboxItems As Outlook.Items
Dim Mailobject As Object
Dim dteSentOn As Date
Dim strSentTo As String
Dim strRequest As String
Set olApp = CreateObject("Outlook.Application")
Set Inbox = olApp.GetNamespace("Mapi").GetDefaultFolder(olFolderInbox).Folders("Approval")
Set InboxItems = Inbox.Items
dteSentOn = Me.txtSentOn
strSentTo = Me.txtSentTo
strRequest = Me.txtRequest
For Each Mailobject In InboxItems
If InStr(olMail.Subject, strRequest) <> 0 And Mailobject.From = strSentTo Then
If olMail.(?original email of this conversation sent on date?) = dteSentOn Then
'Open the email to read the response
End If
Else
MsgBox "No response yet!"
End If
Next
Set olApp = Nothing
Set Inbox = Nothing
Set InboxItems = Nothing
Set Mailobject = Nothing
End Sub
Any help would be greatly appreciated!
Sup