View Single Post
 
Old 07-06-2021, 09:33 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The short answer is 'no'.
You have no control over your clients' e-mail applications. You have no control over the incoming e-mail formats - with plain text having no compatibility with fields. If you add material to messages, you damage their evidential value in the event of a future legal action.
In theory you can add to an e-mail message, either incoming or outgoing using a macro (or in the case of incoming a script attached to a rule), but I would avoid fields. At its simplest it would be as follows, but you could replace the reference input box with a lookup to the Access table.
Open a new (or existing) message and run the Test macro.

Code:
Sub Test()
Dim olMsg As MailItem
On Error Resume Next
    Select Case Outlook.Application.ActiveWindow.Class
        Case olInspector
            Set olMsg = ActiveInspector.currentItem
        Case olExplorer
            Set olMsg = Application.ActiveExplorer.Selection.Item(1)
    End Select
    AddData olMsg
    Set olMsg = Nothing
End Sub

Sub AddData(olItem As MailItem)
'Graham Mayor - https://www.gmayor.com - Last updated - 07 Jul 2021
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
Dim sCase As String, sRef As String

    sCase = InputBox("Enter the case number")
    sRef = InputBox("Enter the reference number")

    With olItem
        .BodyFormat = olFormatHTML
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.collapse 1
        oRng.Text = "++++++++++++++++ Admin use only ++++++++++++++++++++" & vbCr & vbCr & _
                    "Case: " & sCase & vbCr & "Reference: " & sRef & vbCr & vbCr & _
                    "++++++++++++++++++++++++++++++++++++++++++++++++++" & vbCr & vbCr
        oRng.collapse 0
        oRng.Select
    End With
lbl_Exit:
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote