*!* Credit goes to mgagnon and his FAQ:
*!* Useful functions with Outlook Automation faq184-3894
*!* for the first part of this code automating Outlook
Local oOutlookObject,olNameSpace
#Define olFolderInBox 6
oOutlookObject = Createobject("Outlook.Application")
olNameSpace = oOutlookObject.GetNameSpace("MAPI")
oItems= olNameSpace.GetDefaultFolder(olFolderInBox).Items
For Each loItem In oItems
If loItem.unRead
GetFilesFromEmail(loitem.htmlbody) && or use body which contains HYPERLINK "
Endif
NEXT
FUNCTION GetFilesFromEmail(tcBody)
LOCAL lnCounter, lnAt, lcLink, lcPart
FOR lnCounter = 1 TO 1000 && there probably will never be 1000 links
lnAt = AT([<a href="],tcBody,lnCounter) + 9
IF lnAt > 9
lcPart = SUBSTR(tcBody,lnAt)
lcLink = LEFT(lcPart,AT(["],lcPart,1) - 1)
GetFileFromWeb(lcLink) &&If you want it automated further then you will need to use InternetReadFile and InternetOpenUrl among others
ELSE
EXIT
ENDIF
ENDFOR
ENDFUNC
PROCEDURE GetFileFromWeb(tcLink)
Local tcLink, nRet
Declare DoFileDownload IN shdocvw.dll STRING lpszFile
tcLink = HandleUnsafeChars(tcLink)
IF !EMPTY(tcLink)
nRet=DoFileDownload(STRCONV(tcLink,5))
ELSE
MESSAGEBOX("Function returned an empty length string.",16,"Something is Wrong")
ENDIF
ENDPROC
************************
FUNCTION HandleUnsafeChars(sAddressUrl)
***Purpose: Change unsafe chars to escape sequences
************************
#DEFINE ICU_BROWSER_MODE 33554432 && 0x2000000
DECLARE INTEGER InternetCanonicalizeUrl IN wininet;
STRING sURL, STRING @sBUFFER, INTEGER @nLength, INTEGER nFlags
LOCAL sNewUrl, nResult
nResult = 250
sNewUrl = Replicate(Chr(0), nResult)
IF InternetCanonicalizeUrl (sAddressUrl,@sNewUrl, @nResult, ICU_BROWSER_MODE) <> 0
RETURN Left(sNewUrl, nResult)
ELSE
RETURN ""
ENDIF
ENDFUNC &&HandleUnsafeChars