Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieving email from an archive 1

Status
Not open for further replies.

nc1264

Programmer
Dec 11, 2000
24
GB
I want to retrieve email that I have in an archive. How can I doe this with VFP. I have seen examples for the Inbox but not for what I would like to achieve.

Can anyone point me in the right direction.

Thanks,

Ron
 

You have to first determine the folder index number using something like this:
Code:
Local oOutlook,oNameSpace,oNewFolder
oOutlook=CREATEOBJECT('outlook.application')
oNameSpace=oOutlook.GetNamespace('mapi')
oFolders=oNameSpace.Folders(1).folders
nCount =oNameSpace.Folders(1).folders.Count
i = 1
FOR EACH oFolder IN oFolders
  ? oFolder.Name+' ,'+TRANSFORM(i)
  i = i +1
ENDFOR





Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
It also depends what you intend to do with these email and where you folder is located. If your folder is in your Inbox folder, here is how to get the subject line.
Code:
clear
#DEFINE olFolderInBox 6
Local oOutlook,oNameSpace,oDefaultFolder
oOutlook=CREATEOBJECT('outlook.application')
oNameSpace=oOutlook.GetNamespace('mapi')
oDefaultFolder =oNameSpace.Getdefaultfolder(olFolderInBox)
oFolders=oDefaultFolder.folders
FOR EACH oFolder IN oFolders
   oItems=oFolder.items
   FOR EACH oItem IN oItems
      ?oItem.subject
   endfor
ENDFOR




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

thanks for the answer. I will look into your examples in order to determine the foldernumber.
What I do find strange is that I know what the name is of the folder (and is location). Can´t I access it on its name? Must I determine its number. What if I have the same name in more folders, what do I need to do to determine which one is the correct one?

Thanks,
Ron
 

The folders in Outlook work like the folders in Windows Explorer. In other words there is certain hiarchy. In this example I moved up a level in the hiarchry which gives me the hiarchy above the Personal Folders as show in the above example. In my case it gives me "Personal Folders ,1" and Archive Folders, 2".
Code:
Local oOutlook,oNameSpace,oNewFolder
oOutlook=CREATEOBJECT('outlook.application')
oNameSpace=oOutlook.GetNamespace('mapi')
oFolders=oNameSpace.Folders
nCount =oNameSpace.Folders.Count
i = 1
FOR EACH oFolder IN oFolders
  ? oFolder.Name+' ,'+TRANSFORM(i)
  i = i +1
ENDFOR

So the folder I'm looking for is in the "personal Folders" directory, so in the above sample that I gave you earlier I used the line:
nCount =oNameSpace.Folders(1).folders.Count

The '1' means the reference to the "personal folders" index number, if I wanted to go to the "archive folders" I would have use the "2".




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top