Re: Sending email from Forms 4.5

From: Clint Redwood <clint.redwood_at_bcm-ltd.co.uk>
Date: 2000/05/09
Message-ID: <8f8kae$hc4$1_at_nnrp1.deja.com>#1/1


In article <8f2064$79e$1_at_nslave1.tin.it>,   "Antonio D'Ambrosio" <pesce.rosso_at_clubnet.it> wrote:
> Hi, I have a problem.
> I want to send a mail from a form, but I don't want to use OLE.
> I'd like to use a small and free programatic interface indipendently
 from
> the mailer of the user.
> Is there anybody that can help me ?
>
> Thank you in advance
>
>
I suspect you will need to use ole. I have used MAPI objects, which should be mailer independant (assuming the mailer is MAPI compliant)

It's actually very easy (using outlook anyway). I used the following code, which I'm sure can be improved on but it did work

PROCEDURE P_MAIL (p_subject VARCHAR2, p_body VARCHAR2, p_address VARCHAR2) IS   hKey PLS_INTEGER := 0;
  lType PLS_INTEGER;
  vData VARCHAR2(2000);
  vValue VARCHAR2(2000);
  lLength PLS_INTEGER := 2000;
  def_prof VARCHAR2(2000);
  dummy PLS_INTEGER := NULL;

	a OLE2.OBJ_TYPE;
	b OLE2.OBJ_TYPE;
	c OLE2.OBJ_TYPE;
	d OLE2.OBJ_TYPE;
	e OLE2.OBJ_TYPE;
	f OLE2.OBJ_TYPE;

	args OLE2.LIST_TYPE;

BEGIN

  • Get the default mapi profile from NT registry IF Registry.RegOpenKey( Registry.HKEY_CURRENT_USER, 'Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles', hKey ) = 0 THEN IF Registry.RegQueryValueEx( hKey, 'DefaultProfile', 0, lType, vData, lLength ) = 0 THEN def_prof := SUBSTR( vData, 1, lLength ); END IF; dummy := Registry.RegCloseKey( hKey ); END IF; IF def_prof IS NULL THEN MESSAGE( 'Unable to determine default mail profile.' ); END IF; a := OLE2.CREATE_OBJ('MAPI.Session'); args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, def_prof); OLE2.INVOKE(a, 'Logon', args); OLE2.DESTROY_ARGLIST(args); b := OLE2.GET_OBJ_PROPERTY(a, 'Outbox'); c := OLE2.GET_OBJ_PROPERTY(b, 'Messages'); args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, p_subject); OLE2.ADD_ARG(args, p_body); d := OLE2.INVOKE_OBJ(c, 'Add', args); OLE2.DESTROY_ARGLIST(args); e := OLE2.GET_OBJ_PROPERTY(d, 'Recipients'); args := OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(args, p_address); f := OLE2.INVOKE_OBJ(e, 'Add', args); OLE2.DESTROY_ARGLIST(args); OLE2.INVOKE(f, 'Resolve'); OLE2.INVOKE(d, 'Send'); OLE2.RELEASE_OBJ(f); OLE2.RELEASE_OBJ(e); OLE2.RELEASE_OBJ(d); OLE2.RELEASE_OBJ(c); OLE2.RELEASE_OBJ(b); OLE2.RELEASE_OBJ(a); END;
--
Clint Redwood.

Note: Any oppinions expressed are my own and may not reflect the views
of my employer.
No warranty can be given to the correctness of any information given.


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Tue May 09 2000 - 00:00:00 CEST

Original text of this message