Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Open Attachments in Outlook Automation
Message
 
 
To
06/03/2010 16:37:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01452944
Message ID:
01452982
Views:
60
>So far so good. The code at bottom scans for new unread emails and captures and displays the email in text format.
>Last phase not working.
>
>FOR EACH loAttachment IN loMess.Attachments
>   IF loAttachment.Type = 1
>   loAttachment.SaveAsFile("C;\Downloads\"+loAttachment.FileName)
>   ENDIF
>ENDFOR
>
>extract from: http://www.aksel.com/whitepapers/OutlookAutomation.htm
>
>I need to open and store attachments that come with the email in a folder called downloads. I have tried various placements of the code above without success - should it work? - if so, how would I integrate it with code below to collect the attachement my downloads directory.
>
>(i had added these lines to the code below and it now runs without error but also without effect. But it's guesswork on my part
>local loAttachment as object && at this locale (1)
>loattachment = lonamespace.getattachment(olfolderinbox) &&(2)
>
>many thanks
>k
>
>
>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"
>	
>
Strange program - what exactly you're trying to achieve and why did you put set alternate command in there? There are many other ways to create a test file.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform