date of first email in Outlook conversation

supmktg

Registered User.
Local time
Today, 13:56
Joined
Mar 25, 2002
Messages
360
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:

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
 
I can't find any property like that. I noticed that when someone responds to an email I sent that date is in the body like

On Aug 29, 2016, at 5:32 PM, Steven Neuberger wrote:

but I suspect that depends on the Email client that created the reply email and the person replying could delete that.

Could you embed the date in the original subject line delimited with something. Then you could get the date out of the subject line if the person reply doesn't change it but I guess you are relying on that already.
 
Last edited:
Hi sneuberg, I appreciate your reply.

After much research I discovered that although there is no conversation start date property, there is a ConversdationID property that is shared by all emails in the thread. I probably could have extracted the original date by searching for the earliest date for a particular ConversationID, but if the original was deleted, moved, etc then that date would not be accurate and my process would fail.

Instead I create an entry in a tracking table for each original email and include the PK from that table in the subject like this: "Response required(1234)". Then I look for the string "(" & strTrackNo & ")" to find all of the emails.

Although I have found numerous ways to send an email using Outlook from Access, I'm having trouble finding a way to display emails using Outlook from Access. I can put the relevant data into a temp table and display the date, subject, body, etc on a form. But I have to believe that if I can extract the data from Outlook I should also be able to open and display the email using Outlook. Am I wrong?

Thanks,
Sup
 
Although I have found numerous ways to send an email using Outlook from Access, I'm having trouble finding a way to display emails using Outlook from Access. I can put the relevant data into a temp table and display the date, subject, body, etc on a form. But I have to believe that if I can extract the data from Outlook I should also be able to open and display the email using Outlook. Am I wrong?

Do you mean "display the email using Access" or ""display the email using Outlook Automation in Access" ? That might be tricky for emails in HTML format. Maybe you could display the content in a Browser control but in any case I don't have a good answer. As this is a different question I suggest you start a new thread.
 

Users who are viewing this thread

Back
Top Bottom