Re: Forms 5.0 and MAPI

From: Robert Clevenger <robc_at_magicnet.net>
Date: 1998/02/18
Message-ID: <6cdn7q$df2$1_at_comet2.magicnet.net>#1/1


Ray Burg wrote in message <887763496.571596_at_mercedes.iniaccess.net.au>... >Does any know how to link forms 5.0 to Microsoft Exchange so I can send >mail, attachments?

Ray,

Here is a basic example, you could modify it to suit your needs.

Robert Clevenger

/*

*
  • PACKAGE SPECIFICATION
  • =====================
    *
    */
    PACKAGE MAILX IS
session OLE2.OBJ_TYPE; /* OLE object handle */ args OLE2.LIST_TYPE; /* handle to OLE argument list */

procedure logon( Profile IN varchar2 default NULL ); procedure logoff;

procedure send( Recp       IN varchar2,
                Subject    IN varchar2,
                Text       IN varchar2,
                dialog     IN number );

END;
/*

  • * *** END OF PACKAGE SPECIFICATION ***
    */
/*

*
  • PACKAGE BODY
  • ============
    *
    */

PACKAGE BODY MAILX IS
  session_outbox OLE2.OBJ_TYPE;
  session_outbox_messages OLE2.OBJ_TYPE;   message1 OLE2.OBJ_TYPE;
  msg_recp OLE2.OBJ_TYPE;
  recipient OLE2.OBJ_TYPE;
  msg_attch OLE2.OBJ_TYPE;
  attachment OLE2.OBJ_TYPE;

procedure logon( Profile IN varchar2 default NULL )is

/*
  • Logon to the MAPI Service Provider using profile named "Profile"
  • If NULL is passed, it uses the default profile.
    */
    Begin if session is null then /*
    • Create the OLE MAPI Session Object */ session := ole2.create_obj('mapi.session');

    args := ole2.create_arglist;

    ole2.add_arg(args,Profile);          /* Specify a valid profile name  */
    ole2.invoke(session,'Logon',args);   /* to avoid the logon dialog box */
    ole2.destroy_arglist(args);

  end if;
End;

procedure logoff is

/*
  • Disconnects from MAPI Service Provider
    */
    Begin if session is not null then ole2.invoke(session,'Logoff'); /* Logoff the session and deallocate the */ /* resources for all the OLE objects */ ole2.release_obj(session); ole2.release_obj(session_outbox); ole2.release_obj(session_outbox_messages); ole2.release_obj(message1); ole2.release_obj(msg_recp); ole2.release_obj(recipient); end if; End;
Procedure send( Recp       IN varchar2,
                Subject    IN varchar2,
                Text       IN varchar2,
                Dialog     IN number default 1)is
/*
  • If Dialog = 0 then this does not display any window to create a message.
  • And you would have to specify values for Recp, Subject, and Text
  • Recp : Recipient of the message
  • Subject : The Subject of the message
  • Text : Message Body.
  • Dialog : 0 => No Dialog will be displayed asking for message
  • : 1 => Dialog will be displayed asking for message
    */
    Begin if session is null then message('[Error][Send]Cannot Allocate MAPI Session.'); return; end if;
   /*
    * Add a new object message1 to the outbox
    */

   session_outbox := ole2.get_obj_property(session,'outbox');    session_outbox_messages :=
ole2.get_obj_property(session_outbox,'messages');
     message1 := ole2.invoke_obj(session_outbox_messages,'Add');
     if subject is not null then
       ole2.set_property(message1,'subject',Subject);
     end if;

     if text is not null then
       ole2.set_property(message1,'text',Text);
     end if;

   /*
  • Add a recipient object to the message1.Recipients collection */ if recp is not null then msg_recp := ole2.get_obj_property(message1,'Recipients'); recipient := ole2.invoke_obj(msg_recp,'add') ; ole2.set_property(recipient,'name',Recp); ole2.set_property(recipient,'type',1); ole2.invoke(recipient,'resolve'); end if;

   args := ole2.create_arglist;
   ole2.add_arg(args,1); /* 1 => save copy */    ole2.add_arg(args,dialog); /* 0 => no dialog */

   /*
    * Send the message without any dialog box, saving a copy in the Outbox
    */

   ole2.invoke(message1,'Send',args);
   ole2.destroy_arglist(args);
   message('Message successfully sent'); End;

END;

/*

  • * *** END OF PACKAGE BODY***
    */
Received on Wed Feb 18 1998 - 00:00:00 CET

Original text of this message