Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-15-2017, 12:45 AM
CepheiMD CepheiMD is offline Change category of a message if received again as forward Windows 7 64bit Change category of a message if received again as forward Office 2010 64bit
Novice
Change category of a message if received again as forward
 
Join Date: Mar 2016
Posts: 3
CepheiMD is on a distinguished road
Default Change category of a message if received again as forward

Hello.
Please help me to solve the following situation.


I receive message from various senders. All messages which need my examination are sent by my manager as forwarded message (using quick steps).
I would like that the original message received by me to change the category then I receive the same message forwarded.
For example:
On 09:00 AM I received a message:
From: xyz@example.com subject: "case abc" text: “please find attached abc document”
On 09:05 AM my manager forwards the message to me
From: manager@example.com; subject: "for examination"; text: "please examine the case and respond."
In result, I would like that the message received on 09:00 AM to get the category "Worked".

I hope I explained the case clear
Reply With Quote
  #2  
Old 02-15-2017, 03:28 AM
gmayor's Avatar
gmayor gmayor is offline Change category of a message if received again as forward Windows 10 Change category of a message if received again as forward Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
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 of
Default

This is easier said than done as there is no correlation between the two messages.

They will presumably have the same original subject in the body text and they may have the same time of sending of the original message and they should have the same original sender, but there are many areas where this could go wrong and either no message is flagged or the wrong message is flagged.

The following may work, but much depends on how your mail system is configured and what is actually in the messages, but if not you may be able to alter it to suit.

It assumes that the messages sent directly to you, and are to be categorised, are in the default Inbox. I have included a test macro to test the premise with a message received from your manager that also exists in your inbox. If it works run the main script from a rule that identifies messages from your manager.

Code:
Option Explicit

Sub Test()
Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    FlagMessage olMsg
lbl_Exit:
    Exit Sub
End Sub

Sub FlagMessage(olItem As MailItem)
Dim strName As String
Dim strSubject As String
Dim strTime As String
Dim vItem As Variant
Dim vText As Variant
Dim vSubject As Variant
Dim i As Long
Dim olFolder As Folder
Dim olItems As Items
Dim olMsg As MailItem
    With olItem
        If LCase(.Subject) = "for examination" Then
            vText = Split(olItem.Body, Chr(13))
            For i = 0 To UBound(vText)
                If InStr(1, vText(i), "From: ") > 0 Then
                    vItem = Split(vText(i), Chr(58))
                    strName = LCase(Trim(vItem(1)))
                    strName = Replace(strName, " [mailto", "")
                    Exit For
                End If
            Next i
            For i = 0 To UBound(vText)
                If InStr(1, vText(i), "Sent: ") > 0 Then
                    vItem = Split(vText(i), Chr(58))
                    strTime = Trim(vItem(1)) & Chr(58) & vItem(2)
                    Exit For
                End If
            Next i
            For i = 0 To UBound(vText)
                If InStr(1, vText(i), "Subject: ") > 0 Then
                    vItem = Split(vText(i), Chr(58))
                    strSubject = LCase(Trim(vItem(UBound(vItem))))
                    Exit For
                End If
            Next i
            Set olFolder = Session.GetDefaultFolder(olFolderInbox)    'the folder where the messages are stored
            Set olItems = olFolder.Items
            olItems.Sort "[Received]", True
            For i = 1 To olItems.Count
                Set olMsg = olItems(i)
                If Format(olMsg.ReceivedTime, "dd mmmm yyyy HH:MM") = strTime Then
                    vSubject = Split(LCase(olMsg.Subject), Chr(58))
                    If strSubject = Trim(LCase(vSubject(UBound(vSubject)))) And _
                       strName = LCase(olMsg.Sender.Name) Then
                        olMsg.Categories = "Worked"
                        olMsg.Save
                        Exit For
                    End If
                End If
            Next i
        End If
    End With
lbl_Exit:
    Set olFolder = Nothing
    Set olItems = Nothing
    Set olMsg = 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
Reply

Tags
category, forwarded message



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change category of a message if received again as forward Error Message Received When Attempting to Open Doc in WORD or Publisher k5jim Word 1 01-25-2016 03:17 PM
Change category of a message if received again as forward Unable to edit a received message w/Outlook 2010 Mona123 Outlook 5 02-22-2012 10:25 AM
Change category of a message if received again as forward Message rules to forward to another address evurr Outlook 3 11-07-2011 10:46 PM
Change category of a message if received again as forward Create Rule to forward message to mobile# JoyConner Outlook 1 04-21-2011 05:44 PM
Change category of a message if received again as forward forward message to outlook category knoutam Outlook 1 11-07-2010 02:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft