none
Remove first 20 Character in Subject Line RRS feed

  • Question

  • Can I remove the first 20 Characters in the subject line from an incoming email address say test@xtra.co.nz

    Or create a rule for a incoming email with a script

    Thanks for any help.........Bob

    Wednesday, August 8, 2012 2:01 AM

Answers

  • Trim gets rid of only white space. If "item" is the item then something like this:
     
    Dim sSubject As String
    sSubject = item.Subject
    sSubject = Right(sSubject, Len(sSubject) - 20)
     
    That would get the subject in a string variable, then it would remove the leftmost 20 characters from the string.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "TurnipOrange" <=?utf-8?B?VHVybmlwT3Jhbmdl?=> wrote in message news:0366c5ef-05be-47ba-9f4c-ad33dd0d0a72...

    Thanks Damian , Would Right Trim take away the first 20 Characters?

    Regards Bob


    Ken Slovak MVP - Outlook
    • Marked as answer by TurnipOrange Wednesday, August 8, 2012 11:45 PM
    Wednesday, August 8, 2012 6:56 PM
    Moderator

All replies

  • is function 'right' ok for your needs? http://msdn.microsoft.com/en-US/library/dxs6hz0a(v=vs.80)

    Wednesday, August 8, 2012 9:15 AM
  • Thanks Damian , Would Right Trim take away the first 20 Characters?

    Regards Bob

    Wednesday, August 8, 2012 6:19 PM
  • Trim gets rid of only white space. If "item" is the item then something like this:
     
    Dim sSubject As String
    sSubject = item.Subject
    sSubject = Right(sSubject, Len(sSubject) - 20)
     
    That would get the subject in a string variable, then it would remove the leftmost 20 characters from the string.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "TurnipOrange" <=?utf-8?B?VHVybmlwT3Jhbmdl?=> wrote in message news:0366c5ef-05be-47ba-9f4c-ad33dd0d0a72...

    Thanks Damian , Would Right Trim take away the first 20 Characters?

    Regards Bob


    Ken Slovak MVP - Outlook
    • Marked as answer by TurnipOrange Wednesday, August 8, 2012 11:45 PM
    Wednesday, August 8, 2012 6:56 PM
    Moderator
  • Brilliant Ken, thank you so much for your effort...........Regards Bob :)

    Sub ChangeSubjectLine(MyMail As MailItem)
    Dim strID As String

    Dim olNS As Outlook.NameSpace
    Dim olMail As Outlook.MailItem

    strID = MyMail.EntryID
    Set olNS = Application.GetNamespace("MAPI")
    Set olMail = olNS.GetItemFromID(strID)
    olMail = Right(olMail, Len(olMail) - 42)
    olMail.Save


    Set olMail = Nothing
    Set olNS = Nothing
    End Sub

    Wednesday, August 8, 2012 11:46 PM