Re: Sending e-mail from Forms 5.0
Date: 1998/02/02
Message-ID: <34D58EFD.971A32FF_at_isa.dknet.dk>#1/1
On a buttom use:
mailx.logon(null);
mailx.send(null,null,null,1);
where the package spec is:
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; and the BODY is:
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
Begin
if session is null then
session := ole2.create_obj('mapi.session'); /* create the session object
*/
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
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
Begin
if session is null then
message('Kan ikke sende mails. Er ikke logget på systemet');
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');
-- if subject is not null or text is not null then
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;
-- 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;
Hope it helps
Med venlig hilsen / Best regards
Karsten Weikop PBJ Consult A/S E-mail: kw_at_pbj.dk Roholmsvej 10GPhone: +45 43 62 74 00 DK-2620 Albertslund Fax: +45 43 62 74 24 Denmark
Adrian G. Klingel wrote:
> Got any ideas on how to do this? I'm storing e-mail addresses in the
> database, and I already know I can write to a text file. I'm using MS
> Exchange for e-mail, which seems to be pretty limited at the command
> line. I can spawn Exchange from a button in my form, and it will come
> up with a new message containing the text from the text file I wrote to,
> but I don't know how to put the address in the address block. Is this
> something I'll have to do on the server side, like a cron job or
> something? Like I could write a job that runs a SQL*Plus report, spools
> the data to the file, then mails it automatically to a person of my
> choosing. Please comment on my plans, or shoot them down, or whatever.
> If you've done this before, please help!
>
> Have a good one,
> Adrian Klingel
> Consultant
Received on Mon Feb 02 1998 - 00:00:00 CET
