-2

We have a ticket system that sends us tickets with the title "New Ticket Created: T20120803.0078" where the number is generated.

We reply to all saying we are working on the ticket. The reply title looks like this "RE: New Ticket Created: T20120803.0078".

My Outlook is set up to forward all tickets into one folder called "Tickets".

I am trying to figure out how when the email is replied to, it sends both the reply and the original to another folder called "InProgress".

4

1 回答 1

2

don't have a lot of time to figure this one out.

Typically, at this sight we don't build code for people, but help them build the tweak or perfect code where they are struggling.

That said, I was intrigued by your question and wanted to learn myself, so I put something together for you. This should get you a great start, if it's not already exactly what you need.

UPDATE:

You don't even need VBA for the first part. You can set up a rule to move all sent messages with "RE: New Ticket Created" in the subject line to the In Progress folder. Therefore, you don't even need the whole first IfF Then End If block in the code below. (I've left it for reference, purposes).

CODE

All assumptions based on the settings you provided.

Place the code in the Application_ItemSend event of ThisOutlookSession object in Outlook VBE.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim olNameSpace As Outlook.NameSpace
Set olNameSpace = GetNamespace("MAPI")

Dim olDestFolder As Outlook.Folder
Set olDestFolder = olNameSpace.Folders("myMailbox@myCompany.com").Folders("In Progress")


If TypeName(Item) = "MailItem" Then 'if it's a mail item being sent

    Dim olMailCopy As Outlook.MailItem
    Set olMailCopy = Item.Copy 'copy the item so we can move it and still have it send

    If InStr(1, olMailCopy.Subject, "New Ticket Created") > 0 Then '

        olMailCopy.Move olDestFolder ' move copy of mail to folder

        Dim strTicket As String
        strTicket = Mid(olMailCopy.Subject, InStrRev(olMailCopy.Subject, ": ") + 2) 'just grab ticket id

    End If

End If


Dim olLookUpFolder As Outlook.Folder
Set olLookUpFolder = olNameSpace.Folders("myMailbox@myCompany.com").Folders("Tickets")

Dim olMail As Outlook.MailItem

For Each olMail In olLookUpFolder.Items 'loop through Tickets folder to find original mail

    If InStr(1, olMail.Subject, strTicket) > 0 Then 'look for unique ticket Id

        olMail.Move olDestFolder ' move to InProgress folder

        Exit For

    End If

Next

End Sub
于 2012-08-03T20:58:54.777 回答