Delete

  • Thread starter Thread starter Rizza
  • Start date Start date
R

Rizza

I am a newbie to Outlook VBA so please have patience.
What I need to create is code that I can attach to a button to delete emails
from another users folder and then to permanently delete them from the
deleted items.
Anything would be helpful.
Thanks in advance
 
Use the GetDefaultSharedFolder method to return another user's mailbox, and
loop through the MAPIFolder object's Items collection to retrieve individual
MailItem objects and use the Delete method.

The FolderType parameter for GetDefaultSharedFolder will allow you to return
the Inbox or Deleted Items folder, amongst others.

You'd have to provide additional coding logic to find the message you just
deleted in the Deleted Items folder by either looping through Items and
comparing Subject property values, or use the Restrict method, and then
delete that message as well.

Or you could use CDO; the Message.Delete method allows you to bypass sending
the message to Deleted Items.

For more resources for programming with Outlook, start here:

Visual Basic and VBA Coding in Microsoft Outlook:
http://www.outlookcode.com/d/vb.htm
 
Back
Top