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
Similar Messages
-
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 From the Oracle Applications.
Hi,
I was assigned a task to send a mail from the front end i.e., from oracle applications.
but i have no idea.
i am working on oracle apps R12.1.1 and 10g reports.
First i have to create an rdf file and that rdf file i want to send as an attachment through mail from the apps.
Any Advice will be of great help and i will follow accordingly.
Thanks in Advance,
Regards,
Bharathi.SHi,
I was assigned a task to send a mail from the front end i.e., from oracle applications.
but i have no idea.
i am working on oracle apps R12.1.1 and 10g reports.
First i have to create an rdf file and that rdf file i want to send as an attachment through mail from the apps.
Any Advice will be of great help and i will follow accordingly.
Thanks in Advance,
Regards,
Bharathi.S -
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; -
How to send JMS message from oracle to weblogic
Hello,
I am facing with a problem of sending jms message from oracle to weblogic. I am using oracle 10g and weblogic server 9.1. Here is the problem. I would like to create a trigger to send JMS message to weblogic server whenever there is an update in oracle database. So I created a java class that will send a jms message to weblogic server. But in that class I use the jndi from weblogic: weblogic.jndi.WLInitialContextFactory
when I use the loadjava utility to load that class into oracle, the status of that class is invalid though this class is working fine in eclipse with the weblogic.jar included. I was thinking because the jndi from weblogic needs the weblogic.jar in order to work, then I loaded that jar file into oracle (it took about 20 minute to load everything) and everything loaded into oracle from that jar file is invalid and missing some reference.
So my question is: how do I send a jms message from oracle to weblogic using a java class with the right jndi?
Any help will be appreciated.
Thanks
TLIt should be quite straightforward to do this. As stated you need weblogic.jar in your classpath, then use 100% standard JMS calls to publish.
Ensure that you set the following properties before getting your initial context:
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://node:7001 (or whatever)
this will ensure that the correct JMS implementation classes are invoked.
You can't easily (without some mucking around) build a test implementation in an AQ environment and then deploy to WebLogic because in AQ you don't tend to use JNDI lookups (unless you've implemented oracle JNDI etc) but rather use non standard factory class to create connections etc. -
How to send formatted mail from form 6i
Hi,
There is requirment in my project to send formatted mail from form 6i.The database used in 9i.In normal form we can send normal mail.However our requirment is such that the mail content should have company logao pics and it should display data in coloured format based on data fetched from database.How can this be done.
lWhat method are you using to send email from your form now? If you are using UTL_SMTP, you can set the MIME_TYPE = 'HTML' as Francois suggests. If you are using an OLE call to Outlook or a email JavaBean? The method you use to send email will dictate how you send Rich Text/HTML email messages.
Craig... -
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 -
Hi all,
We are using Apex 3.1 on Windows Platform,
Could any one please provide the Steps for Configuring " Sending e-mail from APEX "
many thanks
Edited by: khaja on Jan 18, 2009 11:10 AMHello,
>> Could any one please provide the Steps for Configuring " Sending e-mail from APEX "
The APEX document is including specific details on that - http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/advnc.htm#BABJHJJF .
Also, the following thread might also help you in some general information and example - HTMLDB_MAIL.SEND P_BODY .
Regards,
Arie. -
Hello colleagues!
How are u?
Could you help me explain me how to send an email from Apex please?
I suposed that Apex has an option designed for this purpose.
I would thank you your prompt reply.
Best Regards.Hello Erik.
FYI this is the sytax I use to send an email in one of my pages as part of a PL/SQL process...
l_id := APEX_MAIL.SEND(p_to => v_recipient_mail
,p_from => '[email protected]'
,p_body => l_body
,p_subj => 'Issue Updated Regarding: '||INITCAP(:P203_SUBJECT)
,p_cc => v_cc_recipients
,p_replyto => '[email protected]');Please feel free to post back if you get stuck.
Regards
Simon -
I have used Oracle 9i server (9.2.0.1 version) on Windows XP machine(with SP2).I want to send Email from PL/SQL procedure.
My Question is what sort of configuration needed to perform this activity?
I have installed IIS (Internet Information Service)
in my machine, then configure my SMTP mail server
with a valid email id and password given TCP port 465.
Later I came to know that to send Email from PL/SQL I have to install Oracle JServer Code. Follow three steps. the steps are
1. Execute the script as sys "$ORACLE_HOME\javavm\install\initjvm.sql"
2. Execute the loadjava classfile as
$ORACLE_HOME\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 iam 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
My code is as follows.
CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_to varchar2,
msg_subject varchar2,
msg_text varchar2
IS
c utl_smtp.connection;
rc integer;
msg_from varchar2(50) := '[email protected]';
mailhost VARCHAR2(30) := 'mail.google.com';
BEGIN
c := utl_smtp.open_connection(mailhost, 465);
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);
dbms_output.put_line(' Start Sending data');
utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || msg_text);
dbms_output.put_line(' Finish Sending data');
utl_smtp.quit(c);
EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;
Procedure Created.
SQL> execute prc_send_mail('[email protected]','[email protected]','Good Morning.');
BEGIN prc_send_mail('[email protected]','[email protected]','Good Morning.'); END;
ERROR at line 1:
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at "SYS.UTL_SMTP", line 17
ORA-06512: at "SYS.UTL_SMTP", line 96
ORA-06512: at "SYS.UTL_SMTP", line 374
ORA-06512: at "SCOTT.PRC_SEND_MAIL", line 19
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at line 1.
Please tell me how to solve this problem.
Thank You.1) Why did you install an SMTP server locally and then tell your code to try to use the server mail.google.com?
2) The error you're getting is from mail.google.com indicating that Google isn't running an open SMTP server there. I would be very surprised if Google were running a publicly available SMTP server anywhere since that would be an invitation for spammers.
Justin -
How to send a mail from SAP 3.1H Ver.
Hi,
I am working on SAP 3.1H Version. I need to send mail from one of my ABAP program. Since SAP 3.1H version does not have Standard function modules which send mails from any ABAP program so how can I achive this task in this version of SAP.
The Operating system of my application server is Sun solaris.
Waiting for an early and postive reply.
Thanks & Regards,
Maqsood KhanREPORT ZSAPMAIL NO STANDARD PAGE HEADING.
TABLES: DRAD,
QINF,
DRAW,
SOUC,
SOFD,
DRAP.
DATA: P_RETURN_CODE LIKE SY-SUBRC.
data: d_username LIKE DRAP-PRNAM.
mail declarations
DATA : BEGIN OF NEW_OBJECT_ID. " the newly created email object
INCLUDE STRUCTURE SOODK.
DATA : END OF NEW_OBJECT_ID.
DATA : BEGIN OF FOLDER_ID. " the folder id of the outbox
INCLUDE STRUCTURE SOODK.
DATA : END OF FOLDER_ID.
DATA : BEGIN OF REC_TAB OCCURS 5. " the table which will contain the
INCLUDE STRUCTURE SOOS1. " information on the destination
DATA : END OF REC_TAB.
DATA : BEGIN OF OBJECT_HD_CHANGE. " the table which contains the
INCLUDE STRUCTURE SOOD1. " info for the object we will be
DATA : END OF OBJECT_HD_CHANGE. " creating
DATA : OBJECT_TYPE LIKE SOOD-OBJTP. " the type of object
DATA : BEGIN OF OBJHEAD OCCURS 5. " the header of the object
INCLUDE STRUCTURE SOLI.
DATA : END OF OBJHEAD.
DATA : BEGIN OF OBJCONT OCCURS 0. " the contents of the object
INCLUDE STRUCTURE SOLI. " i.e. the text etc
DATA : END OF OBJCONT.
DATA : BEGIN OF OBJPARA OCCURS 5. " formatting options
INCLUDE STRUCTURE SELC.
DATA : END OF OBJPARA.
DATA : BEGIN OF OBJPARB OCCURS 5. " formatting options
INCLUDE STRUCTURE SOOP1.
DATA : END OF OBJPARB.
DATA : BEGIN OF T_MAIL_TEXT OCCURS 0, "Message table for messages to
STRING(255), "user via mailbox
END OF T_MAIL_TEXT.
Parameter: p_uname like sy-uname.
**START-OF-SELECTION
START-OF-SELECTION.
d_username = p_uname.
PERFORM POPULATE_EMAIL_TEXT.
PERFORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
PERFORM CREATE_AND_SEND_MAIL_OBJECT.
FORM POPULATE_EMAIL_TEXT *
Inserts text for email message *
FORM POPULATE_EMAIL_TEXT.
CLEAR T_MAIL_TEXT-STRING. "puts a blank line in
APPEND T_MAIL_TEXT.
APPEND T_MAIL_TEXT.
adds failed list on to end of success list.
T_MAIL_TEXT-STRING = 'Test email message line 1'.
APPEND T_MAIL_TEXT.
T_MAIL_TEXT-STRING = 'Test email message line 1'.
APPEND T_MAIL_TEXT.
CLEAR T_MAIL_TEXT-STRING. "puts a blank line in
APPEND T_MAIL_TEXT.
T_MAIL_TEXT-STRING = 'Header1 Header2 Header3'.
APPEND T_MAIL_TEXT.
T_MAIL_TEXT-STRING = '----
APPEND T_MAIL_TEXT.
ENDFORM.
*& Form SETUP_TRX_&_RTX_MAILBOXES
Ensure that the mailboxes of the sender (INTMGR) are set up OK
FORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
get the user no of the sender in order to add the mail to the
user name's outbox for future reference
SELECT SINGLE * FROM SOUC
WHERE SAPNAM = SY-UNAME. "SAP name of a SAPoffice user
IF SY-SUBRC NE 0.
"Error finding the SAPoffice user info for the user
MESSAGE E064(ZR53) WITH SY-UNAME.
P_RETURN_CODE = 1.
EXIT.
ENDIF.
*Get the outbox No for the sender from the user No where the folder
" type is an outbox
SELECT * FROM SOFD WHERE OWNTP = SOUC-USRTP "Owner type from ID
AND OWNYR = SOUC-USRYR "Owner year from the ID
AND OWNNO = SOUC-USRNO "Owner number from the I
AND FOLRG = 'O'."Output box
ENDSELECT.
IF SY-SUBRC NE 0.
" Error getting folder information for the user
MESSAGE E065(ZR53) WITH SY-UNAME.
P_RETURN_CODE = 1.
EXIT.
ENDIF.
ENDFORM. " SETUP_TRX_&_RTX_MAILBOXES
*& Form CREATE_AND_SEND_MAIL_OBJECT
FORM CREATE_AND_SEND_MAIL_OBJECT.
FOLDER_ID-OBJTP = SOFD-FOLTP. " the folder type ( usually FOL )
FOLDER_ID-OBJYR = SOFD-FOLYR. " the folder year ( usually 22 )
FOLDER_ID-OBJNO = SOFD-FOLNO. " the folder no.
OBJECT_TYPE = 'RAW'. " the type of object being added
build up the object information for creating the object
OBJECT_HD_CHANGE-OBJLA = SY-LANGU. " the language of the email
OBJECT_HD_CHANGE-OBJNAM = 'PS to DM Interface'. " the object name
mail subject 'Mass Linking of QA, pass/fail'
MOVE TEXT-002 TO OBJECT_HD_CHANGE-OBJDES.
OBJECT_HD_CHANGE-DLDAT = SY-DATUM. " the date of the email
OBJECT_HD_CHANGE-DLTIM = SY-UZEIT. " the time of the email
OBJECT_HD_CHANGE-OBJPRI = '1'. " the priority ( highest )
OBJECT_HD_CHANGE-OBJSNS = 'F'. " the object sensitivity
F is functional, C - company sensitive
object_hd_change-skips = ' '. " Skip first screen
object_hd_change-acnam = 'SM35'. " Batch imput transaction
object_hd_change-vmtyp = 'T'. " Transaction type
add the text lines into the contents of the email
CLEAR OBJCONT.
REFRESH OBJCONT.
free objcont. " added this to delete the mail contents records
LOOP AT T_MAIL_TEXT.
OBJCONT-LINE = T_MAIL_TEXT-STRING.
APPEND OBJCONT.
ENDLOOP.
CLEAR OBJCONT.
build up the table of receivers for the email
REC_TAB-RCDAT = SY-DATUM. " the date to send the email
REC_TAB-RCTIM = SY-UZEIT. " the time to send the email
the SAP username of the person who will receive the email
REC_TAB-RECNAM = D_USERNAME.
the user type of the person who will send the email ( USR )
REC_TAB-SNDTP = SOUC-USRTP.
the user year of the person who will send the email ( 22 )
REC_TAB-SNDYR = SOUC-USRYR.
the user number of the person who will send the email
REC_TAB-SNDNO = SOUC-USRNO.
the sap username of the person who will send the email
REC_TAB-SNDNAM = SY-UNAME.
get the user info for the receiver of the document
SELECT SINGLE * FROM SOUC WHERE SAPNAM = D_USERNAME.
IF SY-SUBRC NE 0.
WRITE : / TEXT-001, D_USERNAME. "usnam.
EXIT.
ENDIF.
the user number of the person who will receive the email ( USR )
REC_TAB-RECNO = SOUC-USRNO.
the user type of the person who will receive the email ( USR )
REC_TAB-RECTP = SOUC-USRTP.
the user year of the person who will receive the email ( USR )
REC_TAB-RECYR = SOUC-USRYR.
the priority of the email ( highest )
REC_TAB-SNDPRI = '1'.
check for delivery on the email
REC_TAB-DELIVER = 'X'.
send express so recipient knows there is a problem
REC_TAB-SNDEX = 'X'.
check for a return receipt
REC_TAB-READ = 'X'.
the sap username of the person receiving the email
REC_TAB-ADR_NAME = D_USERNAME. "usnam.
add this receiver to the internal table
APPEND REC_TAB.
CLEAR REC_TAB.
call the function to create the object in the outbox of the sender
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
FOLDER_ID = FOLDER_ID
OBJECT_HD_CHANGE = OBJECT_HD_CHANGE
OBJECT_TYPE = OBJECT_TYPE
OWNER = SY-UNAME
IMPORTING
OBJECT_ID = NEW_OBJECT_ID
TABLES
OBJCONT = OBJCONT
OBJHEAD = OBJHEAD
OBJPARA = OBJPARA
OBJPARB = OBJPARB
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
DL_NAME_EXIST = 4
FOLDER_NOT_EXIST = 5
FOLDER_NO_AUTHORIZATION = 6
OBJECT_TYPE_NOT_EXIST = 7
OPERATION_NO_AUTHORIZATION = 8
OWNER_NOT_EXIST = 9
PARAMETER_ERROR = 10
SUBSTITUTE_NOT_ACTIVE = 11
SUBSTITUTE_NOT_DEFINED = 12
SYSTEM_FAILURE = 13
X_ERROR = 14
OTHERS = 15.
IF SY-SUBRC NE 0.
MESSAGE A063(ZR53) WITH SY-SUBRC.
EXIT.
ENDIF.
call the function to send the already created email to the receivers
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
FOLDER_ID = FOLDER_ID
OBJECT_ID = NEW_OBJECT_ID
OUTBOX_FLAG = 'X'
OWNER = SY-UNAME
TABLES
RECEIVERS = REC_TAB
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
FOLDER_NOT_EXIST = 4
FOLDER_NO_AUTHORIZATION = 5
FORWARDER_NOT_EXIST = 6
NOTE_NOT_EXIST = 7
OBJECT_NOT_EXIST = 8
OBJECT_NOT_SENT = 9
OBJECT_NO_AUTHORIZATION = 10
OBJECT_TYPE_NOT_EXIST = 11
OPERATION_NO_AUTHORIZATION = 12
OWNER_NOT_EXIST = 13
PARAMETER_ERROR = 14
SUBSTITUTE_NOT_ACTIVE = 15
SUBSTITUTE_NOT_DEFINED = 16
SYSTEM_FAILURE = 17
TOO_MUCH_RECEIVERS = 18
USER_NOT_EXIST = 19
X_ERROR = 20
OTHERS = 21.
IF SY-SUBRC EQ 0.
MESSAGE I035(ZR53) WITH NEW_OBJECT_ID D_USERNAME. "usnam.
ELSE.
MESSAGE I036(ZR53) WITH D_USERNAME." sy-subrc.
ENDIF.
ENDFORM. " CREATE_AND_SEND_MAIL_OBJECT
award points if useful,
Aleem. -
How to send a mail from R/3 to external environment.
Hi all,
I want to send mail from R/3 to external environment.
How can i do?
NaveenHi naveen,
1. There is some trick involved
in the binary files.
2. I have made a program (and it works fantastic)
ONLY 6 LINES FOR EMAILING
BELIEVE ME
ITS A FANTASTIC PROGRAM.
IT WILL WORK LIKE OUTLOOK EXPRESS !
3. The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
IF sy-subrc <> 0.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
amit m. -
How to send an email from oracle?
Hi I want to send email from oracle database.
i have tried following procedure
create or replace
2 PROCEDURE send_mail (p_sender IN VARCHAR2,
3 p_recipient IN VARCHAR2,
4 p_message IN VARCHAR2)
5 as
6 l_mailhost VARCHAR2(255) := 'aria.us.oracle.com';
7 l_mail_conn utl_smtp.connection;
8 BEGIN
9 l_mail_conn := utl_smtp.open_connection(l_mailhost, 25);
10 utl_smtp.helo(l_mail_conn, l_mailhost);
11 utl_smtp.mail(l_mail_conn, p_sender);
12 utl_smtp.rcpt(l_mail_conn, p_recipient);
13 utl_smtp.open_data(l_mail_conn );
14 utl_smtp.write_data(l_mail_conn, p_message);
15 utl_smtp.close_data(l_mail_conn );
16 utl_smtp.quit(l_mail_conn);
17 end;
and when i execute the following
begin
send_mail( '[email protected]',
'[email protected]',
'Hello arun' );
end;
I get the following errors
ERROR at line 1:
ORA-29278: SMTP transient error: 421 Service not available
ORA-06512: at "SYS.UTL_SMTP", line 21
ORA-06512: at "SYS.UTL_SMTP", line 97
ORA-06512: at "SYS.UTL_SMTP", line 139
ORA-06512: at "TEST.SEND_MAIL", line 8
ORA-06512: at line 2
Please help
Regards
ArunC:\>telnet aria.us.oracle.com 25Only if you work ofr Oracle & start behind their firewall would I expect this to work.
The SMTP server to which PL/SQL connects needs to be YOUR corporate email (MTA) server & configured to RELAY message.
Contact your LOCAL postmaster/Network Admin
NONE of this is related to Oracle RDBMS! -
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. -
Hi,
I written the below email procedure.I am facing an issues now. I am receving the mail but it does not have any content.
CREATE OR REPLACE PROCEDURE IIBWP.SEND_MAIL
is
l_mailhost VARCHAR2(64) := 'us.ingerrand.com';
l_from VARCHAR2(64) := '[email protected]';
l_subject VARCHAR2(64) := 'Duplicate records details';
l_to VARCHAR2(64) := '[email protected]';
l_mail_conn UTL_SMTP.connection;
v_cnt number;
cursor c1 is select * from error_log_table where trunc(error_timestamp) =trunc(sysdate);
BEGIN
select count(*) into v_cnt
from error_log_table
where trunc(error_timestamp) =trunc(sysdate);
--if v_cnt>=1 then
l_mail_conn := UTL_SMTP.open_connection(l_mailhost, 25);
UTL_SMTP.helo(l_mail_conn, l_mailhost);
UTL_SMTP.mail(l_mail_conn, l_from);
UTL_SMTP.rcpt(l_mail_conn, l_to);
utl_smtp.data(l_mail_conn, 'CHINNATHAMBI');
UTL_SMTP.open_data(l_mail_conn);
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'From: ' || l_from || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'Subject: ' || l_subject || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'To: ' || l_to || Chr(13));
UTL_SMTP.write_data(l_mail_conn, '' || Chr(13));
FOR i IN c1 LOOP
UTL_SMTP.write_data(l_mail_conn, i.error_details);
END LOOP;
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
--end if;
END;
Please help me to fix this issues.
the mail which i received is only having the from email address. it is not showing the to mail address, and the messages.
with regards
chinnathambiuser607786 wrote:
I written the below email procedure.I am facing an issues now. I am receving the mail but it does not have any content.Invalid Mime body is created by your code.
UTL_SMTP.helo(l_mail_conn, l_mailhost);Not really correct (soft error, usually ignored by SMTP server). You need to define your IP host in the HELO command - not pass the mail server its hostname.
utl_smtp.data(l_mail_conn, 'CHINNATHAMBI');
UTL_SMTP.open_data(l_mail_conn);Huh? The DATA command is intended to use a single call to send the entire e-mail (headers and body). This contains the text string "+CHINNATHAMBI+". This is not valid.
The document describes this call as follows:
UTL_SMTP.DATA (
c IN OUT NOCOPY connection
body IN VARCHAR2 CHARACTER SET ANY_CS);
Parameter Description
c The SMTP Connection.
body The text of the message to be sent, including headers, in [RFC822] format.Is that string in RFC822 format? Nope - not even close.
Then straight after that, you now use multiple commands to create another e-mail body... This is not a valid SMTP command sequence. You have already supplied complete e-mail data - you cannot now supply yet more e-mail data!
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'From: ' || l_from || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'Subject: ' || l_subject || Chr(13));
UTL_SMTP.write_data(l_mail_conn, UTL_TCP.CRLF ||'To: ' || l_to || Chr(13));
UTL_SMTP.write_data(l_mail_conn, '' || Chr(13));Also wrong. Here you are attempting to write an e-mail header. There should not be an empty line as the first line - as an empty line is used to separate the header from the body in the mail.
The header lines must be written first (no empty lines). Then a single empty line to indicate the start of the body. Then the body itself (using local headers per body part if this a mixed multi-type Mime message).
I suggest you first get to grips with how a physical e-mail looks like, before you attempt to manually create one. You can use your mail reader and select the "+view source/raw e-mail+" option to look at the actual physical text structure of e-mails. You should also have a look at the RFC's (Request For Comments) memo's that specifies the Internet standards for Mime bodies, such as RFC822 (Internet Message Format). Use google to look up these RFC's.
Constructing e-mails is easy - but that requires you to know the basic structure of an Internet Message. Not guessing like you have done in your code.
Maybe you are looking for
-
Why am I suddenly getting this message after I've been using iMovie for a few years now and have never had any such issue before: The project could not be prepared for publishing because an error occurred. (OpWrErr: file already open with with write
-
Look in the red circle at the photo and tell me if this is ok. Will it get bigger because its annoying to look at now? Should i take my iPad back i have already returned it once already and this is my new one and found this. I dont know what to do.
-
Hi All, I needed some help figuring out a particular join. I have three tables ; NPIProjects (alias npip) table which contains ID testGrades (alias tg) table which contains the fields -----id , ProductGrade NewModels (alias nm) which contains the ---
-
Security in developing a pdf file
how do i make a pdf file secure so that it cannot be shared or copied? thanks, alex
-
I have accidentally deleted an sms that I require from my iphone 4s. Can anyone please help me to recover this?