Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bad Help Needed!!
Message
From
13/05/2002 08:50:15
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00655574
Message ID:
00655620
Views:
15
Okay, well, I think I have this licked. For those of you, like me, who like to know the ins and outs of 'why' something is, I shall put this down... it is late, and I shall try to cover all the ground... from my original message, and the others, and finally this one = I have learned that automation without documentation stinks!! More on this later... but for now:

So, here is what I started with:
*-- A single message deleter
LPARAMETERS lnCurrentMessage, lcMessageSubject

lnReturn = -1
loInbox = THIS.oOutInbox  && The default Inbox folder - already defined
loDeletedItems = THIS.oOutDeleted  && The default Deleted Items folder - already defined
lnWork = 0
FOR EACH loMsg IN loInbox.Items
     lnWork = lnWork+1
     lcWorkSubject = THIS.GetInSubject(lnWork)
     IF lnWork = lnCurrentMessageNo .AND. LOWER(lnWorkSubject)=LOWER(lcMessageSubject)
          *-- Right, by reckoning, this should move the message I am on....
          *-- ERROR SPOT!!!! Remember this spot!!! The error occurs here!!!
          loMsg.Move( loDeletedItems )
          lnReturn = 0
          *-- Okay, remember, I only want ONE message deleted, this one... so we can go now...
          EXIT
     ENDIF
ENDFOR
*--- Do all the cleanup stuff....
*-- Return a '0' - we did good, Return -1, no message deleted
RETURN lnReturn
And, we know my error was:
'ERROR SPOT' =
OLE error code 0x8002000f: Parameter Not Optional
Well, after a shuffle, and looking at Marcia Akins comments on a thread I don't remember (LOL), I came up with this... but, this only worked to delete.... I could not get it to Move...
loInbox = THIS.oOutInbox  && The default Inbox folder
loInBoxItems = loInbox.Items
loDeletedItems = THIS.oOutDeleted  && The default Deleted Items folder
loTest = THIS.oName.GetDefaultFolder(3) && Deleted Items
lnCount = THIS.getmessagecount()
*lnCount = lnCount+1
lnReturn = -1
lnWork = 0
lcCurrentSubject = THIS.GetInSubject(lnCurrentMessageNo)

FOR EACH loMsg IN loInbox.Items
     lnWork = lnWork+1
     lcWorkSubject = THIS.GetInSubject(lnWork)
     IF lnWork = lnCurrentMessageNo .AND. LOWER(lcWorkSubject)=LOWER(lcMessageSubject)
          oMsg = loInbox.Items(lnWork)
          oCrap = oMsg.Delete
          lnReturn = 0
          EXIT
     ENDIF
ENDFOR
RETURN lnReturn
So, I reversed the delete order to get the message index okay.... thinking that my help... Thanks Ed. Again, worked to delete, but not to move...
... same stuff was here....
FOR lnCycle = lnCount TO 1 STEP -1
     lcWorkSubject = THIS.GetInSubject(lnCycle)
     IF lnCycle = lnCurrentMessageNo .AND. LOWER(lcWorkSubject)=LOWER(lcMessageSubject)
		  oMsg = loInbox.Items(lnCycle)
          oCrap = oMsg.Delete
          lnReturn = 0
          EXIT
     ENDIF
ENDFOR
RETURN lnReturn
And now.. the secret solution.. lol... the problem was the loDeletedItems. Originally, my open outlook code gets all of the outlook folder items.... aha!!! folder "items".... we do not want to move to folder items... we want to move to folders!!! the rain came down, the sun shone, and lightning flashed all over my desk... (we get weird weather here in NZ)... so, I left what some parent methods did visible, for anyone to see (and I hope learn) from my mistake:
*-- the solution...

LOCAL loInbox,  loInBoxItems, loDeletedItems, lnCount, lnWork, lnCycle
LOCAL lcWorkSubject, lnReturn
lnReturn = -1
loInbox = THIS.oOutInbox  && The default Outlook Inbox folder (funny name, I know)
loInBoxItems = loInbox.Items && This was here all the time
*-- take this line out....
*loDeletedItems = THIS.oOutDeleted  && The default Deleted Items folder
*-- the parent method defined :: THIS.oName.GetDefaultFolder(3).Items :: && Deleted Items!!!
*-- I never had the folder, only the items... so the new line is:

loDeletedItems = THIS.oName.GetDefaultFolder(3) && Deleted Items Folder
lnCount = THIS.getmessagecount() && How many message 

FOR lnCycle = lnCount TO 1 STEP -1
     lcWorkSubject = THIS.GetInSubject(lnCycle)
     IF lnCycle = lnCurrentMessageNo .AND. LOWER(lcWorkSubject)=LOWER(lcMessageSubject)
          oMsg = loInbox.Items(lnCycle)
          oCrap = oMsg.Move(loDeletedItems)
          lnReturn = 0
          EXIT
     ENDIF
ENDFOR
RETURN lnReturn
Ta Daa!!! So, all of you who are working to learn about outlook automation and understand the whys and why nots, I hope it helps. Now, is there anywhere specific I can possibly go to find out all of the automation properties, methods, and events with, dare I say, some examples? I don't mind figuring things out... but it helps to have a map to find the quickest way... thanks to all of you public and private who had fun with me tonight...
Previous
Reply
Map
View

Click here to load this message in the networking platform