sending mail via outlook ole

Emma

Member
i am using the following code to send emails via outlook from progress. This works fine when outlook is already running. If it isn't, the code runs outlook, but doesn't send the email. If i click send i get this error:

Error occurred while accessing component property/method: SEND.
The server threw an exception.

Error code 0x80010105 sendmail d:\temp\p29814cf.ab (5890)


Does anyone have any ideas as to why this is happening, or how i can aleter the code to send them without the errors happening?

Thanks.

Emma.

PROCEDURE sendmail:

DEFINE INPUT PARAMETER vAddress AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER vCCAddress AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER vBCCAddress AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER vSubject AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER vBody AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER vAttach AS CHARACTER NO-UNDO.

DEFINE VARIABLE hNameSpace AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hFolder AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hOutlook AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hOutlookMsg AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hOutlookRecip AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hOutlookAttach AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE vShow AS LOGICAL NO-UNDO.
DEFINE VARIABLE X AS INTEGER NO-UNDO.
DEFINE VARIABLE w-i AS INTEGER INITIAL 1 NO-UNDO.

CREATE "Outlook.Application" hOutlook CONNECT NO-ERROR.

IF hOutlook = ? THEN
DO:
CREATE "Outlook.Application" hOutlook.
ASSIGN vShow = TRUE.
END.
ELSE
ASSIGN vShow = FALSE.

houtlookMsg = hOutlook:CreateItem(0).

DO X = 1 TO NUM-ENTRIES(vAddress):
hOutlookRecip = hOutlookMsg:Recipients:ADD(trim(substring(vAddress,w-i,
(index(vAddress,";")) - 1))).
ASSIGN vAddress = TRIM(SUBSTRING(vAddress,((index(vAddress,";")) + 1),
LENGTH(vAddress))).
hOutlookRecip:TYPE = 1.
END.

DO X = 1 TO NUM-ENTRIES(vCCAddress):
hOutlookRecip = hOutlookMsg:Recipients:ADD(trim(substring(vCCAddress,w-i,
(index(vCCAddress,";")) - 1))).
ASSIGN vCCAddress = TRIM(SUBSTRING(vCCAddress,((index(vCCAddress,";")) + 1),
LENGTH(vCCAddress))).
hOutlookRecip:TYPE = 2.
END.

DO X = 1 TO NUM-ENTRIES(vBCCAddress):
hOutlookRecip = hOutlookMsg:Recipients:ADD(trim(substring(vBCCAddress,w-i,
(index(vBCCAddress,";")) - 1))).
ASSIGN vBCCAddress = TRIM(SUBSTRING(vBCCAddress,((index(vBCCAddress,";")) + 1),
LENGTH(vBCCAddress))).
hOutlookRecip:TYPE = 3.
END.

DO X = 1 TO NUM-ENTRIES(vAttach):
hOutlookAttach = hOutlookMsg:Attachments:ADD(ENTRY(X, vAttach)).
END.

hOutlookMsg:Subject = vSubject.
hOutlookMsg:Body = vBody.
/* hOutlookRecip:Resolve. */
hNameSpace = hOutlook:GetNamespace("MAPI").
/* 3 deleted items, 4 outbox, 5 sent items, 6 inbox */
hFolder = hNameSpace:GetDefaultFolder(4).

IF vShow THEN
hFolder:DISPLAY.

hOutlookMsg:DISPLAY.

hOutlookMsg:SEND. /* sends the email message */


RELEASE OBJECT hOutlookAttach NO-ERROR.
RELEASE OBJECT hOutlookRecip NO-ERROR.
RELEASE OBJECT hOutlookMsg NO-ERROR.
RELEASE OBJECT hFolder NO-ERROR.
RELEASE OBJECT hNameSpace NO-ERROR.
RELEASE OBJECT hOutlook NO-ERROR.
END PROCEDURE.
 
Back
Top