Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to insert records into a Database table from an Email ?
Hello Faiz,
Yes it is possible to make it, I you dispatch this file in which you will
find the method that will allow you to send
messages of tone application and in adding there the code following that
will allow you to receive these message in tone application:
declare
session_inbox_messages ole2.obj_type; session_inbox ole2.obj_type; list ole2.list_type; senderobj ole2.obj_type;
begin
session_inbox:=ole2.get_obj_property(session,'inbox');
session_inbox_messages:=ole2.get_obj_property(session_inbox,'messages');
if session_inbox_messages=0
then message('L"ouverture de la boite de recéption a échoué!'); else
liste:=ole2.create_arglist; ole2.add_arg(liste,'IPM.NOTE'); message2:=ole2.invoke_obj(session_inbox_messages,'GetLast',liste); ole2.destroy_arglist(liste); if (message2!=0)then nbr:=ole2.get_num_property(message2,'Timereceived'); select to_date('30/12/1899','dd/mm/yyyy')+nbr into date_received from dual; end if; if ole2.get_char_property(message2,'Unread')!='0' then ole2.set_property(message2,'Unread','0'); ole2.invoke(message2,'Update');
senderobj:=ole2.get_obj_property(message2,'sender');
if senderobj!=0 then :sender_name:=ole2.get_char_property
(senderobj,'name');
end if;
ole2.release_obj(senderobj);
nbr:=ole2.get_num_property(message2,'Timereceived'); select to_date('30/12/1899','dd/mm/yyyy')+nbr into :lrdemmiss.date_demmiss from dual; select to_date('30/12/1899','dd/mm/yyyy hh24:mi:ss')+nbr into :heure_received from dual;
end;
It is necessary to know the objets of messages
<<Olemsg.zip>>
Excuse my very bad english:-)
LYNDA HAOUHACH
Ingénieur Systèmes
SONATRACH LTH
Émail: lhaouhach_at_lth.sonatrach.dz
<<47498.1.html>>
> -----Message d'origine-----
> De: FAIZ QURESHI [SMTP:faizq_at_hotmail.com]
> Date: lundi 21 janvier 2002 06:30
> À: Multiple recipients of list ORACLE-L
> Objet: How to insert records into a Database table from an Email ?
>
> Hello All:
> I have a situation where emails sent to an Email Id should get inserted
> into
> a database 1,e some part of the email should get inserted as records in a
> particular table. Like for example the Person's Name(who sent the email)
> should get inserted in the Name field of the table, Subject should get
> inserted in the subject field, Body should get inserted in the body field
> of
> the table.
> I am already using ole2 to send automated emails from my application. But
> is
> the reverse also possible ?
> Is there any way to do this.
> Regards,
> Faiz
>
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: FAIZ QURESHI
> INET: faizq_at_hotmail.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
Olemsg.zip
Description: Binary data
The previous attachment was filtered out by the ListGuru mailing software at fatcity.com because binary attachments are not appropriate for mailing lists. If you want a copy of the attachment which was removed, contact the sender directly and ask for it to be sent to you by private E-mail.
This warning is inserted into all messages containing binary attachments which have been removed by ListGuru. If you have questions about this message, contact Postmaster_at_fatcity.com for clarification.
Title: header
Article-ID: <Note:47498.1> Circulation: PUBLISHED (EXTERNAL) Folder: client.Dev2000.Forms.V4 Platform: GENERIC Generic issue Topic: Oracle Forms Hints - MS Windows Specific (OLE, DDE etc.) 95 Modified-Date: 14-MAY-1998 11:54:40 Revision: 1 Document-Type: FAQ Document ID: 13000147.6 Title: Programmatically sending a Fax/Email via Microsoft Exchange Author: Varun Puri (vpuri.in) Department: IN: IPEC-ESG Creation Date: 26 May 1997 Last Revision Date: 04 Feb 1998 Expiration Date: 26 May 1998 Revision Number: 3 Distribution Code: External Category: SQL*Forms Product: Developer/2000 Forms Product Version: V45 Platform: Windows 95, WindowsNT 4.0 Information Type: Advisory Impact: Medium Abstract: This bulletin explains how to programmatically send a fax/email from a Forms/Reports application via Microsoft Exchange using OLE2 Keywords: DEVELOPER/2000;FORMS;REPORTS;FAX;EMAIL;EXCHANGE;OLE;OLE2 _______________________________________________________________________________ Programmatically sending a Fax/Email via Microsoft Exchange ===========================================================
INTRODUCTION:
This bulletin explains how to programmatically send a fax/email message from a Forms/Reports application via Microsoft Exchange without any kind of user interaction. It shows the general usage of the 'Mailx' package as well as a fully coded Forms sample application.
The concept of OLE (Object Linking and Embedding) automation is used to control
the OLE server application (Microsoft Exchange) using the client application.
The client in this case may be a Developer/2000 Forms or Reports application.
It uses the objects and methods exposed by the OLE Messaging Library which are
much more robust than the MSMAPI OCX controls and allow access to many more
MAPI
properties.
Oracle provides support for OLE automation in its applications by means of the OLE2 built-in package. This package contains object types and built-ins for creating and manipulating the OLE objects. Some of these built-ins for e.g. OLE2.create_obj, OLE2.invoke, OLE2.set_property have been extensively used in the code.
Note for Windows'95 users:
The example in this bulletin assumes that the OLE Messaging Library was properly
installed on your machine (typically, by installing Exchange in Windows NT).
Since the OLE Messaging Library was released after Windows'95, it is NOT
included
as a part of the Windows'95 Exchange client. I have included a simple script
and
the necessary files to install this OLE Messaging component which is archived
in
OLEW95.ZIP file. This can be obtained by accessing the following URL:
ftp://anonymous:userid@www-ess8.oracle.com/desktop/download/olem95.zip
Replace userid by your valid user id on MetaLink.
GENERAL USAGE:
The Mailx package contains three procedures:
This is the procedure that actually sends the message and attachments, if any, to the recipient. The recipient may be specified directly as a valid email address or as an alias defined in the address book. If the message is intended for a fax recipient then a valid alias must be used that is defined as a fax address in the address book.
3. Procedure Mailx.logoff;
This procedure closes the Exchange session and deallocates the resources used by the OLE automation objects.
SAMPLE FORMS APPLICATION:
(a) Mailx Package Spec
(b) Mailx Package Body
Mailx Package Spec:
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, Attch IN varchar2 );
END; Mailx 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 Begin
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;
procedure logoff is
Begin
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;
procedure send( Recp IN varchar2, Subject IN varchar2, Text IN varchar2, Attch IN varchar2 )is
/* 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') ;
ole2.set_property(recipient,'name',Recp); ole2.set_property(recipient,'type',1); ole2.invoke(recipient,'resolve');
/* Add an attachment object to the message1.Attachments collection */
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);
/* Read the attachment from the file */
args := ole2.create_arglist;
ole2.add_arg(args,Attch); ole2.invoke(attachment,'ReadFromFile',args); ole2.destroy_arglist(args);
args := ole2.create_arglist;
ole2.add_arg(args,1); /* 1 => save copy */
ole2.add_arg(args,0); /* 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; 2. Create a block called MAPIOLE with the following canvas layout:
|-----------------------------------------------------------------------| | | | Exchange Profile: |====================| | | | | To: |============================| | | | | Subject: |============================| | | | | Message: |============================| | | | | | | | | | | | | | | | | | | | | | | |============================| | | |-----------| | | Attachment: |============================| | SEND | | | |-----------| | |-----------------------------------------------------------------------|
The layout contains 5 text-itmes:
and a 'Send' button with the following WHEN-BUTTON-PRESSED trigger:
Mailx.logon(:profile); Mailx.send(:to,:subject,:message,:attch); Mailx.logoff;
CONCLUSION:
This bulletin explained how to create a sample Forms application which can send a fax/email using OLE automation. The same concept/code can be extended to programmatically fax/email an Oracle Report without any user interaction. In order to fax a report, first generate the report output as a PDF file and then send this to the fax recipient as an attachment using the same Mailx Package.
REFERENCES:
Oracle India Development Center Electronic Services Group
Information from Oracle Corporate Repository.
Received on Mon Jan 21 2002 - 03:15:41 CST