Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Outlook, ADO, and VFP
Message
De
20/07/2000 14:09:36
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00394985
Message ID:
00395032
Vues:
10
Evelyn,

Here is some code I posted for someone else a while back, that might help get you started with Outlook automation from VFP. This is for checking incoming messages and storing the message bodies to a table.

1) start Outlook
2) get references to "Inbox" and "Archive" (a folder I set up)
3) step through inbox messages, storing message bodies (you could of course store date, from, subject, etc.)
4) move messages to Archive folder
5) close up
WAIT WINDOW NOWAIT "Starting up Outlook Email program"
ol=createobject("outlook.application")
ons=ol.getnamespace("MAPI")
crea cursor mymail (mailtext M)
oMain=ons.folders("Personal Folders").folders("Inbox")
oArchive=ons.folders("Personal Folders").folders("Archive")
lncount=oMain.items.count

* in case you like to see what the counts are
wait window "Inbox contains "+ALLTRIM(STR(lncount))+" messages."
wait window "Saved folder contains "+ ;
  ALLTRIM(STR(oArchive.items.count))+" messages."

* NOTE: This processes messages from oldest date to newest
FOR lnLoop = 1 TO lnCount
  WAIT WINDOW NOWAIT "Processing Email Message # "+ALLTRIM(STR(lnLoop))+;
    " of "+ALLTRIM(STR(lnCount))
  INSERT INTO mymail (mailtext) ;
    VALUES (oMain.items(lnLoop).body)
ENDFOR

FOR lnLoop = 1 TO lnCount
  WAIT WINDOW NOWAIT "Archiving Email Message # "+ALLTRIM(STR(lnLoop))+;
    " of "+ALLTRIM(STR(lnCount))
  * must refer always to items(1) because after
  * moving each message to archive, the next
  * message shifts to #1
  oItem=oMain.items(1)
  oItem.move(oArchive)
ENDFOR

ons.Logoff
ons=.NULL.
ol=.NULL.
WAIT CLEAR
USE
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform