Send BW query results as HTML email from ABAP program
I have published a code sample for sending BW query results as HTML email from ABAP program. if you have any questions or clarification, please post them here.
the same can be accessed from this link.
http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b7658119-0a01-0010-39a9-b600c816f370
Regards
Raja
Message was edited by: Durairaj Athavan Raja
OK forget about my earlier post.
do the following changes.
declare the following variables:
data: xtext type standard table of solix .
DATA: atta_sub TYPE sood-objdes .
after the call of FM SCMS_STRING_TO_FTEXT add the following code.
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = text
IMPORTING
EP_SOLIXTAB = xtext .
and after the following statement
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = text
i_length = conlengths
i_subject = subject ).
add the following code
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'htm'
i_attachment_subject = atta_sub
i_att_content_hex = xtext.
now you will have results both in the body as well as attachment. (this is for test you can remove one of them )
Regards
Raja
Similar Messages
-
Html Email from abap program itab - html - email
hi experts..
i want to convert an itab into html and then with html format send an email , following is the code for that
report, the email is coming but not in the html format,
can any body help me in this regard...
thanks in advance
umer
<< Please only post the relevant portions of your code - and format it.>>
Edited by: Umer Malik on Jun 5, 2009 3:48 PM
Edited by: Umer Malik on Jun 5, 2009 4:03 PM
Edited by: Rob Burbank on Jun 5, 2009 10:11 AMHi,
Check this.
TABLES: KNA1.
DATA DECLARATION
DATA : IT_DATA_XML TYPE STANDARD TABLE OF KNA1 WITH HEADER LINE.
DATA : XML_RESULT TYPE STRING.
SELECT OPTIONS
selection-screen begin of block abc with frame title text-001.
selection-screen skip.
SELECT-OPTIONS: SO_KUNNR FOR KNA1-KUNNR.
selection-screen skip.
selection-screen end of block abc.
*START OF SELECTION
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GET_INTO_XML_FORMAT.
FORM GET_DATA
FORM GET_DATA.
SELECT * FROM KNA1 INTO TABLE IT_DATA_XML
WHERE KUNNR IN SO_KUNNR.
IF SY-SUBRC <> 0.
MESSAGE 'RECORDS NOT FOUND.' TYPE 'E'.
ENDIF.
ENDFORM. "GET_DATA
FORM GET_INTO_XML_FORMAT
FORM GET_INTO_XML_FORMAT.
call transformation id
source SOURCE = IT_DATA_XML[]
result xml XML_RESULT.
refresh IT_DATA_XML.
CALL TRANSFORMATION id
SOURCE XML XML_RESULT
RESULT SOURCE = IT_DATA_XML[].
write: 'this is test'.
ENDFORM. "GET_INTO_XML_FORMAT -
Sending emails from ABAP program
Hi,
I need to send error emails from ABAP program.
I have to pass error internal table as text (not as attachment) in the email.
Can anybody supply any sample code?
Thanks in advance.
Regards,
Arun MohanHI,
See if this code helps:
***Sending mail to the receipients
if not it_final[] is initial.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Sales Register Report - Set Top Box / Accessories'
'XLS'
'SSTB'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
endif.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM BUILD_XLS_DATA_TABLE .
data: wa_itab like it_final.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'Business Place' 'Region Code' 'Region' 'Branch Code'
'Branch' 'Material Desc' 'Area off Code'
'Area Name' 'Zone code' 'Zone Name' 'Cust No' 'Cust Name'
'Bill Doc No' 'Bill Date' 'Base Val' 'Total Val' 'Quantity'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_FINAL INTO WA_ITAB.
CONCATENATE WA_ITAB-BUSINESS_PLACE
WA_ITAB-KVGR1
WA_ITAB-REGION
WA_ITAB-VKBUR
WA_ITAB-SALES_OFF
WA_ITAB-ARKTX
WA_ITAB-vkgrp
WA_ITAB-sales_grp
WA_ITAB-bzirk
WA_ITAB-zone
WA_ITAB-kunnr
WA_ITAB-name
WA_ITAB-vbeln
WA_ITAB-fkdat
WA_ITAB-base_value
WA_ITAB-total_value
WA_ITAB-fkimg
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form POPULATE_EMAIL_MESSAGE_BODY
text
--> p1 text
<-- p2 text
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO G_DATE.
IT_MESSAGE = 'Please find attached excel sheet.'.
APPEND IT_MESSAGE.
IT_MESSAGE = 'Sales Register Report - Set Top Box / Accessories'.
APPEND IT_MESSAGE.
Concatenate 'Report generated date' ':' G_Date '.' into IT_MESSAGE.
APPEND IT_MESSAGE.
clear it_message.
append it_message.
IT_MESSAGE = 'This is an autogenerated mail, please do not reply'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
T_PACKING_LIST-OBJ_NAME = 'stb'.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-DOC_TYPE = 'XLS'.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_DESCR = 'Sales_STB'.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-OBJ_NAME = 'stb'.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
LOOP AT IT_RECV.
T_RECEIVERS-RECEIVER = IT_RECV-EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-COPY = 'X'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
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.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
text
--> p1 text
<-- p2 text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = ''
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
Regards
Subramanian -
Sending EMAIL from ABAP Program Configuration+Code(Step by step)
Dear All,
Please anybody can provide me Step by Step document for sending Email from ABAP Program.
Thanks,
RPNot an appropriate forum. Try ABAP forum.
Regards,
Jai Shankar -
Sending query result as html email
hi,
I have requirement to send query result as html emial to user, is there a possibility to send it?
database is 11.2.3
thanks,
7ZGoogle is your friend
http://oracle-base.com/articles/misc/email-from-oracle-plsql.php
https://www.google.nl/search?q=send+email+oracle+database+11g -
Converting Query results into HTML email
Hi,
I am using oracle 11g. I' m using the following procedure to send out html emails from a static query in the procedure and it works fine. I wanted to make it dynamic and pass the sql query as a parameter to procedure and build the html tags based on the query. Any thoughts?
CREATE OR REPLACE PROCEDURE html_sql_results
is
v_rows clob;
v_header clob;
cursor v_cursor is
select SR_NO,STATE,DUE_DT,PROCESS_DT,STATUS,DAY_NO,SEQ_NO
from T_TABLE;
BEGIN
v_header := '<table border=1>
<tr style=''background:#8DB3E2''>
<td><p><b>SR_NO</b></p></td>
<td><p><b>STATE</b></p></td>
<td><p><b>DUE_DT</b></p></td>
<td><p><b>PROCESS_DT</b></p></td>
<td><p><b>STATUS</b></p></td>
<td><p><b>DAY_NO</b></p></td>
<td><p><b>SEQ_NO</b></p></td>
</tr>';
v_rows := Null;
FOR i in v_cursor
LOOP
v_rows := v_rows ||
'<tr>
<td> <p>' || I.SR_NO||'</p></td>
<td> <p>' || I.STATE||'</p></td>
<td> <p>' || I.DUE_DT ||'</p></td>
<td> <p>' || I.PROCESS_DT ||'</p></td>
<td> <p>' || I.STATUS||'</p></td>
<td> <p>' || I.DAY_NO ||'</p></td>
<td> <p>' || I.SEQ_NO||'</p></td>
</tr> ';
END LOOP;
if v_rows is not null then
v_rows:= v_header ||v_rows ||' </table> ' ;
dbms_output.put_line(v_rows);
email_results(v_rows);
end if ;
end ;
/A possible way :
SQL> var result clob
SQL> DECLARE
2
3 ctx dbms_xmlgen.ctxHandle;
4 qry varchar2(2000) := 'SELECT * FROM hr.employees WHERE department_id = :1';
5
6 xsl xmltype := xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
7 <xsl:output method="html"/>
8 <xsl:template match="/ROWSET">
9 <table border="1">
10 <tr style="background:#8DB3E2">
11 <xsl:for-each select="ROW[1]/*">
12 <td><p><b><xsl:value-of select="name()"/></b></p></td>
13 </xsl:for-each>
14 <xsl:apply-templates/>
15 </tr>
16 </table>
17 </xsl:template>
18 <xsl:template match="ROW">
19 <tr><xsl:apply-templates/></tr>
20 </xsl:template>
21 <xsl:template match="ROW/*">
22 <td><p><b><xsl:value-of select="."/></b></p></td>
23 </xsl:template>
24 </xsl:stylesheet>');
25
26 res clob;
27
28 BEGIN
29
30 ctx := dbms_xmlgen.newContext(qry);
31 dbms_xmlgen.setBindValue(ctx, '1', 90);
32 dbms_xmlgen.setNullHandling(ctx, dbms_xmlgen.EMPTY_TAG);
33 dbms_xmlgen.setXSLT(ctx, xsl);
34
35 :result := dbms_xmlgen.getXML(ctx);
36 dbms_xmlgen.closeContext(ctx);
37
38 --dbms_output.put_line(res);
39
40 END;
41 /
PL/SQL procedure successfully completed.
SQL> print result
RESULT
<table border="1"><tr style="background:#8DB3E2"><td><p><b>EMPLOYEE_ID</b></p></
td><td><p><b>FIRST_NAME</b></p></td><td><p><b>LAST_NAME</b></p></td><td><p><b>EM
AIL</b></p></td><td><p><b>PHONE_NUMBER</b></p></td><td><p><b>HIRE_DATE</b></p></
td><td><p><b>JOB_ID</b></p></td><td><p><b>SALARY</b></p></td><td><p><b>COMMISSIO
N_PCT</b></p></td><td><p><b>MANAGER_ID</b></p></td><td><p><b>DEPARTMENT_ID</b></
p></td><tr><td><p><b>100</b></p></td><td><p><b>Steven</b></p></td><td><p><b>King
</b></p></td><td><p><b>SKING</b></p></td><td><p><b>515.123.4567</b></p></td><td>
<p><b>17/06/03</b></p></td><td><p><b>AD_PRES</b></p></td><td><p><b>24000</b></p>
</td><td><p><b></b></p></td><td><p><b></b></p></td><td><p><b>90</b></p></td></tr
<tr><td><p><b>101</b></p></td><td><p><b>Neena</b></p></td><td><p><b>Kochhar</b></p></td><td><p><b>NKOCHHAR</b></p></td><td><p><b>515.123.4568</b></p></td><td><
p><b>21/09/05</b></p></td><td><p><b>AD_VP</b></p></td><td><p><b>17000</b></p></t
d><td><p><b></b></p></td><td><p><b>100</b></p></td><td><p><b>90</b></p></td></tr
<tr><td><p><b>102</b></p></td><td><p><b>Lex</b></p></td><td><p><b>De Haan</b></p></td><td><p><b>LDEHAAN</b></p></td><td><p><b>515.123.4569</b></p></td><td><p><
b>13/01/01</b></p></td><td><p><b>AD_VP</b></p></td><td><p><b>17000</b></p></td><
td><p><b></b></p></td><td><p><b>100</b></p></td><td><p><b>90</b></p></td></tr></
tr></table>Typically, XSLT stylesheets may be stored in the database too, so that you can modify and use different presentation templates without touching the code. -
Email from ABAP program to outlook with attachment
Hi,
I need to send an email to outlook from my program with an attachment. I wrote my program without attchment feature and working fine. I really donot understand how to do attchment. Can anyone send me some piece of code.
I promise points will be rewarded for useful answers.
Thanks In Advance.
Rajesh.Here is a sample program how to attach a sapscript output to your email.
REPORT ZRICH_0003.
DATA: ITCPO LIKE ITCPO,
TAB_LINES LIKE SY-TABIX.
* Variables for EMAIL functionality
DATA: MAILDATA LIKE SODOCCHGI1.
DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
PERFORM SEND_FORM_VIA_EMAIL.
* FORM SEND_FORM_VIA_EMAIL *
FORM SEND_FORM_VIA_EMAIL.
CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
* Creation of the document to be sent File Name
MAILDATA-OBJ_NAME = 'TEST'.
* Mail Subject
MAILDATA-OBJ_DESCR = 'Subject'.
* Mail Contents
MAILTXT-LINE = 'Here is your file'.
APPEND MAILTXT.
* Prepare Packing List
PERFORM PREPARE_PACKING_LIST.
* Set recipient - email address here!!!
MAILREC-RECEIVER = '[email protected]'.
MAILREC-REC_TYPE = 'U'.
APPEND MAILREC.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = MAILDATA
PUT_IN_OUTBOX = ' '
TABLES
PACKING_LIST = MAILPACK
OBJECT_HEADER = MAILHEAD
CONTENTS_BIN = MAILBIN
CONTENTS_TXT = MAILTXT
RECEIVERS = MAILREC
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
ENDFORM.
* Form PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
CLEAR: MAILPACK, MAILBIN, MAILHEAD.
REFRESH: MAILPACK, MAILBIN, MAILHEAD.
DESCRIBE TABLE MAILTXT LINES TAB_LINES.
READ TABLE MAILTXT INDEX TAB_LINES.
MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
* Creation of the entry for the compressed document
CLEAR MAILPACK-TRANSF_BIN.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 0.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'RAW'.
APPEND MAILPACK.
* Creation of the document attachment
* This form gets the OTF code from the SAPscript form.
* If you already have your OTF code, I believe that you may
* be able to skip this form. just do the following code, looping thru
* your SOLISTI1 and updating MAILBIN.
PERFORM GET_OTF_CODE.
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST.OTF'.
APPEND MAILHEAD.
** Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST'.
MAILPACK-OBJ_DESCR = 'Subject'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
ENDFORM.
* Form GET_OTF_CODE
FORM GET_OTF_CODE.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
* Start writing OTF code
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZTEST_FORM'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'START_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'MAIN'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
* Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
* Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
ENDFORM.
Regards,
Rich Heilman -
Hi !
I am populating the email body with some internal table values. I would like a line feed and carriage return in the email. How do I do it ?
Constants : c_lf(2) TYPE X value '0A'.
c_cr(2) TYPE X value '0D'.
SWC_CREATE_OBJECT MESSAGE 'MESSAGE' SPACE.
SWC_SET_ELEMENT CONTAINER 'DOCUMENTTITLE' 'Title'(020).
SWC_SET_ELEMENT CONTAINER 'DOCUMENTNAME' 'Email message'(020).
SWC_SET_ELEMENT CONTAINER 'DOCUMENTTYPE' 'RAW'.
SWC_SET_ELEMENT CONTAINER 'NO_DIALOG' 'X'.
CONCATENATE 'Dear' firstname INTO CONTENT.
APPEND CONTENT.
CONTENT = c_lf.
APPEND CONTENT.
CONTENT = c_cr.
APPEND CONTENT.
CONTENT 'This is the first line'.
APPEND CONTENT.
The above just appends the hex values of line feed and carriage return into the email body and doesn't actually create a line feed / carriage return.
Any ideas ?
Cheers,
Ashok.If you are using SAP R/3 Enterprise, you might want to look at the class(SE24) CL_ABAP_CHAR_UTILITIES - the attributes section.
Regards,
Subramanian V. -
To send external email from ABAP
How to send external email from ABAP Program and what are the settings to be done for the same ?
Please check..
Sending External email through SAP
What is the FM for sending the external email through SAP by attaching layout set to it?
These are the FM for sending external email :-
SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments via RFC
SO_NEW_DOCUMENT_ATT_SEND_API1
(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
SAPoffice: Send new document with attachments via RFC
Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.
SO_NEW_DOCUMENT_SEND_API1
SAPoffice: Send new document
How to send a report to an external mail-id?
Try this sample code :-
REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
DATA : BEGIN OF ITAB OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.
DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.
START-OF-SELECTION.
SELECT PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM PA0001
WHERE PERNR < 50.
LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
SY-VLINE.
ENDLOOP.
Receivers
receiver_list-recextnam = '[email protected]'. "-->
EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-
APPEND receiver_list.
General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
Mail subject
w_object_hd_change-objdes = 'Message subject'.
Mail body
APPEND 'Message content' TO message_content.
Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment. -
Hi everyone!
Is there a way in ABAP to output XML files? Pls. send code/ function module if any.
From ABAP programs, we are sure that we can output TEXT files, but how about XML files?
The significance of this question is related
Currently we are using XI to interface SAP and AMS, this question for ABAP to produce XML file arose, if for example, the XI server is down and we have to still send data from one system to another. IDocs can also produce XML files, pls confirm. Earlier however, we have preferred XI rather than IDocs to do this. Anyway, any idea regarding this scenario will be greatly appreciated.
Thanks and God bless!
CelesteHi,
Please check this sample codes from other thread.
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
*-------------- DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
******************************* FIRST PHASE
******************************* FIRST PHASE
******************************* FIRST PHASE
*------------------ Fetch Data
SELECT * FROM t001 INTO TABLE t001.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
* IMPORTING
* LENGTH =
TABLES
FTEXT_TAB = itab.
*-------------- Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:xx.xml'
TABLES
data_tab = itab.
******************************* SECOND PHASE
******************************* SECOND PHASE
******************************* SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
*------------------- XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
Regards,
Ferry Lianto -
Sending HTML emails from Outlook
I am a Mac user and only know how to send an HTML email from
Entourage. How do I send an HTML email created in Dreamweaver from
a PC that uses Microsoft Outlook?It's tricky in Outlook (Outlook Express lets you actually
edit the code directly if I recall correctly). But one clunky way
to do it regular Outlooks is to display your HTML page in your
browser. Not the source code, the resulting display page in a
normal browser window. Select all, copy, then paste into your HTML
format message in Outlook.
Keep in mind if you're sending this to more than 50 people or
so you stand a real good chance of getting that domain/IP black
listed. -
Sending Unicode HTML email from Oracle
Dear All,
How we can send the HTML email from Oracle in Unicode format (I am using Arabic Language, to be specific). So far I have tried the following solutions (using utl_smpt) without any success (either i see junk characters in the email or see question marks). Would you please help me in solving this?
Options Tried*
Option 1
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE p_send_mail_test (
2 sender IN VARCHAR2,
3 recipient IN VARCHAR2,
4 subj IN VARCHAR2,
5 message IN VARCHAR2)
6 IS
7 mailhost VARCHAR2(30) := '<smtp Server>';
8 c utl_smtp.connection;
9 PROCEDURE send_header( name IN VARCHAR2, header IN VARCHAR2) AS
10 BEGIN
11 utl_smtp.write_data(c, name || ': ' || header || utl_tcp.CRLF);
12 END;
13 BEGIN
14 c := utl_smtp.open_connection(mailhost,25);
15 utl_smtp.helo(c, mailhost);
16 utl_smtp.mail(c, sender);
17 utl_smtp.rcpt(c, recipient);
18 utl_smtp.open_data(c);
19 send_header('From', sender);
20 send_header('To', recipient);
21 -- If you need to send mail to more than one receipient, uncomment the
22 -- following line(s) as appropriate. Please don't forget the ","
23 -- in the "To" line before the next receipient's email id. You can't
24 -- use a comma separated list in the receipient parameter.
25 -- For variable number of "To"'s and "Cc"'s have multiple calls to
26 -- "send_header" function inside a cursor for loop.
27 -- Similar comments apply for "Cc" too.
28 -- send_header('To', ',<email@domain>');
29 send_header('Cc', ',<email@domain>');
30 send_header('Subject', subj);
31 utl_smtp.write_data(c, utl_tcp.CRLF || message);
32 utl_smtp.close_data(c);
33 utl_smtp.quit(c);
34 EXCEPTION
35 WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
36 utl_smtp.quit(c);
37 raise_application_error(-20000,
38 'Failed to send mail due to the following error: ' || sqlerrm);
39* END;
SQL>
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 email_text varchar2(2000);
3 contract_end_date_v date := sysdate;
4 name_v varchar2(200) := 'Riaz';
5 begin
6 email_text :='<br/><div align="right"><font size="4"><b>السيد '||name_v||' المحترم</b><br/><br/> يرجى التكرم بالعلم أن العقد الخاص بكم سينتهي بتاريخ ' || to_char(contract_end_date_v,'dd-mm-yyyy')||'<br/>. وعليه يرجـى التكـرم بإفادة إدارة الموارد البشرية في حال عدم رغبتكم بتجديد العقد خلال مدة أقصها أسبوعين من اليوم وذلك للأهمية القصوى <br/>.ولكم جزيل الشكر والتقدير </font></div>';
7 p_send_mail_test('<email@domain>','<email@domain>','Hello',email_text);
8* end;
SQL> /
PL/SQL procedure successfully completed.
Result_
<div align="right"><font size="4"><b>????? Riaz ???????</b>
???? ?????? ?????? ?? ????? ????? ??? ?????? ?????? 12-07-2011
.???? ???? ????? ???????? </font></div>
[Question marks along with all tags; this OTN page is converting that to HTML output]
Option2
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure html_email(
2 p_to in varchar2,
3 p_from in varchar2,
4 p_subject in varchar2,
5 p_text in varchar2 default null,
6 p_html in varchar2 default null
7 )
8 is
9 l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';
10 l_connection utl_smtp.connection;
11 l_body_html clob := empty_clob; --This LOB will be the email message
12 l_offset number;
13 l_ammount number;
14 l_temp varchar2(32767) default null;
15 l_smtp_hostname varchar2(50) := '<smtp Server>';
16 begin
17 l_connection := utl_smtp.open_connection( l_smtp_hostname, 25);
18 utl_smtp.helo( l_connection, l_smtp_hostname );
19 utl_smtp.mail( l_connection, p_from );
20 utl_smtp.rcpt( l_connection, p_to );
21 l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);
22 l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
23 l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
24 l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
25 l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);
26 l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
27 chr(34) || l_boundary || chr(34) || chr(13) ||
28 chr(10);
29 ----------------------------------------------------
30 -- Write the headers
31 dbms_lob.createtemporary( l_body_html, false, 10 );
32 dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
33 ----------------------------------------------------
34 -- Write the text boundary
35 l_offset := dbms_lob.getlength(l_body_html) + 1;
36 l_temp := '--' || l_boundary || chr(13)||chr(10);
37 l_temp := l_temp || 'content-type: text/plain;charset=utf-8' ||
38 chr(13) || chr(10) || chr(13) || chr(10);
39 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
40 ----------------------------------------------------
41 -- Write the plain text portion of the email
42 l_offset := dbms_lob.getlength(l_body_html) + 1;
43 dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
44 ----------------------------------------------------
45 -- Write the HTML boundary
46 l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
47 chr(13) || chr(10);
48 l_temp := l_temp || 'content-type: text/html;charset=utf-8' ||
49 chr(13) || chr(10) || chr(13) || chr(10);
50 l_offset := dbms_lob.getlength(l_body_html) + 1;
51 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
52 ----------------------------------------------------
53 -- Write the HTML portion of the message
54 l_offset := dbms_lob.getlength(l_body_html) + 1;
55 dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
56 ----------------------------------------------------
57 -- Write the final html boundary
58 l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);
59 l_offset := dbms_lob.getlength(l_body_html) + 1;
60 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
61 ----------------------------------------------------
62 -- Send the email in 1900 byte chunks to UTL_SMTP
63 l_offset := 1;
64 l_ammount := 1900;
65 utl_smtp.open_data(l_connection);
66 while l_offset < dbms_lob.getlength(l_body_html) loop
67 utl_smtp.write_data(l_connection,
68 dbms_lob.substr(l_body_html,l_ammount,l_offset));
69 l_offset := l_offset + l_ammount ;
70 l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
71 end loop;
72 utl_smtp.close_data(l_connection);
73 utl_smtp.quit( l_connection );
74 dbms_lob.freetemporary(l_body_html);
75* end;
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 email_text varchar2(2000);
3 contract_end_date_v date := sysdate;
4 name_v varchar2(200) := 'Riaz';
5 begin
6 email_text :='<br/><div align="right"><font size="4"><b>السيد '||name_v||' المحترم</b><br/><br/> يرجى التكرم بالعلم أن العقد الخاص بكم سينتهي بتاريخ ' || to_char(contract_end_date_v,'dd-mm-yyyy')||'<br/>. وعليه يرجـى التكـرم بإفادة إدارة الموارد البشرية في حال عدم رغبتكم بتجديد العقد خلال مدة أقصها أسبوعين من اليوم وذلك للأهمية القصوى <br/>.ولكم جزيل الشكر والتقدير </font></div>';
7 html_email(p_to=>'<email@domain>',p_from=>'<email@domain>',p_subject=>'Hello',p_text=>'Hi', p_html=>email_text);
8* end;
SQL> /
PL/SQL procedure successfully completed.
Result*
????? Riaz ???????
???? ?????? ?????? ?? ????? ????? ??? ?????? ?????? 12-07-2011
Option3
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure p_html_email_riaz(
2 p_to in varchar2,
3 p_from in varchar2,
4 p_subject in varchar2,
5 p_text in varchar2 default null,
6 p_html in varchar2 default null
7 )
8 is
9 l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';
10 l_connection utl_smtp.connection;
11 l_body_html clob := empty_clob; --This LOB will be the email message
12 l_offset number;
13 l_ammount number;
14 l_temp varchar2(32767) default null;
15 l_smtp_hostname varchar2(50) := '<smtp Server>';
16 begin
17 l_connection := utl_smtp.open_connection( l_smtp_hostname, 25);
18 utl_smtp.helo( l_connection, l_smtp_hostname );
19 utl_smtp.mail( l_connection, p_from );
20 utl_smtp.rcpt( l_connection, p_to );
21 l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);
22 l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
23 l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
24 l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
25 l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);
26 l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
27 chr(34) || l_boundary || chr(34) || chr(13) ||
28 chr(10);
29 ----------------------------------------------------
30 -- Write the headers
31 dbms_lob.createtemporary( l_body_html, false, 10 );
32 dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
33 ----------------------------------------------------
34 -- Write the text boundary
35 l_offset := dbms_lob.getlength(l_body_html) + 1;
36 l_temp := '--' || l_boundary || chr(13)||chr(10);
37 l_temp := l_temp || 'content-type: text/plain; charset=UTF-8' ||
38 chr(13) || chr(10) || chr(13) || chr(10);
39 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
40 ----------------------------------------------------
41 -- Write the plain text portion of the email
42 /**
43 l_offset := dbms_lob.getlength(l_body_html) + 1;
44 dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
45 **/
46 ----------------------------------------------------
47 -- Write the HTML boundary
48 l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
49 chr(13) || chr(10);
50 l_temp := l_temp || 'content-type: text/html;' ||
51 chr(13) || chr(10) || chr(13) || chr(10);
52 l_offset := dbms_lob.getlength(l_body_html) + 1;
53 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
54 ----------------------------------------------------
55 -- Write the HTML portion of the message
56 l_offset := dbms_lob.getlength(l_body_html) + 1;
57 dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
58 ----------------------------------------------------
59 -- Write the final html boundary
60 l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);
61 l_offset := dbms_lob.getlength(l_body_html) + 1;
62 dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
63 ----------------------------------------------------
64 -- Send the email in 1900 byte chunks to UTL_SMTP
65 l_offset := 1;
66 l_ammount := 1900;
67 utl_smtp.open_data(l_connection);
68 while l_offset < dbms_lob.getlength(l_body_html) loop
69 utl_smtp.write_raw_data(l_connection,
70 utl_raw.cast_to_raw(
71 dbms_lob.substr(l_body_html,l_ammount,l_offset ) ) );
72 l_offset := l_offset + l_ammount ;
73 l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
74 end loop;
75 utl_smtp.close_data(l_connection);
76 utl_smtp.quit( l_connection );
77 dbms_lob.freetemporary(l_body_html);
78* end;
SQL>
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 email_text varchar2(2000);
3 contract_end_date_v date := sysdate;
4 name_v varchar2(200) := 'Riaz';
5 begin
6 email_text :='<br/><div align="right"><font size="4"><b>السيد '||name_v||' المحترم</b><br/><br/> يرجى التكرم بالعلم أن العقد الخاص بكم سينتهي بتاريخ ' || to_char(contract_end_date_v,'dd-mm-yyyy')||'<br/>. وعليه يرجـى التكـرم بإفادة إدارة الموارد البشرية في حال عدم رغبتكم بتجديد العقد خلال مدة أقصها أسبوعين من اليوم وذلك للأهمية القصوى <br/>.ولكم جزيل الشكر والتقدير </font></div>';
7 p_html_email_riaz(p_to=>'<email@domain>',p_from=>'<email@domain>',p_subject=>'Hello',p_text=>'Hi', p_html=>email_text);
8* end;
SQL> /
PL/SQL procedure successfully completed.
Result*
GaSmO Riaz GacMJQc
mQLl GaJ_Qc HGaZac Cd GaZ^O GaNGU H_c SmdJem HJGQmN 12-07-2011
. fZame mQL\l GaJ_\Qc HE]GOI EOGQI GacfGQO GaHTQmI ]m MGa ZOc Q[HJ_c HJLOmO GaZ^O NaGa cOI C^UeG CSHfZmd cd Gamfc fPa_ aaCecmI Ga^Ufl
.fa_c LRma GaT_Q fGaJ^OmQ
*Option4*
[code]
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE send_email_html_test(
2 pi_from IN Varchar,
3 pi_to IN VARCHAR,
4 pi_cc IN Varchar,
5 pi_subj IN VARCHAR,
6 pi_msg CLOB
7 )
8 IS
9 conn utl_smtp.connection;
10 lv_mailhost varchar2(1000);
11 lv_port number;
12 BEGIN
13 lv_mailhost := '<smtp Server>';
14 lv_port := 25;
15 conn := utl_smtp.open_connection(lv_mailhost, lv_port);
16 utl_smtp.helo(conn, lv_mailhost);
17 utl_smtp.mail(conn, pi_from);
18 utl_smtp.rcpt(conn, pi_to);
19 IF pi_cc is not null THEN
20 utl_smtp.rcpt(conn, pi_cc);
21 END IF;
22 utl_smtp.open_data(conn);
23 utl_smtp.write_data(conn, 'MIME-version: 1.0' || utl_tcp.CRLF);
24 utl_smtp.write_data(conn, 'Content-Type: text/html; charset=iso-8859-6' ||
25 utl_tcp.CRLF);
26 utl_smtp.write_data(conn, 'Content-Transfer-Encoding: 8bit' ||
27 utl_tcp.CRLF);
28 utl_smtp.write_data(conn, 'From:' ||pi_from || utl_tcp.CRLF);
29 utl_smtp.write_data(conn, 'To:' ||pi_to || utl_tcp.CRLF);
30 utl_smtp.write_data(conn, 'Cc:' ||pi_cc || utl_tcp.CRLF);
31 utl_smtp.write_data(conn, 'Reply-To:' ||pi_from || utl_tcp.CRLF);
32 utl_smtp.write_data(conn, 'Subject:' ||pi_subj|| utl_tcp.CRLF);
33 utl_smtp.write_data(conn, utl_tcp.crlf);
34 utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(pi_msg));
35 utl_smtp.close_data(conn);
36 utl_smtp.quit(conn);
37 EXCEPTION WHEN others THEN
38 dbms_output.put_line(sqlerrm);
39* END;
40 /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 email_text varchar2(2000);
3 contract_end_date_v date := sysdate;
4 name_v varchar2(200) := 'Riaz';
5 begin
6 email_text :='
<div align="right"><font size="4"><b>السيد '||name_v||' المحترم</b>
يرجى التكرم بالعلم أن العقد الخاص بكم سينتهي بتاريخ ' || to_char(contract_end_date_v,'dd-mm-yyyy')||'
. وعليه يرجـى التكـرم بإفادة إدارة الموارد البشرية في حال عدم رغبتكم بتجديد العقد خلال مدة أقصها أسبوعين من اليوم وذلك للأهمية القصوى
.ولكم جزيل الشكر والتقدير </font></div>';
7 send_email_html_test('<email@domain>',
8 '<email@domain>',
9 '<email@domain>',
10 'Hello',email_text);
11* end;
SQL> /
PL/SQL procedure successfully completed.
Result*
Riaz افكحترك
ٍرجٌ افترك بافغفك أل افغد افخاص بك سٍلتمٍ بتارٍخ 12-07-2011
. نغفٍم ٍرجٌ افترك بإادة إدارة افكنارد افبشرٍة ٍ حاف غدك ربتك بتجدٍد افغد خفاف كدة أصما أسبنغٍل كل افٍنك نذف ففأمكٍة افصنٌ
.نفك جزٍف افشر نافتدٍر
Option5
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE send_mail_test1 (p_to IN VARCHAR2,
2 p_from IN VARCHAR2,
3 p_subject IN VARCHAR2,
4 p_text_msg IN VARCHAR2 DEFAULT NULL,
5 p_html_msg IN VARCHAR2 DEFAULT NULL,
6 p_smtp_host IN VARCHAR2,
7 p_smtp_port IN NUMBER DEFAULT 25)
8 AS
9 l_mail_conn UTL_SMTP.connection;
10 l_boundary VARCHAR2(50) := '----=*#abc1234321cba#*=';
11 BEGIN
12 l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
13 UTL_SMTP.helo(l_mail_conn, p_smtp_host);
14 UTL_SMTP.mail(l_mail_conn, p_from);
15 UTL_SMTP.rcpt(l_mail_conn, p_to);
16 UTL_SMTP.open_data(l_mail_conn);
17 UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || UTL_TCP.crlf);
18 UTL_SMTP.write_data(l_mail_conn, 'To: ' || p_to || UTL_TCP.crlf);
19 UTL_SMTP.write_data(l_mail_conn, 'From: ' || p_from || UTL_TCP.crlf);
20 UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || p_subject || UTL_TCP.crlf);
21 UTL_SMTP.write_data(l_mail_conn, 'Reply-To: ' || p_from || UTL_TCP.crlf);
22 UTL_SMTP.write_data(l_mail_conn, 'MIME-Version: 1.0' || UTL_TCP.crlf);
23 UTL_SMTP.write_data(l_mail_conn, 'Content-Type: multipart/alternative; boundary="' || l_boundary || '"' || UTL_TCP.crlf || UTL_TCP.crlf);
24 IF p_text_msg IS NOT NULL THEN
25 UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || UTL_TCP.crlf);
26 UTL_SMTP.write_data(l_mail_conn, 'Content-Type: text/plain; charset="utf-8"' || UTL_TCP.crlf || UTL_TCP.crlf);
27 UTL_SMTP.write_data(l_mail_conn, p_text_msg);
28 UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
29 END IF;
30 IF p_html_msg IS NOT NULL THEN
31 UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || UTL_TCP.crlf);
32 UTL_SMTP.write_data(l_mail_conn, 'Content-Type: text/html; charset="utf-8"' || UTL_TCP.crlf || UTL_TCP.crlf);
33 UTL_SMTP.write_data(l_mail_conn, p_html_msg);
34 UTL_SMTP.write_data(l_mail_conn, UTL_TCP.crlf || UTL_TCP.crlf);
35 END IF;
36 UTL_SMTP.write_data(l_mail_conn, '--' || l_boundary || '--' || UTL_TCP.crlf);
37 UTL_SMTP.close_data(l_mail_conn);
38 UTL_SMTP.quit(l_mail_conn);
39* END;
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 declare
2 email_text varchar2(2000);
3 contract_end_date_v date := sysdate;
4 name_v varchar2(200) := 'Riaz';
5 begin
6 email_text :='<br/><div align="right"><font size="4"><b>السيد '||name_v||' المحترم</b><br/><br/> يرجى التكرم بالعلم أن العقد الخاص بكم سينتهي بتاريخ ' || to_char(contract_end_date_v,'dd-mm-yyyy')||'<br/>. وعليه يرجـى التكـرم بإفادة إدارة الموارد البشرية في حال عدم رغبتكم بتجديد العقد خلال مدة أقصها أسبوعين من اليوم وذلك للأهمية القصوى <br/>.ولكم جزيل الشكر والتقدير </font></div>';
7 send_mail_test1('<email@domain>',
8 '<email@domain>',
9 'Hello',
10 'msg',
11 email_text,
12 '<smtp Server>',
13 25);
14* end;
SQL> /
PL/SQL procedure successfully completed.
Result*
????? Riaz ???????
???? ?????? ?????? ?? ????? ????? ??? ?????? ?????? 12-07-2011
.???? ???? ????? ????????I worked with Oracle support and was able to find solution. The helping document ids were: 752309.1 & 404389.1
-
Need to send HTML email from Workflow : problem with sender
Hi all,
i need to send HTML email from my Workflow. I did it but i have a problem with the sender. The sender of email is always the agent responsible of workitem, and i don't want the receiver can answer to sender. So i need to put a false email address like nosender.at.mycustomer.com.
Possible to do that ?
Thanks for your help.
CheersHi rick
How to change the wf-batch to some other name as you mention in previous reply. Can you give some details of that. If i use the function module SO_NEW_DOCUMENT_ATT_SEND_API1 how to change the wf-batch name and if i use send mail step in my workflow how to change wf-batch name.
Regards
vijay -
How do i send a html email from office outlook web access?
how do i send a html email from office outlook web access?
glenholmes,
You've come to the right place for help. Sorry to hear that you have had hard time with your Gmail app lately. What steps have you tried to get this to work? We want to ensure that you are able to start sending those messages right away.
ErinW_VZW
Follow us on Twitter @VZWSupport -
Sending an email to users from abap program
Hi experts ,
How to send an email to users from abap program ...
i need full coding please..so that i can copy and paste it in my program.
Thank you in advance.
Rajasekhar.PHi Venkat
check the below simple code to convert spool to HTML and email it
data: list type table of abaplist with header line.
data: htmllines type table of w3html with header line.
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
start-of-selection.
Produce a list
do 100 times.
write:/ sy-index, at 30 sy-index, at 50 sy-index.
enddo.
Save the list
call function 'SAVE_LIST'
tables
listobject = list
exceptions
list_index_invalid = 1
others = 2.
Convert the list
call function 'WWW_LIST_TO_HTML'
tables
html = htmllines.
Send mail
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Maybe you are looking for
-
Exporting to fixed length text using Crystal Enterprise 10
Post Author: adamsueryan CA Forum: Deployment I would like to know if it is possible to export from Crystal Enterprise 10 to a fixed length text file similar to the text exporting option using Crystal Reports 8.5. From Enterprise 10 I see you can ex
-
Hi In the ESS Leave Request Application , when user views the Team Calendar , he cannot see the Employee Name if it is maintained in Korean Language in BackEnd, ( Infotype PA0001-ename) but if the Name is Maintained in English Language , it is appe
-
Full screen mode and the tab key: how to ignore invisible UI elements
Hi there, When Mozilla is in windowed mode, the tab key moves between the page content, which is great. However, when it reaches the end of the page, it then goes to the tab bar, the address bar, the search bar, something I can't figure out, and only
-
Installing WAS ABAP 6.40 on HPUX/Oracle with SR1
Anyone has installed WebAS ABAP 6.40 on HPUX Oracle with the latest SR1 package released in Dec/04? Would really appreciate if you could let me know whether you have encountered any glitches during your installation process. Thanks!
-
Quick Q: Tab controls?
Is there a way to make a button 'skipped over' when using the Tab key? The search criteria form has buttons to the right of the first two text boxes, curious if its possible to have the Tab button go directly from the first field, to the second field