PDA

View Full Version : Delete email addresses from fwd's



Zack Barresse
04-26-2006, 01:12 PM
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? :dunno

Jacob Hilderbrand
04-26-2006, 04:16 PM
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?

Zack Barresse
04-26-2006, 04:43 PM
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?

Jacob Hilderbrand
04-26-2006, 06:40 PM
Well I can get you started at least. The idea here is to watch all the emails in the Inbox.

In a Standard Module:


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


In a Class Module Named ClassForward:


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

In ThisOutlookSession:


Option Explicit

Private Sub Application_NewMail()

Call ClassInitialize

End Sub

Private Sub Application_Startup()

Call ClassInitialize

End Sub


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

Zack Barresse
04-27-2006, 10:30 AM
Thanks Jake. :) I'll try it out.

Zack Barresse
04-27-2006, 10:51 AM
Errors out on this line upon opening Outlook ...

Set MItems(i).ForwardWatch = Inbox.Items(i)

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

Jacob Hilderbrand
04-27-2006, 10:58 AM
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.