I'm working on the code to fetch email with a specific "Order Number" from my excel list (column A) and open the email once it is found in the search, forward/Edit that email to add Invoice Number and take a print, i do not wish to forward it to some other email address however i wish to add a corresponding invoice number in the email body i.e. email received from system upon order number creation for physical print out.
I've been able to find the email and open however i am unable to find the code to make the forwarding of email and adding the corresponding invoice number in the mail body to print. below is the sample of my data
my code
Public Sub sofWorkWithOutlook()
Dim outlookApp
Dim olNs As Outlook.Namespace
Dim Fldr As Outlook.MAPIFolder
Dim olMail As Variant
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""")
'
For Each olMail In myTasks
'
If (InStr(1, olMail.Body, "1806594500", vbTextCompare) > 0) Then
olMail.Display
Dim myinspector As Outlook.Inspector
oMail.Display
myItem.Forward
olMail.PrintOut
Exit For
End If
Next
End Sub