Consulting

Results 1 to 7 of 7

Thread: Delete email addresses from fwd's

  1. #1
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location

    Delete email addresses from fwd's

    Hey all,

    A co-worker of mine asked me an Outlook question and I have no idea. He wants to delete any email addresses shown in the body of an email text when he forwards an email he received (he was on a list). Is there a setting for this or do we need VBA?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    So when you reply or forward an email, normally it will show all the To: and CC: emails and he wants to delete that text?

  3. #3
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Yeah, the first part of the body. I know on replies you can choose not to show the last message in the body, but you don't have that option in forwarding. You can only have the message indented or not (basically) but can't not show it.

    Btw, this is Outlook 2003. Preferrable if a solution went back to 2002 or even 2000, but whatever.

    Do you think a coded solution is in order?

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Well I can get you started at least. The idea here is to watch all the emails in the Inbox.

    In a Standard Module:

    [vba]
    Option Explicit

    Public MItems() As New ClassForward

    Sub ClassInitialize()

    Dim i As Long
    Dim n As Long
    Dim NS As NameSpace
    Dim Inbox As MAPIFolder

    Set NS = GetNamespace("MAPI")
    Set Inbox = NS.GetDefaultFolder(olFolderInbox)
    n = Inbox.Items.Count
    ReDim MItems(1 To n)
    For i = 1 To n
    Set MItems(i).ForwardWatch = Inbox.Items(i)
    Next i

    End Sub
    [/vba]

    In a Class Module Named ClassForward:

    [vba]
    Option Explicit

    Public WithEvents ForwardWatch As MailItem

    Private Sub ForwardWatch_Forward(ByVal Forward As Object, Cancel As Boolean)

    Dim StrBody As String

    StrBody = Forward.Body
    MsgBox StrBody

    End Sub
    [/vba]
    In ThisOutlookSession:

    [vba]
    Option Explicit

    Private Sub Application_NewMail()

    Call ClassInitialize

    End Sub

    Private Sub Application_Startup()

    Call ClassInitialize

    End Sub
    [/vba]

    This will trigger whenever you forward an email. Then you should be able to manipulate the string variable and change the text.

    Hope this helps.

    Thanks

    Jake

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Thanks Jake. I'll try it out.

  6. #6
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Errors out on this line upon opening Outlook ...

    [vba]Set MItems(i).ForwardWatch = Inbox.Items(i)[/vba]

    .. on iteration # 2. Same error I'm getting with the other thread, Type Mismatch.

  7. #7
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    And you have the class setup right, with the correct class module name? I'm not sure what the error could be, maybe someone else can give it a test.

Posting Permissions

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