View Single Post
  #3  
Old August 14th 06, 08:33 PM posted to microsoft.public.outlook.program_vba
Geoff
external usenet poster
 
Posts: 21
Default MailItem Attachments Inconsistency

Hi Ken,

Try saving the item again after you add the attachments.


Thanks for your reply.

I thought you might like to know the rather interesting result.

It transpires my clean up code was in error. By trying to ensure that the
attachments object variable was "properly" destroyed, my clean up code
removed each attachment from the attachments collection before setting the
attachments collection variable to nothing. Naturally, the clean up code ran
*after* the Display method was used, so the MailItem was already on screen
when the clean up code ran. Although it happened too fast to see it, the
attachments were in the MailItem initially but were removed so fast as not
to be seen.

What's interesting is that, if the code was stopped any time after the
Display method but before the clean up, the attachments could be seen in the
MailItem. Stepping through the clean up code showed each attachment being
removed one at a time from the MailItem as the attachment was removed from
the attachments collection.

Interestingly, as might be expected, this behaviour was *not* replicated for
the Send method. Presumably, after Send, the MailItem is already in the
Outbox by the time my clean up code ran and it was too late for the clean up
code to remove attachments.

Omitting removal of attachments from the attachments collection solved the
problem when using the Display method.

If you (or others) have any further comments, I'd be glad to hear them.

Thanks for your interest.
Regards
Geoff


Ads