Recurring mail attachment(s)

  • Thread starter Thread starter Torsten Piehl
  • Start date Start date
T

Torsten Piehl

Outlook Experts,


I wrote a OL2003 macro to (1) save an OL.MailItem in filesystem
and to (2) remove the attachment(s).

This is the code so far:

Private Sub SaveMail(myMailObj As MailItem)

(1) myMailObj.SaveAs sFilePath, olMSG
...
(2) nMax = myMailObj.Attachments.Count
For i = 1 To nMax
sAttachements = sAttachements & "<" &
myMailObj.Attachments.Item(i).FileName & "> "
myMailObj.Attachments.Item(i).Delete
Next i
myMailObj.Body = p_myObj.Body & vbCRLF & sAttachements
myMailObj.Save
...
(3) MoveMail myMailObj
...
End Sub

Problem:
Change selected item in view, return to item and open it. The mail still
contains their attachments!!!
(If you do not change the selection and open the edited item, the mail does
not contain any attachments, macro works fine!)

Evaluation: In step (3), I moved the mail to an backup folder in
OL.ActiveExplorer. Step (2) works fine!

Aggregation: The macro deletes the mail attachments when moving the mail.
If the mail will not moved, the attachments will recurring if the mail is
revisited!

Any ideas?

Thanks in advance!
Torsten Piehl
 
Outlook caches things so you'd need to change the current folder in the
ActiveExplorer and then go back again to see the changes.

For deleting items from a collection never use a count up loop. Use a count
down loop (For i = Count To 1 Step -1). That way you're not messing with the
loop counter within the loop.
 
Thanks for fast reply
and a happy new year,

is it possible to reload or clear the ol (mail) -cache manually to make
changes visible?

Regards
T. Piehl
 
No, not really. From code about the only way is to switch folders and back
again to refresh the view.
 
Back
Top