Trouble with a com-handle error

dayv2005

Member
I have this email procedure and im having trouble with the come handles of it can someone take a look and tell me what looks wrong.

Here's the part that is initializing my email params
Code:
FOR EACH EmailParams WHERE EmailParams.user-id = OS-GETENV("winstationname") EXCLUSIVE-LOCK:
        DELETE EmailParams.
    END.

    FIND aimdata.UserFile WHERE UserFile.User-ID = USERID("aimdata") NO-LOCK.
   

    CREATE EmailParams.
    ASSIGN
        /*EmailParams.CC                  = 'dpipes@aimntls.com'*/
        /*EmailParams.CustLocation        = tCustLocID*/
        /*EmailParams.EmailTo             = */
        EmailParams.OutputDirectory     = "n:\pro400\tc\" 
        /*EmailParams.Priority            = rs-priority:SCREEN-VALUE*/
        EmailParams.Recep               = "dpipes@aimntls.com"
        EmailParams.Report              = "tc.csv"
        EmailParams.Subject             = "Aim Used Truck Inventory File"
        EmailParams.user-id             = OS-GETENV("winstationname")
        EmailParams.UserEmailAddress    = UserFile.EmailAddress
        /*EmailParams.WEDate              = STRING(tWEDate)*/
        EmailParams.MessageText         = "Test".
    RELEASE EmailParams.

    DEFINE VARIABLE cCommandLine AS CHARACTER  NO-UNDO.

    IF PDBNAME(1) = "driverbdev" THEN
        ASSIGN cCommandLine = 'n:\PROGRESS\bin\prowin32.exe -p n:\pro400\dev\EmailBlockS30.p -pf dev.pf -rr -basekey "INI" -ini progress.ini'.    
    ELSE
        ASSIGN cCommandLine = 'n:\PROGRESS\bin\prowin32.exe -p n:\pro400\exec\EmailBlockS30 -pf live.pf -rr -basekey "INI" -ini progress.ini'.

    OS-COMMAND NO-CONSOLE VALUE(cCommandLine).

    FOR EACH EmailParams WHERE EmailParams.User-ID = OS-GETENV("winstationname") EXCLUSIVE-LOCK:
        DELETE EmailParams.
    END.


here's the procedure it's running through the Os command.

Code:
FIND EmailParams WHERE EmailParams.User-ID = OS-GETENV("winstationname") NO-LOCK.

DEFINE VARIABLE logon-name AS CHAR NO-UNDO.
DEFINE VARIABLE recip-name AS CHAR NO-UNDO.
/* DEFINE VARIABLE priority AS CHAR NO-UNDO. */
DEFINE VARIABLE message-text AS CHAR NO-UNDO. 
DEFINE VARIABLE attach-name AS CHAR NO-UNDO. 
DEFINE VARIABLE chSession AS COM-HANDLE. 
DEFINE VARIABLE chMessage AS COM-HANDLE. 
DEFINE VARIABLE chRecipient AS COM-HANDLE.
DEFINE VARIABLE chAttachment AS COM-HANDLE.
DEFINE VARIABLE chFiles     AS COM-HANDLE.
DEFINE VARIABLE numentries AS INTEGER NO-UNDO.
DEFINE VARIABLE X AS INTEGER NO-UNDO.

/*FIND CustLocation WHERE CustLocation.CustLocID = EmailParams.CustLocation NO-LOCK.*/

ASSIGN
     logon-name   = EmailParams.UserEmailAddress
     attach-name  = EmailParams.OutputDirectory + REPLACE(EmailParams.Report, " ", "")
     message-text = EmailParams.MessageText.
     /*priority   = EmailParams.Priority.*/

CREATE "MAPI.session" chSession. 
IF logon-name = "" THEN chSession:logon NO-ERROR. 
ELSE chSession:logon(logon-name, No, Yes, 0) NO-ERROR.   


chMessage = chSession:outbox:messages:add NO-ERROR.
chMessage:Subject = EmailParams.Subject NO-ERROR. 
chMessage:Type = "IPM.Note" NO-ERROR.
chMessage:Text = message-text NO-ERROR. 
chMessage:Importance = IF priority = "Low" THEN 0 
ELSE IF priority = "High" THEN 2 
ELSE 1 NO-ERROR. 

/* Create multiple Recipient */ 
   

     numEntries = NUM-ENTRIES(EmailParams.Recep, ";").
        REPEAT X = 1 TO NUMENTRIES:
            chRecipient = chMessage:Recipients:Add NO-ERROR. 
            chRecipient:name = string(entry(x,EmailParams.Recep,";")) NO-ERROR. 
            chRecipient:Type = 1 NO-ERROR. 
            chRecipient:resolve NO-ERROR. 
END.
   
    numentries = NUM-ENTRIES(EmailParams.CC, ";").
        REPEAT X = 1 TO NUMENTRIES:
            chRecipient = chmessage:Recipients:ADD NO-ERROR.
            chRecipient:NAME = STRING(ENTRY(X,EmailParams.CC,";")) NO-ERROR.
            chRecipient:TYPE = 2 NO-ERROR.
            chRecipient:resolve NO-ERROR.
        END.

IF EmailParams.EmailTo = "C" THEN
DO:
    chRecipient = chMessage:Recipients:Add NO-ERROR. 
    chRecipient:name = "huston"NO-ERROR. 
    chRecipient:Type = 3 NO-ERROR. 
    chRecipient:resolve NO-ERROR. 
END.
    
MESSAGE 1
    VIEW-AS ALERT-BOX INFO BUTTONS OK.

ASSIGN 
    chMessage:TEXT = chMessage:TEXT
    chFiles        = chMessage:Attachments:ADD()
    chFiles:NAME   = attach-name
    chFiles:SOURCE = attach-name.


MESSAGE 2
    VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* Save and send message */ 
chMessage:Update NO-ERROR. 
chMessage:send(Yes, No, 0) NO-ERROR. 

IF attach-name <> "" THEN release object chAttachment NO-ERROR. 
release object chRecipient NO-ERROR. 
release object chMessage NO-ERROR. 
release object chSession NO-ERROR. 
RELEASE OBJECT chAttachment NO-ERROR.
RELEASE OBJECT chFiles NO-ERROR.


RELEASE EmailParams.
 
The errors that i am getting on this is this.


Invalid componet-handle referenced while processing method/statement: Text
\pro400\dev\EmailBLockS30.p (5884)
unable to set com-handle property (5677)
 
Yeah i seen that before but im trying to make use of a reusable mail class here in my company, they want me to use that class to remain to standards.

so if anyone knows an answer to my solution here, much is appreciated. I Might still mess with that frame work one too, thanks for the link.
 
The errors that i am getting on this is this.


Invalid componet-handle referenced while processing method/statement: Text
\pro400\dev\EmailBLockS30.p (5884)
unable to set com-handle property (5677)

As indicated by the error messages your com handle is invalid when you try and access the TEXT property.

What this means in English is that the object you are trying to manipulate is either not what you think it is, or for some reason is not available to you.

The object in question is chMessage (which has the TEXT property), so either it has been incorrectly instantiated, or it has been derived from another invalid object.

Your code looks syntactically correct (though it took me a while to determine this as you didn't supply a skeleton test case), but your NO-ERRORs are obscuring where the error is first occurring, so remove them and run the code again.

You will possibly find the logon to chSession (from which chMessage is derived) is failing.

Whichever object or property is causing the issue, if you are lucky it will be a data problem (eg. invalid profile for logon in UserFile.EmailAddress).

If you are unlucky, there might be a difficult to find environment configuration (network/ocx version) problem which is causing the issue.

Let us know if you resolve it.
 
thanks for the info I'm going to work on it now that I'm back to work over the holiday. But i should hopefully have it done today (i hope). and thanks for the bit of information. I'll inform you all when i get this error worked out.
 
how about while im troubleshooting this, i get a CC email of one of our salesmen got it to work. I guess it was working fine in our Live Enviroment, and then i was like dang.

So it's working right now, thanks im still unsure of what was causing it, i think probably permissions with my user account or something.
 
to be more specific with this issue, was that it wasnt a coding issue or com handle mess up. It was an outlook error, their was a mismatch in profile names on our exchange server :(... feel dumb now haha
 
You will possibly find the logon to chSession (from which chMessage is derived) is failing.

Whichever object or property is causing the issue, if you are lucky it will be a data problem (eg. invalid profile for logon in UserFile.EmailAddress).

to be more specific with this issue, was that it wasnt a coding issue or com handle mess up. It was an outlook error, their was a mismatch in profile names on our exchange server :(... feel dumb now haha

Thanks for updating us.

I don't wish to labour the subject, but it seems there was a definite coding issue. You have a string of NO-ERRORs with no attempt to catch any of the suppressed errors and report them properly at the correct points.

The reason you had to spend more time than necessary investigating it is because when the error arose (presumably at the log-on point as I suggested), a relevant message,

eg. "Unable to access email for " + logon-name

was not returned.
 
You noob programmer! lol j/k Glad you got it working and I didn't have to come over to your cube and figure it out for you, lol.
 
You noob programmer! lol j/k Glad you got it working and I didn't have to come over to your cube and figure it out for you, lol.

haha I'll remember that next time you are like pipes come here haha jk

Ps this was forever ago i think back when i was working on the web vehicles project.
 
Back
Top