Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send e-mail with oracle

Status
Not open for further replies.

Joeyp

Programmer
Nov 5, 2001
4
0
0
BR
I'd like to create a procedure that can send an e-mail with attached file.
Does anybody know how can I do this???
Anybody has i.e?

Thnxs. :D
 
I use the following procedure to send mail using outlook, you can play about with it so that you preview the mail before it is sent or choose to send it straight away (by just commenting out the 'display' or 'send' lines).

James

---------------------
PROCEDURE SENDMAIL IS
objOutlook OLE2.OBJ_TYPE;
objMail OLE2.OBJ_TYPE;
objArg OLE2.LIST_TYPE;
objAttach OLE2.OBJ_TYPE;
BEGIN
objOutlook := OLE2.CREATE_OBJ('Outlook.Application');
objarg := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(objarg,0);
objMail := OLE2.INVOKE_OBJ(objOutlook,'CreateItem',objarg);
OLE2.DESTROY_ARGLIST(objarg);
objAttach := OLE2.GET_OBJ_PROPERTY(objmail, 'Attachments');
objarg := OLE2.CREATE_ARGLIST;
OLE2.SET_PROPERTY(objmail,'To', '<E_MAIL ADDRESS>');
OLE2.SET_PROPERTY(objmail,'Subject','<SUBJECT>');
OLE2.SET_PROPERTY(objmail,'Body','<MESSAGE BODY>');
OLE2.ADD_ARG(objarg,'<ATTACHMENT>');
OLE2.INVOKE(objattach, 'Add', objarg);
OLE2.INVOKE(objmail,'Send');
OLE2.INVOKE(objmail,'Display');
OLE2.RELEASE_OBJ(objmail);
OLE2.RELEASE_OBJ(objOutlook);
END;
---------------------------
 
If the main word in your request is SEND rather than ATTACHED, read faq186-231 . Regards, Dima
 
Just thought I would add my 2 cents. We used the UTL_SMTP package routines to send email and it works well for us. Your database has to be set up properly with the Java Virtual Machine installed. I don't think the FAQ referenced above gives the instructions for this, but here is a link to a good article about it:

 
wouldn't it use less memory to have a small perl daemon listen to a queue and do the mailing?

they may have fixed this in 8.1.7 or 8.2 (a.k.a 9i) but when we tested using java within Oracle on 8.1.6 we found it to be a real pig.

our experience has been that it's almost always easier, faster & more reliable to do anything &quot;fancy&quot; (smtp, monitoring, messaging, etc.) in perl (or even just bash) than using Oracle supplied tools/packages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top