Problems with File Attachments to Outlook using Progress

Chris Kelleher

Administrator
Staff member
I was wondering if someone could help me out with this... I am sending an email message with a file attachment from Progress. Everything is working fine, with one small exception: When I open up the email message in Outlook, there is an icon at the bottom with the name of the attachment (file.doc) as expected. However, when I double-click on the attachement to open it in Word, Outlook prompts me to save it first, and the default filename is something like att6.tmp. This is causing problems when sending this email to a fax server email address, since it doesn't know it's a .doc file, it thinks it is a .tmp (unknown) file.

Here is the code I am using:
Code:
/*------------------------------------------------------------------------------
  Purpose:     
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/
DEFINE INPUT PARAMETER ipMessageCompany AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ipMessageSendTo  AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ipMessageSendNum AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ipMessageSubject AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ipMessageText    AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER ipMessageAttach  AS CHARACTER NO-UNDO.

DEFINE VARIABLE iCounter  AS INTEGER   NO-UNDO.
DEFINE VARIABLE cSendNum  AS CHARACTER NO-UNDO.
DEFINE VARIABLE cSendTo   AS CHARACTER NO-UNDO.
DEFINE VARIABLE cFileName AS CHARACTER NO-UNDO.

define variable chSession   as com-handle no-undo.
define variable chMessage   as com-handle no-undo.
define variable chRecipient as com-handle no-undo.
define variable chAttach    as com-handle no-undo.

DisplayMessage("Sending Email Fax from Outlook...").

create "MAPI.session" chSession.


chSession:logon( 
    getRegistryValue("HKEY_CURRENT_USER",
"Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem",
"Profiles", 
"DefaultProfile")
                ).

chMessage = chSession:outbox:messages:add.

chMessage:Type    = "IPM.Note".
chMessage:Subject = ipMessageSubject.
chMessage:Text    = ipMessageText + CHR(10).

cFileName         = "C:\rtufax\" + ipMessageCompany + ".doc".

chAttach          = chMessage:Attachments:Add.
chAttach:Name     = cFileName.
chAttach:Type     = 1.
chAttach:ReadFromFile(cFileName).

REPEAT iCounter = 1 TO NUM-ENTRIES(ipMessageSendNum):
    ASSIGN
      cSendTo        = REPLACE(ipMessageSendTo," ","")
      cSendNum       = TRIM( ENTRY (iCounter,ipMessageSendNum) )
      cSendNum       = IF   (INDEX(cSendNum,"@") EQ 0)
                       THEN ("[FAX:" + cSendTo + "@" + cSendNum + "]")
                       ELSE cSendNum.
    chRecipient      = chMessage:Recipients:Add.
    chRecipient:name = cSendNum.
    chRecipient:Type = 1.
    chRecipient:resolve.
END.

chMessage:Update.
chMessage:send(Yes, No, 0).

release object chAttach.
release object chRecipient.
release object chMessage.
release object chSession.

END PROCEDURE.

Any pointers or suggestions would be appreciated.

Thanks,
-Chris
 

Chris Kelleher

Administrator
Staff member
Well I just figured it out....

I was just searching through some old posts here, and actually found the answer to my question. I needed to replace the ReadFromFile method with the Source method. Here is my new attachement code:
Code:
chAttach          = chMessage:Attachments:Add.
chAttach:Source   = cFileName.
chAttach:Type     = 1.

-Chris
 
Top