Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Outlook automation to read an entire folder
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00777521
Message ID:
00778251
Vues:
19
Although come to think of it, you may only want to collect information about unread messages, which might make more sense, in that case you's have to add a couple of lines to me suggested code:
Public oForm
oForm = Createobject("form")
oForm.Width = 600
oForm.Height = 500
oForm.AddObject("grid1","grid")
oForm.grid1.Width = 590
oForm.grid1.Height = 490
oForm.grid1.ColumnCount = 4
oForm.grid1.Visible = .T.
Create Cursor myEmails (From c(20),daterec d,subject c(20),content M)
oOutLookObject = Createobject("Outlook.Application")
olNameSpace = oOutLookObject.GetNameSpace("MAPI")
myEmails=olNameSpace.GetDefaultFolder(6).Items
For Each loItem In myEmails
	If loItem.unread  && Check if unread
		Insert Into myEmails (From,daterec,subject,content) Values;
			(loItem.sendername,loItem.ReceivedTime,loItem.subject,loItem.body)
		loItem.unread = .F. && Mark it as a read message
	Endif
Next
oForm.grid1.RecordSource="myEmails"
Select myEmails
Locate
oForm.Show()
>>I need an example of Outlook automation to read an entire folder of emails, such as scanning each email and getting access to its content.
>
>Here is a way to do it, by collecting the information into a cursor and showing the result in a form.
>
>
Public oForm
>oForm = Createobject("form")
>oForm.Width = 600
>oForm.height = 500
>oForm.AddObject("grid1","grid")
>oForm.grid1.Width = 590
>oForm.grid1.height = 490
>oForm.grid1.ColumnCount = 4
>oForm.grid1.Visible = .T.
>Create Cursor myEmails (From c(20),daterec d,subject c(20),content M)
>oOutLookObject = Createobject("Outlook.Application")
>olNameSpace = oOutLookObject.GetNameSpace("MAPI")
>myEmails=olNameSpace.GetDefaultFolder(6).Items
>For Each loItem In myEmails
>	Insert Into myEmails (From,daterec,subject,content) Values;
>		(loItem.sendername,loItem.ReceivedTime,loItem.subject,loItem.body)
>Next
>oForm.grid1.RecordSource="myEmails"
>Select myEmails
>Locate
>oForm.Show()
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform