Consulting

Results 1 to 2 of 2

Thread: Automatically replacing text in subject lines

  1. #1

    Automatically replacing text in subject lines

    Our Exchange server is set to mark certain e-mail messages as unwanted, adding various text strings to their subject lines before passing the message through to the Outlook client. I have a Word macro that removes these specific text strings from subject lines; I cut from the Outlook subject line, paste into Word, run the macro, cut the result from Word, and paste back into the subject line. Whew.

    Is it possible to create an Outlook macro that deletes a specified string from the subject line of incoming e-mail?

    Thanks,

    Dan Goldstein


  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Dan,

    Welcome to VBAX!

    You can use an outlook rule (for incoming mail) to accomplice this. In the rule assign the Macro with "run a script" option in Step 2 off the rule wizard!

    The code could look something like this: (insert in Normal code Module)[VBA]
    Sub StripSubject(oItem As Outlook.MailItem)
    Dim iDelete As Integer
    Dim sDelete As String
    Dim sOld As String
    Dim sNew As String

    sDelete = "Hi Dan"
    With oItem
    sOld = .Subject
    iDelete = InStr(1, .Subject, "Hi Dan", vbTextCompare)

    If iDelete <> 0 Then
    sNew = Replace(sOld, sDelete, "", 1, -1, vbTextCompare)
    .Subject = Trim(sNew)
    .Save
    End If
    End With
    End Sub
    [/VBA]
    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •