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
here's the procedure it's running through the Os command.
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.