Hello,
I have some code I'm using to fill in a couple email properties such as attachments, subject and body. When it runs it pops up the outlook email and they just type who they want this to go to and then send. Everything works great and sends. The problem I am having is that outlook dialog is moved behind current screens and not made the active screen.
What I would like to achieve is the ability to bring to front and make this dialog the active window.
Can anyone help me with this?
Thanks,
I have some code I'm using to fill in a couple email properties such as attachments, subject and body. When it runs it pops up the outlook email and they just type who they want this to go to and then send. Everything works great and sends. The problem I am having is that outlook dialog is moved behind current screens and not made the active screen.
What I would like to achieve is the ability to bring to front and make this dialog the active window.
Can anyone help me with this?
Thanks,
Code:
DEFINE INPUT PARAMETER iEmailTo AS CHARACTER NO-UNDO. /* TO string ";" Delimits */
DEFINE INPUT PARAMETER iEmailCC AS CHARACTER NO-UNDO. /* CC string ";" Delimits */
DEFINE INPUT PARAMETER iEmailBCC AS CHARACTER NO-UNDO. /* BCC string ";" Delimits */
DEFINE INPUT PARAMETER iEmailSubject AS CHARACTER NO-UNDO. /* Subject string */
DEFINE INPUT PARAMETER iEmailBody AS CHARACTER NO-UNDO. /* Body string */
DEFINE INPUT PARAMETER iImportance AS CHARACTER NO-UNDO. /* Priority string 0-2 */
DEFINE INPUT PARAMETER iReadReceipt AS LOGICAL INIT FALSE NO-UNDO. /* Read Receipt Logical */
DEFINE INPUT PARAMETER iDeliveryReceipt AS LOGICAL INIT FALSE NO-UNDO. /* Delivery Receipt Logical */
DEFINE INPUT PARAMETER iAttachment AS CHARACTER NO-UNDO. /* Attachments sting ";" Delimits */
DEFINE VARIABLE hApplication AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hNameSpace AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hMail AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE X AS INTEGER NO-UNDO.
CREATE "Outlook.Application" hApplication NO-ERROR.
IF NOT VALID-HANDLE(hApplication) THEN
DO:
MESSAGE "Could not create outlook application." VIEW-AS ALERT-BOX ERROR.
LEAVE.
END.
ASSIGN hNameSpace = hApplication:GetNameSpace("MAPI").
IF NOT VALID-HANDLE(hNameSpace) THEN
DO:
MESSAGE "Could not get required namespace." VIEW-AS ALERT-BOX ERROR.
LEAVE.
END.
/* Parameters are: Profile, Password, Show dialog, New session */
hNameSpace:Logon("Outlook", "", FALSE, TRUE).
ASSIGN hMail = hApplication:createItem(0).
/** Assign data **/
ASSIGN
hMail:TO = iEmailTo
hMail:Subject = iEmailSubject
hMail:CC = iEmailCC
hMail:BCC = iEmailBCC
hMail:Body = iEmailBody
hMail:Importance = iImportance
hMail:OriginatorDeliveryReportRequested = iDeliveryReceipt
hMail:ReadReceiptRequested = iReadReceipt.
IF iAttachment <> "" THEN
DO:
DEFINE VARIABLE tmpAtt AS CHARACTER NO-UNDO.
DEFINE VARIABLE tmpName AS CHARACTER NO-UNDO.
REPEAT X = 1 TO NUM-ENTRIES(iAttachment, ";"):
tmpAtt = hMail:Attachments:Add(TRIM(ENTRY(X, iAttachment, ";"))).
IF SEARCH(tmpAtt) <> ? THEN
DO:
tmpName = SUBSTRING(tmpAtt, R-INDEX(tmpAtt, "/"), LENGTH(tmpAtt) - R-INDEX(tmpAtt, "/")).
hMail:Attachments:Add(tmpAtt).
hMail:Attachments(X):DisplayName = tmpName.
END.
END.
END.
/** view mail **/
hMail:Display(1).
/*chMail:SEND().*/
RELEASE OBJECT hMail NO-ERROR.
RELEASE OBJECT hNameSpace NO-ERROR.
RELEASE OBJECT hApplication NO-ERROR.