Recurring mail attachment(s)

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
 
K

Ken Slovak - [MVP - Outlook]

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.
 
T

Torsten Piehl

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
 
K

Ken Slovak - [MVP - Outlook]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top