Moving emails with similar subject and find the timings between the emails using outlook VBA macro


Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
I want to move the emails from one folder to another folder based on the selection one of items in outlook. If i choose one email in outlook when i run the outlook VBA macro i want all similar subject of the email to be moved from that folder into another folder(we can sort by subject and move the email , this may be faster), also i want to calculate response time of first received email with same subject and the responded time of the email which i have replied at the last. Please assist
i have tried selecting one email and run the macro and it is moving to another folder correctly but i need all the similar subject of the has to be moved faster
Tried for moving one email by selecting the macro and it is working fine. but i want all the similar subject of the email has to be moved.I want to calculate the timing of the first email received and the email which i have responded at the latest.
Example subject of the email : Need data Received at 1 AM, i have acknowledged at 1 :10 AM and responded at 1:40 AM In that case i need to calculate the timings as 40 MIN

Sample VBA
Option Explicit

Sub MoveEml()
Dim ol As Outlook.Application
Dim ns As Outlook.NameSpace
Dim inFolder As Outlook.MAPIFolder
Dim olFolder As Outlook.MAPIFolder
Dim SubFolder As Outlook.MAPIFolder
Dim selItems As Selection
Dim myItem As Object
Dim SubItem As MailItems

Set ol = Outlook.Application
Set ns = ol.GetNamespace("MAPI")
Set inFolder = ol.Session.GetDefaultFolder(olFolderInbox)
Set olFolder = inFolder.Folders("Lyca")
Set SubFolder = inFolder.Folders("bakup")

' Set reference to the Selection.
Set selItems = ActiveExplorer.Selection
Set SubItem = selItems.Item.Subject
Debug.Print SubItem

' Loop through each item in the selection.
For Each myItem In selItems
myItem.Move SubFolder


'MsgBox "All Done. Email converted to Plaintext.", vbOKOnly, "Message"

Set selItems = Nothing

End Sub

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
If you want to select one item and find all messages with that subject and mobed them, You'll need to grab the subject from the message then do a filter, or an if statement, and 'walk' the folder.
This would get the subject
Set objItem = ol.ActiveInspector.CurrentItem
strSubject = objItem.subject
If you want ot get the replied to time, you need to get the last verb value. I have a sample that checks for the replied to time and does something (you'll need to change what it does).