Help with sending Mail from Forms 6.0

From: Eric Raskin <eraskin_at_paslists.com>
Date: Thu, 18 Jan 2001 15:53:24 -0500
Message-ID: <t6elth1s4k6n93_at_corp.supernews.com>


Hello all:

I've been on MetaLink and downloaded a description of a Forms Package to send Mail via Exchange using the OLE2 Automation package. When I use it, I get no errors whatsoever -- nothing from OLE2 or any errors at all.

The mail just doesn't go out! I've stepped through the package and found nothing wrong, as far as I know.

Can anyone help me with this or point me to the appropriate docs?

Here is my usage of the package:

DECLARE
 subject varchar2(100);
 message varchar2(100);
 attach varchar2(100);

BEGIN

     if :OUTPUT_ORDLINE.MATERIAL = '3' THEN /* E-Mail */
           subject := :OUTPUT_ORD.LIST || '|' || :OUTPUT_ORDLINE.ORL_DESC ||
'|' ||
                          TO_CHAR(:OUTPUT_ORDLINE.SHIPQTY) || '|' ||
:OUTPUT_ORDLINE.KEYCODE ||
                          '|' || :OUTPUT_ORD.BKRNUM;
           message := 'Please see the README file in the Attached ZIP file
for details.';
            FCA_MAIL.Send(:OUTPUT_ORDLINE.CONTACT, subject, message,
attach);
           FCA_MAIL.Logoff;
           :OUTPUT_ORDLINE.TRACKNUM := :OUTPUT_ORDLINE.CONTACT;
     end if;

END; The following is the package source (it's published on MetaLink, so I guess it's OK for anyone to see/use, right :-) ):

PACKAGE FCA_MAIL 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,
         Attch  IN varchar2 default NULL
          );

END; PACKAGE BODY FCA_MAIL 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;
  ole_errmsg        varchar2(256);
  ole_errnum       number;

  procedure logon( Profile IN varchar2 default NULL) is    BEGIN
    session := ole2.create_obj('MAPI.Session');     args := ole2.create_arglist;

    ole2.add_arg(args, Profile);
    ole2.invoke(session, 'Logon', args);
    ole2.destroy_arglist(args);

   EXCEPTION
    WHEN OLE2.OLE_ERROR THEN

      ole_errnum := ole2.last_exception(ole_errmsg);
      message('OLE ERROR: ' || ole_errmsg);
   END;   procedure logoff is
    BEGIN
     ole2.invoke(session, 'Logoff');
     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);
     ole2.release_obj(msg_attch);
     ole2.release_obj(attachment);

    EXCEPTION
    WHEN OLE2.OLE_ERROR THEN

      ole_errnum := ole2.last_exception(ole_errmsg);
      message('OLE ERROR: ' || ole_errmsg);

    END;   procedure send( Recp IN varchar2,

          Subject   IN varchar2,
          Text    IN varchar2,
          Attch    IN varchar2 default NULL) IS
   BEGIN
/* 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');

    ole2.set_property(message1, 'subject', Subject);     ole2.set_property(message1, 'text', Text);

/* Add a recipient object to the message1.Recipients collection */

    msg_recp := ole2.get_obj_property(message1, 'Recipients');     recipient := ole2.invoke_obj(msg_recp,'add');

/* Add an attachment object to the message1.Attachments collection */

    if Attch is not null then

     msg_attch := ole2.get_obj_property(message1, 'Attachments');
     attachment := ole2.invoke_obj(msg_attch,'add');
     ole2.set_property(attachment,'name',Attch);
     ole2.set_property(attachment,'position',0);
     ole2.set_property(attachment,'type',1); /* 1-MAPI File Data */
     ole2.set_property(attachment,'source',Attch);
      args := ole2.create_arglist;
      ole2.add_arg(args, Attch);
      ole2.invoke(attachment, 'ReadFromFile',args);
      ole2.destroy_arglist(args);

    end if;

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

    ole2.invoke(message1, 'Send', args);

    ole2.destroy_arglist(args);
    message('Message successfully sent to ' || recp);

    EXCEPTION
    WHEN OLE2.OLE_ERROR THEN

      ole_errnum := ole2.last_exception(ole_errmsg);
      message('OLE ERROR: ' || ole_errmsg);

   END; END; Received on Thu Jan 18 2001 - 21:53:24 CET

Original text of this message