MailItem Object & Attachment Count

  • Thread starter Thread starter Venkat
  • Start date Start date
V

Venkat

I am developing a COM add-in for outlook using visual
basic. When I open a new mail and attached a file, the
attachmentadd event fires and the attachment count becomes
1. After that I delete the attachment. Then I checked the
attachment count in debug window typing ?
objmailitem.attachments.count. But it displays 1 still. Is
there any events like attachmentdelete? Or tell me one
solution to maintain the attachment count while adding and
deleting attachments?
 
Hi,

I want to explain the complete scenario.

Actually, I am adding a menu with a commandbar button
Attach, for every mail. Using Attach button, I
programmatically added an attachment into the mail item.
Then I deleted the attachment manually(not
programmatically). After that I checked the attachment
count using mailitem object "objmailitem" by the statement
objmailitem.attachments.count. But it shows 1 still.

I haven't used attachment collection object. And I am
not reinstantiating the mailitem object after deleting the
attachment.

Please clarrify.
-----Original Message-----
Are you reinstantiating your Attachments collection object after you
delete the attachment?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Venkat said:
I am developing a COM add-in for outlook using visual
basic. When I open a new mail and attached a file, the
attachmentadd event fires and the attachment count becomes
1. After that I delete the attachment. Then I checked the
attachment count in debug window typing ?
objmailitem.attachments.count. But it displays 1 still. Is
there any events like attachmentdelete? Or tell me one
solution to maintain the attachment count while adding and
deleting attachments?


.
 
MailItem.Attachments is the attachments collection. Sometimes there is
a lag between Outlook code seeing something and what you do manually.
Outlook caches things. I'd release the mail item object and
reinstantiate it and then try a new test for
MailItem.Attachments.Count.

Also, if you are using code why are you deleting the attachment
manually? Why not just do everything in code?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
Back
Top