FOR EACH loAttachment IN loMess.Attachments IF loAttachment.Type = 1 loAttachment.SaveAsFile("C;\Downloads\"+loAttachment.FileName) ENDIF ENDFORextract from: http://www.aksel.com/whitepapers/OutlookAutomation.htm
LOCAL loOutlook AS Outlook.Application LOCAL loNameSpace AS Outlook.NameSpace LOCAL loInBox AS Object LOCAL loMess AS Outlook.MailItem LOCAL lnUnRead AS Integer &&(1) #DEFINE olFolderInBox 6 loOutlook = CREATEOBJECT('Outlook.Application') && loNameSpace = loOutlook.GetNamespace("MAPI") loInBox = loNameSpace.GetDefaultFolder(olFolderInBox) &&(2) lnUnRead = 0 *-- At this point we have the InBox Object. *-- Let's display how many messages we have in the Inbox. ? "You have " + TRANSFORM(loInBox.Items.Count) + " Messages" FOR EACH loMess IN loInBox.Items IF loMess.UnRead wordfound = "N" lnUnRead = lnUnRead + 1 set alte to m.txt set alte on ? "************************" ? ? "Subject: " + loMess.Subject ? "Body: " + loMess.body ? "************************" ? ? close alte modi file.m.txt do emcheck if wordfound = "Y" **loItem.unRead = .F. && Mark it as read endif close alte ELSE *? "Read Message Subject: " + loMess.Subject ENDIF ENDFOR ? "Total of UnRead Messages " + TRANSFORM(lnUnRead) proc emcheck close alte if 'TestWord'$cFile = .T. wordfound = "Y" cFile = Filetostr("c:\db\prg\menu\m.txt") && store the text file wait window "YES - do processing" else wait window "no - skip this one" endif wordfound = "Y"