Thanks for your comment Matt ! I still have some
questions that need guidance from all of you. Below
are the codes that I had written in my program :-
Dim oMessage as Object
Dim oFldr as Outlook.MAPIFolder
Set oFldr = oNS.GetDefaultFolder(olFolderInbox)
For each oMessage in oFldr.Items
'Loop and save all attachments in an email
oMessage.Delete
Next oMessage
set oFldr = Nothing
I will remark off the part "oMessage.Delete" as
according to Matt, within a For each loop, i can't
delete. So I have improved on my code and will delete
the message once all attachments are saved. Below is
the added coding :-
Do While oFldr.Items.Count > 0
oFldr.Items.Remove 1
Loop
My questions are:-
1) At the time I run the processing I have 10 emails
to save. And once all attachments are saved, the
program will loop through my inbox and delete the
emails. Will I be deleting 11 emails instead? Meaning
that my 1st loop, my inbox has 10 emails but during
the 2nd loop, 1 new email received (attachment not
saved) and the program deleted that email. Will this
scenario happens? If yes, can someone guide me how do
I prevent this matter from happenning?
2) The command "xxx.Remove 1" will actually
permanently delete off the emails from my mailbox and
won't stay in my Deleted Items. If i want it to be in
my Deleted Items, i tried changing the the codes as
below, but not all emails are deleted from my inbox.
Why is that so? Is there any other deletion command
that I can use to delete all my emails and still stays
in my Deleted Item folder ?
For each oMessage in oFldr.Items
oMessage.Delete
Next oMessage
Please help ! My program only need this deletion part
to complete my whole program !! Please help !!
--- "Unicorn.PC.Support"
<[EMAIL PROTECTED]> wrote:
> You will have this sort of problem, because you are
> deleting the objects as
> you go.
> For Each loops do not like you to add or delete
> anything while they are
> running. Sort of confuses the issue as to what is
> actually next, when the
> list changes.
>
> A better approach would be to save all the
> attachments and then delete the
> mail; items in a separate loop, or perhaps the
> outlook object reveals a
> delete all property that could do it in a single
> statement.
>
> Matt
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~->
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [EMAIL PROTECTED]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/