Read Receipts, Delivery Receipts, and Send on Behalf of

dayv2005

Member
I couldn't find anywhere to write a specific document on this so i figured I'd start it here till i found out where you post this stuff.

There was this puzzling feature we needed over here at our company. We spent numerous amount of time looking for this, not getting much help on the forums, i finally figured it out and figured i'd share it. If you already knew this sorry, if not i hope this helps.

Well here's the example i used.

Code:
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)
        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)
        MailItem:CC         = TRIM(scr-CC:SCREEN-VALUE)
        MailItem:Bcc        = TRIM(scr-BCC:SCREEN-VALUE)
        MailItem:Importance = rs-priority:SCREEN-VALUE.
    

    /* This is for Delivery Receipts */
        MailItem:OriginatorDeliveryReportRequested = IF tDilivReceipt:SCREEN-VALUE = "YES" 
                                                        THEN TRUE ELSE FALSE. /* Logical */
    /* This is for Read Receipts */
        MailItem:ReadReceiptRequested              = IF tReadReceipt:SCREEN-VALUE = "YES"
                                                        THEN TRUE ELSE FALSE. /* LOGical */
                   
    /* This is to send on behalf */
    IF scr-BehalfOf:SCREEN-VALUE <> "" THEN
        MailItem:SentOnBehalfOfName = scr-BehalfOf:SCREEN-VALUE. /*String Email*/
        
    IF scr-Attach:SCREEN-VALUE <> "" THEN
        MAilItem:Attachments:ADD(attach-name).
    
    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.
 
AFAIK this approach will be caught by the increased security in any releases beyond Outlook 2003 (SP1?).

Perhaps not a big problem if you don't mind the user needing to click OK on a prompt to allow the applicaiton to access Outlook.

If you are sending a batch of emails, it could become a problem. There was a workaround developed for VB which works around this http://www.dimastr.com/redemption/
 

tamhas

ProgressTalk.com Sponsor
You could contribute a page on OE Hive. It would be great if someone put together a book there of mail issues and solutions.
 

dayv2005

Member
I went a head and did that. It's just a blog entry with snippets. Haven't got around to writing pages yet. If i get some free time i might do that. But some of this code is code i wrote and some is some things other people sent me. I still have a bunch more of newer snippets that need added

But here is the link.

http://www.oehive.org/node/1093
 
Top