Hello All,

I'm searching for a VBA Code to find a solution to this very unique situation.

my team members search for emails using excel file having order numbers in column A and it has invoice number in Column B.

then search for the email using the subject line containing the order number, which are system generated and come from single system generated email.

once they find the email they edit the email either by replying or forwarding and taking a print out as they need a hard copy with has both invoice number and order number P.S. they don't send the email they only forward or reply to edit the subject / mail body to add the invoice number.

I need someone to help me with the code i have the below code but i fail to do the edit forwarding and printing & loop this cycle.

Sample Table & code below.


PublicSub sofWorkWithOutlook()
Dim outlookApp
Dim olNs As Outlook.Namespace
Dim Fldr As Outlook.MAPIFolder
Dim olMail AsVariant
Dim myTasks

Dim oMail As MailItem
Dim myItem As Outlook.MailItem

'Set outlookApp = New Outlook.Application
Set outlookApp = CreateObject("Outlook.Application")

Set olNs = outlookApp.GetNamespace("MAPI")
Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
Set myTasks = Fldr.Items
Set myItem = Outlook.ActiveInspector.CurrentItem

Set olMail = myTasks.Find("[Subject] = ""1806594500""")
ForEach olMail In myTasks
If(InStr(1, olMail.Body,"1806594500", vbTextCompare)>0)Then
Dim myinspector As Outlook.Inspector