Get rid of those annoying dialogs when sending emails through outlook

This Code sample i posted at progresstalk. I found a place where i could write a snippet and have others be able to access it easily.

This little trick (I translated it from some VB code) will help you get away with the windows dialogs when sending email through out look.

I'm not a big user of SMTPMail.p because we have smtp disabled here, and we use MAPI. It seems like most people prefer SMTP. But i found a way to bypass outlook security. Get rid of those annoying windows dialogs that says another program is accessing outlook, do you allow this?

First step is to go to http://www.dimastr.com/redemption/download.htm I downloaded the developer's edition. And click the install file. It basically just puts a redemption folder in prog file or where ever you select it and registers the dll and puts it in that folder.

Basic way (with the pop ups)

DO WITH FRAME {&FRAME-NAME}:
    
    DEFINE VARIABLE attach-name  AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE Folder       AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE MailItem     AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE message-text AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE NameSpace    AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE Outlook      AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE Recipient    AS COM-HANDLE   NO-UNDO.

    CREATE "Outlook.Application" Outlook.
        
    ASSIGN 
        NameSpace   = Outlook:GetNameSpace("MAPI":U)
        Folder      = NameSpace:GetDefaultFolder(6).

    ASSIGN 
        MailItem            = Folder:Items:Add()
        MailItem:To         = TRIM(scr-To:SCREEN-VALUE)
        MailItem:Subject    = TRIM(scr-Subject:SCREEN-VALUE)
        MailItem:Body       = TRIM(ed-Body:SCREEN-VALUE).

    MailItem:SEND().

    RELEASE OBJECT MailItem  NO-ERROR.
    RELEASE OBJECT Folder    NO-ERROR.
    RELEASE OBJECT NameSpace NO-ERROR.
    RELEASE OBJECT Outlook   NO-ERROR.
    RELEASE OBJECT Recipient NO-ERROR.

END.

END PROCEDURE.

Way to get rid of those pop ups

DO WITH FRAME {&FRAME-NAME}:
    
    DEFINE VARIABLE attach-name  AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE Folder       AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE MailItem     AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE message-text AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE NameSpace    AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE Outlook      AS COM-HANDLE   NO-UNDO.
    DEFINE VARIABLE Recipient    AS COM-HANDLE   NO-UNDO.
    /* A new SafeItem Com-handle */
    DEFINE VARIABLE SafeItem     AS COM-HANDLE   NO-UNDO.

    CREATE "Outlook.Application" Outlook.
        
    ASSIGN 
        NameSpace   = Outlook:GetNameSpace("MAPI":U)
        Folder      = NameSpace:GetDefaultFolder(6)
        attach-name = scr-Attach:SCREEN-VALUE.

    ASSIGN 
        MailItem            = Folder:Items:Add()
        MailItem:To         = TRIM(scr-To:SCREEN-VALUE)
        MailItem:Subject    = TRIM(scr-Subject:SCREEN-VALUE)
        MailItem:Body       = TRIM(ed-Body:SCREEN-VALUE).

    /* Create a SafeItem object from Redemption.DafeMailItem */
    CREATE "Redemption.SafeMailItem" SafeItem.
        
    /* Points it to the MailItem */
    SafeItem:item = MailItem.
    /* Sends it as a SafeItem and not a MailItem */
    SafeItem:SEND().

    RELEASE OBJECT MailItem  NO-ERROR.
    RELEASE OBJECT Folder    NO-ERROR.
    RELEASE OBJECT NameSpace NO-ERROR.
    RELEASE OBJECT Outlook   NO-ERROR.
    RELEASE OBJECT SafeItem  NO-ERROR.

END.

END PROCEDURE.

AttachmentSize
Redemption.zip1023.14 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

.

.