Scheduling a job to send e-mails in Oracle 10g
Hi,
Our application has a scheduled job that runs every hour to fetch data from another application. The SP which this job calls has logic to send e-mails at various stages of the job execution about the status of the job execution. Sometimes, the e-mails are failing due to an SMTP transient error on the server, and thus the job hangs in the RUNNING state.
We were asked to bypass sending the e-mails, and implement that as a separate job. But the problem is that the e-mails are triggered based on some conditions during the main job's execution. So, how is it possible that I can implement just the e-mail thing as a separate job.
Our main job is like below....
1) Job starts -> Send e-mail#1 that the feed started
2) Extract completed and some tables updated-> Send e-mail#2
3) Load to few other tables happened
4) Final Merge to production tables completed -> Send email#3 that the feed is over.
Now, since email #1,2,3 are based on conditional check, how feasible is it to implement these are separate jobs?
Is there any other way that runs the main job even though sending e-mails gets stuck somewhere?
Any help is highly appreciated.
Regards,
Ranganath
Hi,
Can I do something like below. My main job calls a procedure (PRC_SEND_NOTIFICATION) which takes 4 parameters and sends out the e-mails. Now I'm trying to implement sending out the e-mails as a separate job.
-- Run the below Procedure in place of PRC_SEND_NOTIFICATION in the main job.
PRC_EMAIL_JOB ('PRC_SEND_NOTIFICATION (param1,param2,param3,param4)' );
-- Inside the PRC_EMAIL_JOB SP submit the procedure as a job
CREATE OR REPLACE PROCEDURE PRC_EMAIL_JOB (PROC_NAME IN VARCHAR2)
IS
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'Send Email',
job_type => 'STORED_PROCEDURE',
job_action =>PROC_NAME || ';', -- What to run
start_date => SYSDATE, -- Start right away
repeat_interval => NULL ,-- Run only once
comments => 'Send an email',
enabled => TRUE
COMMIT;
END;
Does this new job get dropped as soon as it finishes (as the repeat interval is NULL). So when the main job runs again, this new job gets created again and runs. This is my understanding. Correct me if I'm wrong. Any help is highly appreciated.
Regards,
Ranganath
Similar Messages
-
Hello, all
I have a query that returns on average ~150 rows. I want to set up a job to spool the query's results to a .txt or .csv file and then e-mail it as an attachment.
I am using the sys.utl_mail package to send other query results, however when attempting to use it for this particular query it is failing - presumably due to the 32k size restriction.
Has anyone ran a query returning a number of rows then distributed it via an e-mail attachment? What's the best way to go?
Edited by: user12144603 on Jul 9, 2010 8:12 PMI perhaps should have clarified: I am looking for a way to put query results in an attachment and send them via e-mail. Given certain solutions' limitations I was seeking best practices for doing this. My attachments will certainly exceed the 32k limit of some options.
I decided on the mail_demo package available here: http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt.
There was a terrific post regarding its use here: Re: Send Email with Attachement more than 32K I took the code sample from hoek and plugged my own values in where appropriate.
I am able to populate a .csv with my query results and have it e-mailed it successfully in a .csv (Yay!), however there are two problems:
1. whereas the query returns 150 rows on its own the .csv in my Inbox has 11,325 rows.
2. I would like to put a delimiter between the columns, so the output is more legible
If something jumps out at anyone please advise. Thanks in advance for any assistance.
DECLARE
lv_sender VARCHAR2(200) := '[email protected]';
lv_recipients VARCHAR2(200) := '[email protected]';
lv_subject VARCHAR2(200) := 'Attachment Test';
lv_priority PLS_INTEGER := NULL;
lv_last BOOLEAN := FALSE;
lv_count NUMBER := 0;
lv_message VARCHAR2(32000);
lv_conn utl_smtp.connection;
CURSOR cur_query
IS
select Mycolumn a, Mycolumn2 b, Mycolumn3 c, Mycolumn4 d, Mycolumn5 e, Mycolumn6 f, Mycolumn7 g, Mycolumn8 h, Mycolumn9 i, Mycolumn10 j, Mycolumn11 k, Mycolumn12 l,
Mycolumn13 m, Mycolumn14 n, Mycolumn15 o, Mycolumn16 p, Mycolumn17 q, Mycolumn18 r, Mycolumn19 s, Mycolumn20 t, Mycolumn21 u, Mycolumn v
from
MyTable;
BEGIN
lv_conn:= demo_mail.begin_mail
( lv_sender
, lv_recipients
, lv_subject
, demo_mail.multipart_mime_type
, lv_priority
demo_mail.begin_attachment
( lv_conn
,'text/html'
,FALSE -- Means its not inline
,'test.csv'
,'7 bit'
FOR rec IN cur_query
LOOP
lv_message := lv_message||rec.a||rec.b||rec.c||rec.d||rec.e||rec.f||rec.g||rec.h||rec.i||rec.j||rec.k||rec.l||rec.m||rec.n||rec.o||rec.p||rec.q||rec.r||rec.s||rec.t||rec.u||rec.v||chr(13);
demo_mail.write_text( lv_conn,lv_message);
END LOOP;
demo_mail.end_attachment
( lv_conn
,TRUE
demo_mail.end_mail(lv_conn) ;
END;
Edited by: user12144603 on Jul 10, 2010 10:34 AM -
Send table data through mail in oracle 10g
Hi ,
I am trying to send a mail through oracle 10g .
I can send mail through utl_mail .
The text that I need to send is data from a table .
The table contains information about all the employees .
Table name is person . If the employee is absent on any day without any reason there would be a row of this employee in the table person.
There is also a column named email in this table .
I need to write a stored procedure which will send the data about each particular employee to their respective email for all the employees in the person table .
Can anyone please help me on this .
Thank you.Try this forum thread first:
Re: send email by procedure
There are lots of articles on how to accomplish this taks on the web:
-- utl_smtp example
http://it.toolbox.com/wiki/index.php/Send_email_from_Oracle_Database
http://www.databasejournal.com/features/oracle/article.php/3423431/Sending-e-mail-from-within-Oracle.htm
-- From Application Express product
http://www.oracle.com/technology/products/database/application_express/howtos/howto_workflow.html
HTH -- Mark D Powell -- -
Hi,
I am a newbie in SP2013. I have a task to crate a Timer Job that send e-mail to specific people and in specific time. My situation: there is list "Task for developer" with only 2 field "Developer" - people or group field and "Date"
- date field. Time Job should check current date and date from "Date" and if it current data = "Date" the message to people from "Developer" should be send.
I have never worked with Timer Job. As I uderstand TJ it include some steps:
1) Connect to my site
2) Get my list "Task for developer"
3) Get all item from list
4) Check the field "Date" of all items
5) If current data and "Date" are equal to get all people from "Developer" and formed message.
If I correctly understand help me please to realise it in VS C#.
P.S. Workflow doesn't offer :)
Tank you for any reply :)This has been asked before if you googled it or used search
Take a look
here
Also
here
If this is helpful please mark it so. Also if this solved your problem mark as answer. -
Hi All,
I have a database job to send e-mail.That's great!
We have one too!
But no further questions/problems?
Edited by: hoek on Mar 24, 2009 5:51 PM -
Sending a mail from oracle database
Hi,
I have a requirement to send a mail from oracle database.I use UTL_TCP package for this.Although my procedure is executed successfully,i dont get the mails in my inbox.Please help me to figure out a solution.
Thanks in advance....Hi, you must use UTL_SMTP package for send emails, it has more performance and features for debug. You must look the next code, this is a example for send emails.
DECLARE
c UTL_SMTP.CONNECTION;
PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
BEGIN
UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
END;
BEGIN
c := UTL_SMTP.OPEN_CONNECTION('smtp-server.acme.com');
UTL_SMTP.HELO(c, 'foo.com');
UTL_SMTP.MAIL(c, '[email protected]');
UTL_SMTP.RCPT(c, '[email protected]');
UTL_SMTP.OPEN_DATA(c);
send_header('From', '"Sender" <[email protected]>');
send_header('To', '"Recipient" <[email protected]>');
send_header('Subject', 'Hello');
UTL_SMTP.WRITE_DATA(c, UTL_TCP.CRLF || 'Hello, world!');
UTL_SMTP.CLOSE_DATA(c);
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
BEGIN
UTL_SMTP.QUIT(c);
EXCEPTION
WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
NULL; -- When the SMTP server is down or unavailable, we don't have
-- a connection to the server. The QUIT call will raise an
-- exception that we can ignore.
END;
raise_application_error(-20000,
'Failed to send mail due to the following error: ' || sqlerrm);
END;
Also review the next link for get more information about the UTL_SMTP packege.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_smtp.htm#sthref15587
Regards. -
How to send a mail thru Oracle
Hello Every one ,
Can u plz tell me the way to send a mail thru oracle...................Follow the below steps..........
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 'Mail' 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.
GENERAL USAGE:
The Mail package contains three procedures:
1. Procedure Mail_pkg.logon( profile IN varchar2 default NULL);
Use this procedure to logon to the MS Exchange mail client. The procedure
takes a character argument which specifies the Exchange Profile to use for
logon. Passing a NULL argument to the logon procedure brings up a dialog box
which asks you to choose a profile from a list of valid profiles or create a new
one if it doesn't exist.
2. Procedure Mail_pkg.send(
--------- Recipient IN varchar2,
Subject IN varchar2 default NULL,
Text IN varchar2 default NULL,
Attachment IN varchar2 default NULL
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 Mail_pkg.logoff;
This procedure closes the Exchange session and deallocates the resources used
by the OLE automation objects.
SAMPLE FORMS APPLICATION:
1. Create the Mail Package using the following two Program Units:
(a) Mail Package Spec
(b) Mail Package Body
Mail Package Spec:
PACKAGE Mail_pkg 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;
Mail Package Body:
PACKAGE BODY Mail_pkg 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);
ole2.release_obj(msg_attch);
ole2.release_obj(attachment);
End;
procedure send( Recp IN varchar2,
Subject IN varchar2,
Text IN varchar2,
Attch IN varchar2
)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') ;
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:
- Profile
- To
- Subject
- Message (multiline functional property set to true)
- Attach
and a 'Send' button with the following WHEN-BUTTON-PRESSED trigger:
mail_pkg.logon(:profile);
mail_pkg.send(:to,:subject,:message,:attch);
mail_pkg.logoff; -
Send bulk mail in oracle apps 11i with pdf/Xls attachment
hi,
I have a task how can i send bulk emails in one go ( aprrox 150-200 emails in one go) in oaracle apps 11 with attachment pdf/xls
thanksDuplicate post.
how to send bulk mail in oracle apps 11i with pdf/Xls attachment
Re: how to send bulk mail in oracle apps 11i with pdf/Xls attachment -
How to Send mail in oracle 10g
I am new in oracle developer.....we are using oracle 10g developer...how to send mail through oracle 10g on a button click.pease help me.
Thanks in advanceThis question have been asked many times on this forum, see if you get help from following:
https://forums.oracle.com/message/5395438#5395438
Search results: https://forums.oracle.com/thread/search.jspa?peopleEnabled=true&userID=&containerType=&container=&q=form+email
Check this out as well:
http://nzchaudhry.wordpress.com/2013/05/31/send-report-via-email-attachment-in-oracle-forms-10g/
You can find init.ora or initSID.ora file under $ORACLE_HOME/dbs on linux and on Windows under $ORACLE_HOME/database. Otherwise you can create it using "create pfile from spfile" command
Aneel -
How a send a mail from Oracle ----- urgent
Hi,
I am working in oracle9i and linux 2.4. i need to a send mail from oracle .Please send the procedure to me in a detail manner.
I am having one procedure .plz check and change if possible...
declare
l_maicon utl_smtp.connection;
begin
l_maicon :=utl_smtp.open_connection('mail.com');
utl_smtp.helo(l_maicon,'mail.com');
utl_smtp.mail(l_maicon,'[email protected]');
utl_smtp.rcpt(l_maicon,'[email protected]');
utl_smtp.data(l_maicon,'From: [email protected]' || utl_tcp.crlf||
'To: [email protected]' || utl_tcp.crlf ||
'Subject: database e-mail option' || utl_tcp.crlf ||
'You have received this mail from database!');
utl_smtp.quit(l_maicon);
end;
Please explain me in detail
Gobi....If I do a Google search on the terms "Oracle mail", this askTom thread is the second hit
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:255615160805
Did you already find this thread? If so, did it not answer your question sufficiently?
Additionally, it would be quite helpful if you would post the results of running the code you posted. You've given no indication whether there is an error, what error might be generated, whether you're not seeing the expected behavior, whether the code crashes your system, etc. That leaves us to guess about what problems you might have between syntax errors, permission problems, configuration problems on the database, configuration problems on the SMTP server, operating system problems, network problems (the list goes on).
Justin -
I have installed Oracle 10g (10.2.0.1) on Windows XP (SP2) machine at my home PC.There is a broadband connection on my home PC.I have installed UTL_MAIL package and then set SMTP_OUT_PARAMETER by the following SQL Statement.
My machine IP address is 192.168.0.3
SQl> alter system set smtp_out_server = 'smtp.bsnl.in:25' scope = 25;
Then we run the following script.
BEGIN
UTL_MAIL.SEND(
SENDER => '[email protected]',
RECIPIENTS => '[email protected]',
SUBJECT => 'Testing UTL_MAIL',
MESSAGE => 'The receipt of this email means'||
'that it works for UTL_MAIL'
END;
Then following error message comes.
BEGIN
ERROR at line 1:
ORA-29279: SMTP permanent error: 553 Authentication is required to send mail as
<[email protected]>
ORA-06512: at "SYS.UTL_SMTP", line 21
ORA-06512: at "SYS.UTL_SMTP", line 99
ORA-06512: at "SYS.UTL_SMTP", line 222
ORA-06512: at "SYS.UTL_MAIL", line 407
ORA-06512: at "SYS.UTL_MAIL", line 594
ORA-06512: at line 2
Can anybody suggest the solution of the above problem.Hi,
is your smtp server configured to use anonymous connection?
Attackwave
Reply Code Description
211 System status, or system help reply
214 Help message [Information on how to use the receiver or the meaning of a particular non-standard command; this reply is useful only to the human user]
220 <domain> Service ready
221 <domain> Service closing transmission channel
250 Requested mail action okay, completed
251 User not local; will forward to <forward-path>
252 OK, pending messages for node <node> started. Cannot VRFY user (for example, info is not local), but will take message for this user and attempt delivery.
253 OK, <messages> pending messages for node <node> started
354 Start mail input; end with <CRLF>.<CRLF>
355 Octet-offset is the transaction offset
421 <domain> Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down.)
450 Requested mail action not taken: mailbox unavailable [for example, mailbox busy]
451 Requested action terminated: local error in processing
452 Requested action not taken: insufficient system storage
453 You have no mail.
454 TLS not available due to temporary reason. Encryption required for requested authentication mechanism.
458 Unable to queue messages for node <node>
459 Node <node> not allowed: reason
500 Syntax error, command unrecognized (This may include errors such as command line too long.)
501 Syntax error in parameters or arguments
502 Command not implemented
503 Bad sequence of commands
504 Command parameter not implemented
521 <Machine> does not accept mail.
530 Must issue a STARTTLS command first. Encryption required for requested authentication.
534 Authentication mechanism is too weak.
538 Encryption required for requested authentication mechanism.
550 Requested action not taken: mailbox unavailable [for , mailbox not found, no access]
551 User not local; please try <forward-path>
552 Requested mail action terminated: exceeded storage allocation
*553 Requested action not taken: mailbox name not allowed [for example, mailbox syntax incorrect]*
554 Transaction failed -
Send e-mail from Oracle 9i (9.2.0.1)
Hi,
Iam using oracle 9iR2(9.2.0.1) on Widows XP Platform. I want to send mail thru oracle 9i(9.2.0.1) database.
for that i got a procedure from net. Also they asked to follow three steps. the steps are
1. Execute the script as sys "D:\Oracle\Ora92\javavm\install\initjvm.sql"
2. Execute the loadjava classfile as
D:\Oracle\Ora92\plsql\jlib>loadjava -f -v -r -u sys/**** plsql.jar
3. Execute the script as sys "$ORACLE_HOME\rdbms\admin\initplsj.sql"
I sucessfully executed the first step, but for the second step i am not able to locate the plsql.jar file in the specified path.
So Please tell me if there is any other method to perform this task
Regards
Prasanta Pramanik.Is there some reason not to use the built-in UTL_SMTP package?
http://www.psoug.org/reference/utl_smtp.html
It has been available since 8.1.7. -
Sending e-mail through oracle form.
Hi Guys,
I am using forms6i to develop forms and have deploy them on web using 9iAS.
Now in one of my form, i need to send the information on that form to a couple of people through e-mail.
what is the easiest and the best way to send e-mail?
Can i use any built-in package of oracle on web?
If someone can help through code, it will be appriciated as i really have no idea how to do it.
I just want to add a send button on my form... and the formatted inofrmation will be send on a couple of e-mail address.
Please help me,
ImranYou could send it from the database (depending on what version you are running against), check out the UTL_SMTP package. Or look for some package written on top of it since it's no joy to use if you aren't familiar with the low level stuff. Not sure if it handles attachments, something written against the JavaMail API is probably more flexible for that
-
Sending E-mail Through Oracle Forms
Hi all
what i want is as the following:
1- i would like to convert the report to the PDF file internally using code.
2- open the outlook.
3- attcah the PDF automatically to the e-mail.
4- finally sending the e-mail though outlook
could i do that in Oracle forms 6i if i could do that can anyone instruct me to do it step by stepOh...it's now called ["My Oracle Support"|https://metalink.oracle.com/] .
There's a note on "My Oracle Support" on this item.
This is the note:
Subject: OLE AUTOMATION: Example Sending a Mail From Forms to Outlook
Doc ID: 119828.1 Type: BULLETIN
Modified Date : 02-SEP-2008 Status: PUBLISHED
PURPOSE
This document contains a sample code how to send an e-mail from Forms to Outlook
(97-2000).
SCOPE & APPLICATION
It can be used in addition of the whitepaper "Cracking Outlook!", which explains
the object model of Outlook in detail.
(Have a look in the Technical Libaries Folder Forms Whitepaper, their you can
find it)
OLE: Forms to Outlook
Object Model
"Cracking outlook!" explains the Object Model, you can find additional
information in the Visual Basic Help of Outlook, which must be installed from
your Office CD-Rom. Once installed, you can access the help
by choosing Tools->Macro->Visual Basic Editor and then go to the Help or
Object Browser (view -> Object Browser)
Now you can retrieve the Objects, their Methods and Properties.
Eg: the 'Application' Object has the Method 'CreateItem'.
Note this information is also available in MSDN library or if you require more
information on this Microsoft has to be contacted.
OLE2, CLIENT_OLE2 Package
Once you know the Objects, Methods and Properties you can access them with the
OLE2 package. This package provides a PL/SQL API for creating, manipulating,
and accessing attributes of OLE2 automation objects. When using OLE2 with
WebForms every call will be executed on the midtier and not on the client.
So alternatively, the CLIENT_OLE2 package can be used, that is delivered by
Webutil, to execute the OLE code on the client.
Examples
Once you know the Outlook Object model and you know the functions of the OLE2
or CLIENT_OLE2 package you can write your own OLE2/CLIENT_OLE2 code to send a
mail via Outlook.
Here below are 2 different ways of sending an email using Outlook.
Sample 1:
OLE2 sample: Here a MailItem is created, then the Recepient is explicitely
added and resolved. The mailItem is saved before being sent.
Declare
/*declaration of the Outlook Object Variables*/
application ole2.OBJ_TYPE;
hMailItem ole2.OBJ_TYPE;
hRecipients ole2.OBJ_TYPE;
recipient ole2.OBJ_TYPE;
nameSpace OLE2.OBJ_TYPE;
/*declaration of the argument list*/
args OLE2.LIST_TYPE;
begin
/*create the Application Instance*/
application:=ole2.create_obj('Outlook.Application');
/* create namespace and login */
args:=ole2.create_arglist;
ole2.add_arg(args,'MAPI');
nameSpace:=ole2.invoke_obj(application,'getNameSpace',args);
ole2.destroy_arglist(args);
ole2.invoke(nameSpace,'Logon');
/*create a Mail Instance by calling CreateItem Method and giving argument 0 with
it,
you can find the item types in the explanation of the CreateItem Method
(0=olMailItem,1=olAppointmentItem, ?)*/
args:=ole2.create_arglist;
ole2.add_arg(args,0);
hMailItem:=ole2.invoke_obj(application,'CreateItem',args);
ole2.destroy_arglist(args);
/*Get the Recipients property of the MailItem object:
Returns a Recipients collection that represents all the Recipients for the
Outlook item*/
args:=ole2.create_arglist;
hRecipients:=ole2.get_obj_property(hMailItem,'Recipients',args);
ole2.destroy_arglist(args);
/*Use the Add method to create a recipients Instance and add it to the
Recipients collection*/
args:=ole2.create_arglist;
ole2.add_arg(args,'[email protected]');
recipient:=ole2.invoke_obj(hRecipients,'Add',args);
/* put the property Type of the recipient Instance to value needed
(0=Originator,1=To,2=CC,3=BCC)*/
ole2.set_property(recipient,'Type',1);
ole2.destroy_arglist(args);
/*Resolve the Recipients collection*/
args:=ole2.create_arglist;
ole2.invoke(hRecipients,'ResolveAll',args);
/*set the Subject and Body properties*/
ole2.set_property(hMailItem,'Subject','Test OLE2 to Outlook');
ole2.set_property(hMailItem,'Body','this is body text');
/*Save the mail*/
ole2.invoke(hMailItem,'Save',args);
ole2.destroy_arglist(args);
/*Send the mail*/
args:=ole2.create_arglist;
ole2.invoke(hMailItem,'Send',args);
ole2.destroy_arglist(args);
/*Release all your Instances*/
release_obj(hMailItem);
release_obj(recipient);
release_obj(hRecipients);
release_obj(nameSpace);
release_obj(application);
end;
Sample 2
CLIENT_OLE2 sample. Here a MailItem is created with an attachment and directly
sent.
Declare
objOutlook CLIENT_OLE2.OBJ_TYPE;
objMail CLIENT_OLE2.OBJ_TYPE;
objArg CLIENT_OLE2.LIST_TYPE;
objAttach CLIENT_OLE2.OBJ_TYPE;
nameSpace CLIENT_OLE2.OBJ_TYPE;
BEGIN
objOutlook := CLIENT_OLE2.CREATE_OBJ('Outlook.Application');
/* create namespace and login */
args:=client_ole2.create_arglist;
client_ole2.add_arg(args,'MAPI');
nameSpace:=ole2.invoke_obj(objOutlook,'getNameSpace',args);
client_ole2.destroy_arglist(args);
client_ole2.invoke(nameSpace,'Logon');
-- Previous example usually used 'mapi.session' but this doesn't work correctly
--anymore.
objarg := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(objarg,0);
objMail := CLIENT_OLE2.INVOKE_OBJ(objOutlook,'CreateItem', objarg);
CLIENT_OLE2.DESTROY_ARGLIST(objarg);
objAttach := CLIENT_OLE2.GET_OBJ_PROPERTY(objmail, 'Attachments');
objarg := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(objarg,'c:\temp\test.txt'); -- filename
CLIENT_OLE2.SET_PROPERTY(objmail,'To','[email protected]');
CLIENT_OLE2.SET_PROPERTY(objmail,'Subject','Email sent from Oracle Forms 9i');
CLIENT_OLE2.SET_PROPERTY(objmail,'Body','This is an email that was sent using
CLIENT_OLE2 from Oracle forms 9i');
CLIENT_OLE2.INVOKE(objattach, 'Add', objarg);
CLIENT_OLE2.INVOKE(objmail,'Send');
CLIENT_OLE2.RELEASE_OBJ(objmail);
CLIENT_OLE2.RELEASE_OBJ(nameSpace);
CLIENT_OLE2.RELEASE_OBJ(objOutlook);
CLIENT_OLE2.DESTROY_ARGLIST(objarg);
END;
Notes:
These are just 2 different ways of sending a mail by Outlook and using the
Outlook Object Model.
The first example can also be used with CLIENT_OLE2, and the second example can
also be used with OLE2.
(just replace every OLE2 to CLIENT_OLE2 or every CLIENT_OLE2 call to OLE2). -
how can i send e-mail from within the form and without opening any e-mail program
just one click on a button in the form the mail will be sent
i'm working on nt osI use a program called BLAT which is a command line utility to send SMTP messages.
( Use the HOST built-in ).
I tried using MAPI products but they did not work well on the web.
null
Maybe you are looking for
-
TS1398 what to do if it says can not connect then to dismiss
i need help i see the wi fi network but when i try to connect it want let me it says cannot connect and to dismiss what can i do
-
Hello, I have a small question In my application, i have a Quick Search page, where the user can search throug all the data. On this page I have a 'Clear Cache For Current Application' process, and I call it on Once per session, or when reset pressed
-
I have to find the name of the trigger which uses the table "tbl_job_run"
-
How do I update Lightroom 4.4 to download canon g16 raw images?
How do I update Lightroom 4.4 to download canon g16 raw images from my camera?
-
Want to suppress "Setting the user name and passwwdd"
Does anyone know how to suppress the "Setting the user name and passwwdd login password" line that comes out on stdout when using OracleConnectionCacheImpl and the thin driver? Thanks, Chesla