Chris_cs
05-22-2007, 07:03 AM
Hey guys,
I've written a small sub procedure to remove the attachments from any selected emails but it isn't actually removing them. The code is below:
Sub removeAttachments()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim myattachments As Outlook.Attachments
Dim MsgTxt As String
Dim x As Integer
'MsgTxt = "You have selected items from: "
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
Set myattachments = myOlSel.Item(x).Attachments
While myattachments.Count > 0
myattachments.Remove 1
Wend
'MsgTxt = MsgTxt & myOlSel.Item(x).Body & ";"
Next x
MsgBox "Attachments removed"
End Sub
I cannot see why it wouldn't work so any pointers would be appreciated.
Thanks
I've written a small sub procedure to remove the attachments from any selected emails but it isn't actually removing them. The code is below:
Sub removeAttachments()
Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlSel As Outlook.Selection
Dim myattachments As Outlook.Attachments
Dim MsgTxt As String
Dim x As Integer
'MsgTxt = "You have selected items from: "
Set myOlExp = myOlApp.ActiveExplorer
Set myOlSel = myOlExp.Selection
For x = 1 To myOlSel.Count
Set myattachments = myOlSel.Item(x).Attachments
While myattachments.Count > 0
myattachments.Remove 1
Wend
'MsgTxt = MsgTxt & myOlSel.Item(x).Body & ";"
Next x
MsgBox "Attachments removed"
End Sub
I cannot see why it wouldn't work so any pointers would be appreciated.
Thanks