Kbase P146487: 4GL/ABL: How to access the names the attachments to an Outlook e-mail message via 4GL/ABL?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/18/2009 |
|
Status: Unverified
GOAL:
4GL/ABL: How to access the names the attachments to an Outlook e-mail message via 4GL/ABL?
GOAL:
How to programmatically save the attachments of an Outlook e-mail message under their original names in a given local directory?
FACT(s) (Environment):
Windows
Progress 9.x
OpenEdge 10.x
FIX:
The following code sample demonstrates:
1. How to access the number of attachments of an Outlook message.
2. How to access the individual file names of these attachments.
3. How to save these attachments under their original file names in a given local directory.
This code assumes that Outlook is open and that a message with one or more attachments is currently selected:
DEFINE VARIABLE myOlApp AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE myInspector AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE myItem AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE myAttachments AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE iNumAttachments AS INTEGER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DEFINE VARIABLE cAttachmentPath AS CHARACTER NO-UNDO.
DEFINE VARIABLE cAttachmentName AS CHARACTER NO-UNDO.
CREATE "Outlook.Application" myOlApp.
ASSIGN
myInspector = myOlApp:ActiveInspector
myItem = myInspector:CurrentItem
myAttachments = myItem:Attachments
iNumAttachments = myAttachments:COUNT
cAttachmentPath = "C:\myAttachments\".
DO iCounter = 1 TO iNumAttachments:
ASSIGN
cAttachmentName = myAttachments:Item(iCounter):FILENAME.
myAttachments:Item(iCounter):SaveAsFile(cAttachmentPath + cAttachmentName).
END.
RELEASE OBJECT myOlApp.
RELEASE OBJECT myInspector.
RELEASE OBJECT myItem.
RELEASE OBJECT myAttachments.
ASSIGN
myOlApp = ?
myInspector = ?
myItem = ?
myAttachments = ?.