Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

outlook 2007 - sort incoming email - if sunject = 'x' write to a text file else end program

I am looking for a program that will sort incoming email thru outlook.  if subject = ' x' then save it to a text file in separate columns. one column for each: to, from , suject, message.


--->>>actually i wanted this on the server, but cant have a copy of outlook on the exchange..so my only solution is to have the exchange send to client..client sorts email...then if subject = 'x' then save to text, as I dont know if exchange can save to a text file.


here is what I have so far:

Sub SaveAsTXT_if_SUBJ_equals_X()
    Dim myItem As Outlook.Inspector
    Dim objItem As Object
    Dim strname as stirng

    strname = objItem.Subject
    Set myItem = Application.ActiveInspector


    If strname = "X" Then
        Set objItem = myItem.CurrentItem      

        objItem.SaveAs Environ("HOMEPATH") & "\My Documents\" &  strname & ".txt", olTXT
     
    Else
        MsgBox "There is no current active inspector."
    End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Tony Massa
Tony Massa
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GlobaLevel

ASKER

well simplicity...the emails can stay in the inbox...and can be deleted at the end of the month...

I need the code to check the subject line for a special charset or a split as the subject line will contain: "abc.com"...but when they reply...it will contain the forward so it should factor that in like: "FW:abc.com - your response to your acct" so it has to find the abc.com in there...if found sort to the text file...

this looks like vbscript...but I need VBA to put in a module inside the Outlook VBE....