How to send Z Component as an attachment in workflow
Hi Experts,
I have created a custom component( Z component ) in UI and I want to send this as an attachment in worktask in workflow.
For this I created a custom business object( Z object ) and by default 'Display' method is created in it.
When I send my custom component( Z component ) as attachment I want to see my Z component, which is not happening. Although in GUI this works well. But in UI I want to see my component.
Any help will be highly appreciated.
Regards,
Vikas
Hi Experts,
I have created a custom component( Z component ) in UI and I want to send this as an attachment in worktask in workflow.
For this I created a custom business object( Z object ) and by default 'Display' method is created in it.
When I send my custom component( Z component ) as attachment I want to see my Z component, which is not happening. Although in GUI this works well. But in UI I want to see my component.
Any help will be highly appreciated.
Regards,
Vikas
Similar Messages
-
How to send an email with an attachment to the customers email address.
Hi friends,
How to send an email with an attachment to the customers email address.
the attachment will be in doc format.
Having an Header
the data which i am sending must be in a TABLE format
with 5 columns.
and each column must have a column heading
Please guide me.
Thanks in Advance,
Ganesh.*& Report ZEMAIL_ATTACH *
*& Example of sending external email via SAPCONNECT *
REPORT ZEMAIL_ATTACH .
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver .
*Here get the values of mail from the table adn6 for the customer address.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
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
'Example .xls documnet attachment'
'DOC'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM build_xls_data_table.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
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 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.
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-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
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.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
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.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
regards,
venkat. -
How to send a file as an attachment using mailx
Hi
Can any one tel me how to send a file as an attachment using mailx command in shell script.
Thanks,
Suman.Wrong forum where to ask such questions.
Check this one link:
http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254 -
How to send automatic mail and put attache file on batch file ?
how to send automatic mail and put attache file on batch file ?
START MAILTO:[email protected]?SUBJECT=PHONE%CALL^&BODY=TestingHi,
Do you want to use a batch file to create new email message (including recipients, subject and email body) with attachments? If so, I'd recommend you post your question in the Scripting Guys forum for further assistance:
https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Please feel free to let me know if I've misunderstood something.
Regards,
Steve Fan
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
How to send email notification in different languages in Workflow ?? Urgent Help Needed
Gurus,
How to send email notification in different languages in Workflow? Can anyone send me some useful guidelines or link where it is mentioned.There is no profile option available to specify whether send or not send email notification.
But after login, in preferences youcan set the notification preference value by which you can configure whether to send or not
to send email notifications.
If you select ''Do not send me mail' or 'Disabled' it will not send.
For other values it sends the notfication in different formats like text, html, attachments etc...
Edited by: sarojak on Jun 27, 2011 7:18 AM -
How to send a mail as an attachment in a mail with AppleScript?
Hi,
I want to manage my spam using the advices found in support.apple website :
OS X Mail
Open the message and choose “Forward as Attachment” from the Message menu.
Forward the message to iCloud [email protected].
Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
I don't know how to make a message as an attachment...
set theAttachment to theMessage
make new attachment with properties {file name:theAttachment} at after last paragraph
Here is my whole script, if it runs, it could be useful :
tell application "Mail"
-- envoi les messages sélectionnés en PJ à [email protected]
set theMessages to the selection
repeat with theMessage in theMessages
set theAttachment to theMessage
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set subject to "Fwd: " & theMessage's subject
make new to recipient with properties {address:"[email protected]"}
tell content of theMessage
make new attachment with properties {file name:theAttachment} at after last paragraph
end tell
end tell
send newMessage
end repeat
-- envoi les messages sélectionnés en PJ à abuse@<domaine du spammeur>
set theMessages to the selection
repeat with theMessage in theMessages
set theAttachment to theMessage
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set subject to "Fwd: " & theMessage's subject
set theSpamAddress to theMessage's sender
set AppleScript's text item delimiters to {"@"}
set spamerDomainName to text item 2 of theSpamAddress
set theNewSpamAddress to "abuse@" & spamerDomainName
make new to recipient with properties {address:theNewSpamAddress}
tell content of theMessage
make new attachment with properties {file name:theAttachment} at after last paragraph
end tell
end tell
send newMessage
end repeat
end tell
Thank you!Perfect!
You clearly give me the way. Actually I have used the AppleScript Language Guide from https://developer.apple.com to finalize my AppleScript.
You just need to select the spam message(s) in "Mail" application, then run the script.
As I mentionned previously, it just do this automatically :
OS X Mail
Open the message and choose “Forward as Attachment” from the Message menu.
Forward the message to iCloud [email protected].
Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
Here is the entire working script :
-- Ce script permet de lutter contre le spam.
-- Je me suis appuyé sur les conseils sur http://support.apple.com/kb/TS4019?viewlocale=fr_FR
tell application "Mail"
set theMessages to the selection
repeat with theMessage in theMessages
-- enregistre le message dans un fichier pour le mettre en PJ ensuite
set msgContent to source of theMessage
set tmpFile to ((path to desktop) as rich text) & "ForwardedMessage"
set referenceNumber to open for access tmpFile with write permission
write msgContent to referenceNumber
close access referenceNumber
-- envoi le message sélectionné en PJ à [email protected]
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set subject to "Fwd: " & theMessage's subject
make new to recipient with properties {address:"[email protected]"}
tell content of newMessage
make new attachment with properties {file name:tmpFile} at after last paragraph
end tell
end tell
send newMessage
-- envoi le message sélectionné en PJ à abuse@<domaine du spammeur>
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set subject to "Fwd: " & theMessage's subject
set theSpamAddress to theMessage's sender
set AppleScript's text item delimiters to {"@"}
set theSpamAddress to text item 2 of theSpamAddress
set AppleScript's text item delimiters to {">"}
set spamerDomainName to text item 1 of theSpamAddress
set theNewSpamAddress to "abuse@" & spamerDomainName
make new to recipient with properties {address:theNewSpamAddress}
tell content of newMessage
make new attachment with properties {file name:tmpFile} at after last paragraph
end tell
end tell
send newMessage
end repeat
end tell -
How to send a picture as an attachment
I'm new here and not sure I'm in the correct place .
I just bought a imac and I'm trying to send a picture as an attachment. I showes up in the body of the email. How do I get it to be just an attachment like on a computer?Try using the Finder Compress the file, then attach the resultant file to the e-mail.
-
How to send text file as an attachment to exteral mail
hi ,
Can any one tell me how to send an internal table as a textfile attachment to the external mail.
regards
kishorehi,
i am assuming txt fie attachment means you want notepad attachment
recently i struggled on this and i achieved success by doing as below
remember to keep packlist as RAW type like below:
t_packing_list-doc_type = 'RAW'.
do like this
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = t_attachment[]
IMPORTING
EP_SOLIXTAB = xtext[].
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
tables
packing_list = t_packing_list
OBJECT_HEADER =
CONTENTS_BIN = objbin
CONTENTS_TXT = it_message
CONTENTS_HEX = xtext
OBJECT_PARA =
OBJECT_PARB =
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 -
How to send an ouput as PDF attachment to email
Hi,
We have a 'Z' output for a delivery document. The output has the standard RLE_DELNOTE driver program and a Zsmart form assigned to it. We need to send the output as an attachment to email. Can some one please adivice how this can be achieved?
Thanks in advance
KatHi,
Plz try following steps.
1. Note the spool request No.
2. In T/code SE38, Enter The programme and execute.
3. In sub Object- Click Documentation and then do debuggung.
4.Enter spool request no and desired location and execute.
5. In ABAP Debugger- Use F8 key.
6. Select the desired location and file name and save.
View the desired output in PDF and can be sent through mail.
Hope this helps.
Regards,
Jaiprakash.P.T -
How to send any text as soap attachment without SAAJ ?
I have to send XML or text file as an attachment in the web service, just like email attachment. Currently I am intercepting the SOAP message (sent from web service client) and then adding an attachment using SAAJ. Can we send an attachment without intercepting and SAAJ in netbeans just like how we send other data (with basic datatypes ) as parameters to the web service operation ?
TIA.Wrong forum where to ask such questions.
Check this one link:
http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254 -
How to send a mail with PDF attachment
Hello
Good Day!
We have a requirement to send the mail with pdf attachment. Pdf file will be remain same for all mails and it will be placed at server. We are on R12.4 and below is the database information :
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Thanks a ton for your anticipated help!
Thanks
GauravThe word URGENT is considered as rude in this forum.. Nobody here is getting paid for the ansers they are giving..
Just have a look at These threads.Those will help you. -
How to send a mail as .txt attachment ,As data is seperated by pipeline
Hi ,
I got a requirement to send a mail in .txt format (Using OOPS) and the data inside the mail is seperated by '|' Pls help me in this regard.
i have written a mail to send the mail in .xls it is working fine for me in .xls but i dont know how to write the same for txt where data should be seperated by '|'.
Regards
sas
Ps: i am attaching my code. and please specify where i need to modify to achieve the same. and any perfromance enhacements are also welcome.
*& Report ZGBTEST02
REPORT YSAS_MAIL2.
*Changes done by sas
*PARAMETERS: P_MAIL TYPE AD_SMTPADR OBLIGATORY, " G C by sas
*P_MAIL1 TYPE AD_SMTPADR OBLIGATORY." G by sas
tables: adr6.
SELECT-OPTIONS:p_eaddr FOR adr6-SMTP_ADDR NO INTERVALS .
*end of changes by sas
DATA: I_GLT0 TYPE STANDARD TABLE OF GLT0.
DATA: I_MARA TYPE STANDARD TABLE OF MARA. " MARA Entries
* I_MARC TYPE STANDARD TABLE OF MARC. " MARC Entries
DATA: L_TEXT TYPE CHAR255. " Text
DATA: L_LINES TYPE I,
L_SIZE TYPE SOOD-OBJLEN.
" Size of Attachment
* Mail related
DATA: I_CONTENT TYPE SOLI_TAB, " Mail content
I_ATTACH TYPE SOLI_TAB, " Attachment
I_ATTACH1 TYPE SOLIX_TAB. " Attachment
DATA: L_SEND_REQUEST TYPE REF TO CL_BCS,
" E-Mail Send Request
L_DOCUMENT TYPE REF TO CL_DOCUMENT_BCS,
" E-Mail Attachment
L_RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,
" Distribution List
L_SENDER TYPE REF TO IF_SENDER_BCS,
" Address of Sender
L_UNAME TYPE SALRTDRCPT,
" Sender Name(SY-UNAME)
L_BCS_EXCEPTION TYPE REF TO CX_DOCUMENT_BCS,
" BCS Exception
L_ADDR_EXCEPTION TYPE REF TO CX_ADDRESS_BCS,
" Address Exception
L_SEND_EXCEPTION TYPE REF TO CX_SEND_REQ_BCS.
" E-Mail sending Exception
*Constants------------------------------------------------------------*
CONSTANTS: C_TAB(1) TYPE C VALUE
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
" Tab Character
C_CR(1) TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
" Line Feed for End-Of_line
C_EXT TYPE SOODK-OBJTP VALUE 'XLS'. " XLS Extension
START-OF-SELECTION.
SELECT * FROM MARA INTO TABLE I_MARA UP TO 20 ROWS.
IF SYST-SUBRC EQ 0.
* SELECT * FROM MARC INTO TABLE I_MARC FOR ALL ENTRIES IN I_MARA WHERE MATNR = I_MARA-MATNR.
ENDIF.
*select * from glt0 into table i_glt0.
* Preparing body of the Mail
MOVE 'SAP Material Master Records' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
CLEAR L_TEXT.
APPEND L_TEXT TO I_CONTENT.
MOVE 'Thanks,' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
MOVE 'SAP MM' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
* Creates persistent send request
TRY.
L_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
* Creating Document
L_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW'
I_TEXT = I_CONTENT[]
I_SUBJECT = 'SAS MASTER Records' ).
* Preparing contents of attachment with Change Log
PERFORM PREPARE_ATTACHMENT.
DESCRIBE TABLE I_MARA LINES L_LINES.
* Size to multiplied by 2 for UNICODE enabled systems
L_SIZE = L_LINES * 2 * 255.
* Adding Attachment
CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = C_EXT
I_ATTACHMENT_SIZE = L_SIZE
I_ATTACHMENT_SUBJECT = 'MARA Details'
* i_att_content_hex = i_attach[].
I_ATT_CONTENT_TEXT = I_ATTACH[].
* DESCRIBE TABLE I_MARC LINES L_LINES.
* Size to multiplied by 2 for UNICODE enabled systems
* L_SIZE = L_LINES * 2 * 255.
** Adding Attachment
* CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
* EXPORTING
* I_ATTACHMENT_TYPE = C_EXT
* I_ATTACHMENT_SIZE = L_SIZE
* I_ATTACHMENT_SUBJECT = 'MARC Details'
* I_ATT_CONTENT_HEX = I_ATTACH1[].
** i_att_content_text = i_attach1[].
* Add document to send request
CALL METHOD L_SEND_REQUEST->SET_DOCUMENT( L_DOCUMENT ).
DATA:LR_SENDER TYPE REF TO IF_SENDER_BCS,
LR_SEND TYPE REF TO CL_BCS.
* Preparing the sender object
* LR_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( sy-uname ).
DATA: L1_UNAME TYPE SY-UNAME.
L1_UNAME = SY-UNAME.
LR_SENDER = CL_SAPUSER_BCS=>CREATE( L1_UNAME ).
* Setting the sender
CALL METHOD L_SEND_REQUEST->SET_SENDER
EXPORTING
I_SENDER = LR_SENDER.
* E-Mail
LOOP AT P_EADDR.
TRANSLATE P_EADDR-LOW TO LOWER CASE.
L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_EADDR-LOW ).
CALL METHOD L_SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = L_RECIPIENT
I_EXPRESS = 'U'
I_COPY = ' '
I_BLIND_COPY = ' '
I_NO_FORWARD = ' '.
IF SY-subrc EQ 0.
WRITE:/'** SUCCESS: Email Sent to', p_eaddr-LOW COLOR COL_NORMAL.
ELSE.
WRITE:/'** ERROR: Failed to send Email to',p_eaddr-LOW COLOR COL_NEGATIVE .
ENDIF.
ENDLOOP.
*Trigger E-Mail immediately
L_SEND_REQUEST->SET_SEND_IMMEDIATELY( ' ' ).
CALL METHOD L_SEND_REQUEST->SEND( ).
COMMIT WORK.
CATCH CX_DOCUMENT_BCS INTO L_BCS_EXCEPTION.
CATCH CX_SEND_REQ_BCS INTO L_SEND_EXCEPTION.
CATCH CX_ADDRESS_BCS INTO L_ADDR_EXCEPTION.
ENDTRY.
*& Form PREPARE_ATTACHMENT
FORM PREPARE_ATTACHMENT .
FIELD-SYMBOLS: <LFS_TABLE>, " Internal table structure
<LFS_CON>. " Field Content
DATA: L_TEXT TYPE CHAR1024. " Text content for mail attachment
DATA: L_CON TYPE STRING. "(50) TYPE c. " Field Content in character format
DATA: L_STR TYPE STRING,
L_STR1 TYPE STRING.
DATA: LS_SOLIX TYPE SOLIX.
* Columns to be tab delimeted
LOOP AT I_MARA ASSIGNING <LFS_TABLE>.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
TO <LFS_CON>.
IF SY-SUBRC NE 0.
CONCATENATE C_CR L_TEXT INTO L_TEXT.
* CONCATENATE l_str c_cr l_text INTO l_str.
* ls_solix-line = l_text.
* APPEND ls_solix TO i_attach.
APPEND L_TEXT TO I_ATTACH.
EXIT.
ELSE.
CLEAR: L_CON.
MOVE <LFS_CON> TO L_CON.
CONDENSE L_CON.
IF SY-INDEX = 1.
CLEAR: L_TEXT.
MOVE L_CON TO L_TEXT.
ELSE.
CONCATENATE L_TEXT L_CON INTO L_TEXT
SEPARATED BY C_TAB.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
** Columns to be tab delimeted
* LOOP AT I_MARC ASSIGNING <LFS_TABLE>.
* DO.
* ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
* TO <LFS_CON>.
* IF SY-SUBRC NE 0.
* CONCATENATE C_CR L_TEXT INTO L_TEXT.
** CONCATENATE l_str c_cr l_text INTO l_str1.
* LS_SOLIX-LINE = L_TEXT.
* APPEND LS_SOLIX TO I_ATTACH1.
* EXIT.
* ELSE.
* CLEAR: L_CON.
* MOVE <LFS_CON> TO L_CON.
* CONDENSE L_CON.
* IF SY-INDEX = 1.
* CLEAR: L_TEXT.
* MOVE L_CON TO L_TEXT.
* ELSE.
* CONCATENATE L_TEXT L_CON INTO L_TEXT
* SEPARATED BY C_TAB.
* ENDIF.
* ENDIF.
* ENDDO.
* ENDLOOP.
* i_attach1[] = i_attach[].
ENDFORM. " PREPARE_ATTACHMENTHi Sas,
I have copied the code and executed and it is working fine. I'm getting the text attachement in the email.
* Adding Attachment
CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = 'TXT' " C_EXT My change
I_ATTACHMENT_SIZE = L_SIZE
I_ATTACHMENT_SUBJECT = 'MARA Details'
* i_att_content_hex = i_attach[].
I_ATT_CONTENT_TEXT = I_ATTACH[].
CONCATENATE i_mara-MATNR
i_mara-ERSDA
i_mara-ERNAM
i_mara-LAEDA
INTO L_TEXT
SEPARATED BY '|'. -
HOW TO SEND A HEBREW EMAIL WITH ATTACHMENT USING DEMO_MAIL
Hello All,
This is Not a question , just attaching something I've implemented and might be interesting for few of us,
This package I'm attaching allows to send Hebrew Language email + attaching files to it.
This package is based on demo_mail package (combined here but you can search at google for more example information if needed).
My Package is supplied as is , for any specific information regarding it , please contact me directly at : [email protected] or POST here.
* Please also note , that this package allow file to be attach via URL (meaning you will have to define a link to this file, if you would like to implement a link to a local file , e.g : c:\temp\myfile , you will have to customize the package your self with database directories option etc ...)
First I will attach an example of how to use it :
==================================
begin
demo_mail_heb.send_html_mail_attach(p_sender => '[email protected]',
p_recipients => '[email protected]',
p_subject => 'שלום וברכה עולם',
p_data => '<hr><b>בוקר טוב</b><hr>',
p_file_name => 'but_choose_file.gif',
p_file_mime_type => 'application/pdf',
p_file_URL => 'http://10.172.246.160:7777/i/but_choose_file.gif');
end;
Second Here is the Package (please note you will have to modify few settings in order to enable it , such as mail server address ..etc)
======================================================================================
CREATE OR REPLACE PACKAGE demo_mail_heb IS
----------------------- Customizable Section -----------------------
-- Customize the SMTP host, port and your domain name below.
smtp_host VARCHAR2(256) := 'mail.oracle.com';
smtp_port PLS_INTEGER := 25;
smtp_domain VARCHAR2(256) := 'oracle.com';
-- Customize the signature that will appear in the email's MIME header.
-- Useful for versioning.
MAILER_ID CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
--------------------- End Customizable Section ---------------------
-- A unique string that demarcates boundaries of parts in a multi-part email
-- The string should not appear inside the body of any part of the email.
-- Customize this if needed or generate this randomly dynamically.
BOUNDARY CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
FIRST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
LAST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
utl_tcp.CRLF;
-- A MIME type that denotes multi-part email (MIME) messages.
MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
BOUNDARY || '"';
MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER := 76 / 4 * 3;
-- Sent clear Html Email
procedure send_html_mail (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default null,
p_mime_type in varchar2 default 'text/html; charset=windows-1255');
-- Sent Html Email with Attachment
procedure send_html_mail_attach (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
p_mime_type in varchar2 default demo_mail_heb.MULTIPART_MIME_TYPE,
p_file_name in varchar2 default 'but_choose_file.gif',
p_file_mime_type in varchar2 default 'application/pdf',
p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif');
-- A simple email API for sending email in plain text in a single call.
-- The format of an email address is one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
-- The recipients is a list of email addresses separated by
-- either a "," or a ";"
PROCEDURE mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2);
-- Extended email API to send email in HTML or plain text with no size limit.
-- First, begin the email by begin_mail(). Then, call write_text() repeatedly
-- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
-- email in non-ASCII or multi-byte character set. End the email with
-- end_mail().
FUNCTION begin_mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL)
RETURN utl_smtp.connection;
-- Write email body in ASCII
PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2);
-- Write email body in non-ASCII (including multi-byte). The email body
-- will be sent in the database character set.
PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2);
-- Write email body in binary
PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
message IN RAW);
-- APIs to send email with attachments. Attachments are sent by sending
-- emails in "multipart/mixed" MIME format. Specify that MIME format when
-- beginning an email with begin_mail().
-- Send a single text attachment.
PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
data IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE);
-- Send a binary attachment. The attachment will be encoded in Base-64
-- encoding format.
PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
data IN RAW,
mime_type IN VARCHAR2 DEFAULT 'application/octet',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE);
-- Send an attachment with no size limit. First, begin the attachment
-- with begin_attachment(). Then, call write_text repeatedly to send
-- the attachment piece-by-piece. If the attachment is text-based but
-- in non-ASCII or multi-byte character set, use write_mb_text() instead.
-- To send binary attachment, the binary content should first be
-- encoded in Base-64 encoding format using the demo package for 8i,
-- or the native one in 9i. End the attachment with end_attachment.
PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
transfer_enc IN VARCHAR2 DEFAULT NULL);
-- End the attachment.
PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE);
-- End the email.
PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
-- Extended email API to send multiple emails in a session for better
-- performance. First, begin an email session with begin_session.
-- Then, begin each email with a session by calling begin_mail_in_session
-- instead of begin_mail. End the email with end_mail_in_session instead
-- of end_mail. End the email session by end_session.
FUNCTION begin_session RETURN utl_smtp.connection;
-- Begin an email in a session.
PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
-- mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL);
-- End an email in a session.
PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
-- End an email session.
PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
END;
CREATE OR REPLACE PACKAGE BODY demo_mail_heb IS
-- Sent clear Html Email
procedure send_html_mail (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default null,
p_mime_type in varchar2 default 'text/html; charset=windows-1255')
Is
conn utl_smtp.connection;
BEGIN
conn := demo_mail_heb.begin_mail(
sender => p_sender,
recipients => p_recipients,
subject => p_subject,
mime_type => p_mime_type);
demo_mail_heb.write_text(
conn => conn,
message => p_data);
demo_mail_heb.end_mail( conn => conn );
END;
-- Sent Html Email with Attachment
procedure send_html_mail_attach (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
p_mime_type in varchar2 default demo_mail_heb.MULTIPART_MIME_TYPE,
p_file_name in varchar2 default 'but_choose_file.gif',
p_file_mime_type in varchar2 default 'application/pdf',
p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif')
is
conn utl_smtp.connection;
req utl_http.req;
resp utl_http.resp;
data RAW(200);
begin
conn := demo_mail_heb.begin_mail(
sender => p_sender,
recipients => p_recipients,
subject => p_subject,
mime_type => p_mime_type);
demo_mail_heb.attach_text(
conn => conn,
data => p_data,
mime_type => 'text/html');
demo_mail_heb.begin_attachment(
conn => conn,
mime_type => p_file_mime_type,
inline => TRUE,
filename => p_file_name,
transfer_enc => 'base64');
-- In writing Base-64 encoded text following the MIME format below,
-- the MIME format requires that a long piece of data must be splitted
-- into multiple lines and each line of encoded data cannot exceed
-- 80 characters, including the new-line characters. Also, when
-- splitting the original data into pieces, the length of each chunk
-- of data before encoding must be a multiple of 3, except for the
-- last chunk. The constant demo_mail_heb.MAX_BASE64_LINE_WIDTH
-- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
-- of data before encoding.
Utl_Http.set_proxy('www-proxy.us.oracle.com', 'oracle.com');
req := utl_http.begin_request(p_file_URL);
resp := utl_http.get_response(req);
BEGIN
LOOP
utl_http.read_raw(resp, data, demo_mail_heb.MAX_BASE64_LINE_WIDTH);
demo_mail_heb.write_raw(
conn => conn,
message => utl_encode.base64_encode(data));
END LOOP;
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
demo_mail_heb.end_attachment( conn => conn );
demo_mail_heb.end_mail( conn => conn );
end;
-- Return the next email address in the list of email addresses, separated
-- by either a "," or a ";". The format of mailbox may be in one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
addr VARCHAR2(256);
i pls_integer;
FUNCTION lookup_unquoted_char(str IN VARCHAR2,
chrs IN VARCHAR2) RETURN pls_integer AS
c VARCHAR2(5);
i pls_integer;
len pls_integer;
inside_quote BOOLEAN;
BEGIN
inside_quote := false;
i := 1;
len := length(str);
WHILE (i <= len) LOOP
c := substr(str, i, 1);
IF (inside_quote) THEN
IF (c = '"') THEN
inside_quote := false;
ELSIF (c = '\') THEN
i := i + 1; -- Skip the quote character
END IF;
GOTO next_char;
END IF;
IF (c = '"') THEN
inside_quote := true;
GOTO next_char;
END IF;
IF (instr(chrs, c) >= 1) THEN
RETURN i;
END IF;
<<next_char>>
i := i + 1;
END LOOP;
RETURN 0;
END;
BEGIN
addr_list := ltrim(addr_list);
i := lookup_unquoted_char(addr_list, ',;');
IF (i >= 1) THEN
addr := substr(addr_list, 1, i - 1);
addr_list := substr(addr_list, i + 1);
ELSE
addr := addr_list;
addr_list := '';
END IF;
i := lookup_unquoted_char(addr, '<');
IF (i >= 1) THEN
addr := substr(addr, i + 1);
i := instr(addr, '>');
IF (i >= 1) THEN
addr := substr(addr, 1, i - 1);
END IF;
END IF;
RETURN addr;
END;
-- Write a MIME header
PROCEDURE write_mime_header(conn IN OUT NOCOPY utl_smtp.connection,
name IN VARCHAR2,
value IN VARCHAR2) IS
BEGIN
-- utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
utl_smtp.write_raw_data(conn, UTL_RAW.CAST_TO_RAW(name || ': ' ||value || utl_tcp.CRLF));
END;
-- Mark a message-part boundary. Set <last> to TRUE for the last boundary.
PROCEDURE write_boundary(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE) AS
BEGIN
IF (last) THEN
utl_smtp.write_data(conn, LAST_BOUNDARY);
ELSE
utl_smtp.write_data(conn, FIRST_BOUNDARY);
END IF;
END;
PROCEDURE mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2) IS
conn utl_smtp.connection;
BEGIN
conn := begin_mail(sender, recipients, subject);
write_text(conn, message);
end_mail(conn);
END;
FUNCTION begin_mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL)
RETURN utl_smtp.connection IS
conn utl_smtp.connection;
BEGIN
conn := begin_session;
begin_mail_in_session(conn, sender, recipients, subject, mime_type,
priority);
RETURN conn;
END;
PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2) IS
BEGIN
utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(CONVERT(message,'IW8ISO8859P8')));
END;
PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2) IS
BEGIN
utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
END;
PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
message IN RAW) IS
BEGIN
utl_smtp.write_raw_data(conn, message);
END;
PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
data IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE) IS
BEGIN
begin_attachment(conn, mime_type, inline, filename);
write_text(conn, data);
end_attachment(conn, last);
END;
PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
data IN RAW,
mime_type IN VARCHAR2 DEFAULT 'application/octet',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE) IS
i PLS_INTEGER;
len PLS_INTEGER;
BEGIN
begin_attachment(conn, mime_type, inline, filename, 'base64');
-- Split the Base64-encoded attachment into multiple lines
i := 1;
len := utl_raw.length(data);
WHILE (i < len) LOOP
IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
utl_smtp.write_raw_data(conn,
utl_encode.base64_encode(utl_raw.substr(data, i,
MAX_BASE64_LINE_WIDTH)));
ELSE
utl_smtp.write_raw_data(conn,
utl_encode.base64_encode(utl_raw.substr(data, i)));
END IF;
utl_smtp.write_data(conn, utl_tcp.CRLF);
i := i + MAX_BASE64_LINE_WIDTH;
END LOOP;
end_attachment(conn, last);
END;
PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
transfer_enc IN VARCHAR2 DEFAULT NULL) IS
BEGIN
write_boundary(conn);
write_mime_header(conn, 'Content-Type', mime_type);
IF (filename IS NOT NULL) THEN
IF (inline) THEN
write_mime_header(conn, 'Content-Disposition',
'inline; filename="'||filename||'"');
ELSE
write_mime_header(conn, 'Content-Disposition',
'attachment; filename="'||filename||'"');
END IF;
END IF;
IF (transfer_enc IS NOT NULL) THEN
write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
END IF;
utl_smtp.write_data(conn, utl_tcp.CRLF);
END;
PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE) IS
BEGIN
utl_smtp.write_data(conn, utl_tcp.CRLF);
IF (last) THEN
write_boundary(conn, last);
END IF;
END;
PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
end_mail_in_session(conn);
end_session(conn);
END;
FUNCTION begin_session RETURN utl_smtp.connection IS
conn utl_smtp.connection;
BEGIN
-- open SMTP connection
conn := utl_smtp.open_connection(smtp_host, smtp_port);
utl_smtp.helo(conn, smtp_domain);
RETURN conn;
END;
PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
-- mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
priority IN PLS_INTEGER DEFAULT NULL) IS
my_recipients VARCHAR2(32767) := recipients;
my_sender VARCHAR2(32767) := sender;
BEGIN
-- Specify sender's address (our server allows bogus address
-- as long as it is a full email address ([email protected]).
utl_smtp.mail(conn, get_address(my_sender));
-- Specify recipient(s) of the email.
WHILE (my_recipients IS NOT NULL) LOOP
utl_smtp.rcpt(conn, get_address(my_recipients));
END LOOP;
-- Start body of email
utl_smtp.open_data(conn);
-- Set "From" MIME header
write_mime_header(conn, 'From', sender);
-- Set "To" MIME header
write_mime_header(conn, 'To', recipients);
-- Set "Subject" MIME header
write_mime_header(conn, 'Subject', subject);
-- Set "Content-Type" MIME header
write_mime_header(conn, 'Content-Type', mime_type);
-- Set "X-Mailer" MIME header
write_mime_header(conn, 'X-Mailer', MAILER_ID);
-- Set priority:
-- High Normal Low
-- 1 2 3 4 5
IF (priority IS NOT NULL) THEN
write_mime_header(conn, 'X-Priority', priority);
END IF;
-- Send an empty line to denotes end of MIME headers and
-- beginning of message body.
utl_smtp.write_data(conn, utl_tcp.CRLF);
IF (mime_type LIKE 'multipart/mixed%') THEN
write_text(conn, 'This is a multi-part message in MIME format.' ||
utl_tcp.crlf);
END IF;
END;
PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
utl_smtp.close_data(conn);
END;
PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
utl_smtp.quit(conn);
END;
END;Hello All,
Small modification - use this package and not the above
HERE IS A WORKING CODE FOR SENDING HEBREW MESSAGES (INCLUDING SUBJECT IN UTF-8 APPEAR IN ALL EMAIL CLIENTS I HAVE CHECKED) + ATTACHMENTS
Code attached below is supplied as is with no support. anyhow if help is needed , please contact me via [email protected]
============================================================================
CREATE OR REPLACE PACKAGE demo_mail_heb IS
----------------------- Customizable Section -----------------------
-- Customize the SMTP host, port and your domain name below.
smtp_host VARCHAR2(256) := pst_ajax.getParameter('EMAIL_SMTP_HOST');
smtp_port PLS_INTEGER := pst_ajax.getParameter('EMAIL_SMTP_PORT');
smtp_domain VARCHAR2(256) := pst_ajax.getParameter('EMAIL_SMTP_DOMAIN');
-- Customize the signature that will appear in the email's MIME header.
-- Useful for versioning.
MAILER_ID CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
--------------------- End Customizable Section ---------------------
-- A unique string that demarcates boundaries of parts in a multi-part email
-- The string should not appear inside the body of any part of the email.
-- Customize this if needed or generate this randomly dynamically.
BOUNDARY CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
FIRST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
LAST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
utl_tcp.CRLF;
-- A MIME type that denotes multi-part email (MIME) messages.
MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
BOUNDARY || '"';
MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER := 76 / 4 * 3;
-- Sent clear Html Email
procedure send_html_mail (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default null,
p_mime_type in varchar2 default 'text/html; charset=windows-1255');
-- Sent Html Email with Attachment
procedure send_html_mail_attach (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
p_mime_type in varchar2 default 'text/html; charset=windows-1255',
p_file_name in varchar2 default 'but_choose_file.gif',
p_file_mime_type in varchar2 default 'application/pdf',
p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif');
-- A simple email API for sending email in plain text in a single call.
-- The format of an email address is one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
-- The recipients is a list of email addresses separated by
-- either a "," or a ";"
PROCEDURE mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2);
-- Extended email API to send email in HTML or plain text with no size limit.
-- First, begin the email by begin_mail(). Then, call write_text() repeatedly
-- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
-- email in non-ASCII or multi-byte character set. End the email with
-- end_mail().
FUNCTION begin_mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL)
RETURN utl_smtp.connection;
-- Write email body in ASCII
PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2);
-- Write email body in non-ASCII (including multi-byte). The email body
-- will be sent in the database character set.
PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2);
-- Write email body in binary
PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
message IN RAW);
-- APIs to send email with attachments. Attachments are sent by sending
-- emails in "multipart/mixed" MIME format. Specify that MIME format when
-- beginning an email with begin_mail().
-- Send a single text attachment.
PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
data IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE);
-- Send a binary attachment. The attachment will be encoded in Base-64
-- encoding format.
PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
data IN RAW,
mime_type IN VARCHAR2 DEFAULT 'application/octet',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE);
-- Send an attachment with no size limit. First, begin the attachment
-- with begin_attachment(). Then, call write_text repeatedly to send
-- the attachment piece-by-piece. If the attachment is text-based but
-- in non-ASCII or multi-byte character set, use write_mb_text() instead.
-- To send binary attachment, the binary content should first be
-- encoded in Base-64 encoding format using the demo package for 8i,
-- or the native one in 9i. End the attachment with end_attachment.
PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
transfer_enc IN VARCHAR2 DEFAULT NULL);
-- End the attachment.
PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE);
-- End the email.
PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
-- Extended email API to send multiple emails in a session for better
-- performance. First, begin an email session with begin_session.
-- Then, begin each email with a session by calling begin_mail_in_session
-- instead of begin_mail. End the email with end_mail_in_session instead
-- of end_mail. End the email session by end_session.
FUNCTION begin_session RETURN utl_smtp.connection;
-- Handling the Email Subject Line
function mimeheader_encode(
p_str varchar2
, p_charset varchar2 := 'UTF-8') return varchar2;
-- Begin an email in a session.
PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
-- mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL);
-- End an email in a session.
PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
-- End an email session.
PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
END;
CREATE OR REPLACE PACKAGE BODY demo_mail_heb IS
-- Sent clear Html Email
procedure send_html_mail (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default null,
p_mime_type in varchar2 default 'text/html; charset=windows-1255')
Is
conn utl_smtp.connection;
BEGIN
conn := demo_mail_heb.begin_mail(
sender => p_sender,
recipients => p_recipients,
subject => p_subject,
mime_type => 'text/html; charset=UTF-8');--p_mime_type);
demo_mail_heb.write_text(
conn => conn,
message => p_data);
demo_mail_heb.end_mail( conn => conn );
END;
-- Sent Html Email with Attachment
procedure send_html_mail_attach (p_sender in varchar2 default null,
p_recipients in varchar2 default null,
p_subject in varchar2 default null,
p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
p_mime_type in varchar2 default 'text/html; charset=windows-1255',
p_file_name in varchar2 default 'but_choose_file.gif',
p_file_mime_type in varchar2 default 'application/pdf',
p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif')
is
conn utl_smtp.connection;
req utl_http.req;
resp utl_http.resp;
data RAW(200);
v_mime_type varchar2(32767):=demo_mail.MULTIPART_MIME_TYPE;
begin
conn := demo_mail_heb.begin_mail(
sender => p_sender,
recipients => p_recipients,
subject => p_subject,
mime_type => v_mime_type);
demo_mail_heb.attach_text(
conn => conn,
data => p_data,
mime_type => 'text/html');
demo_mail_heb.begin_attachment(
conn => conn,
mime_type => p_file_mime_type,
inline => TRUE,
filename => p_file_name,
transfer_enc => 'base64');
-- In writing Base-64 encoded text following the MIME format below,
-- the MIME format requires that a long piece of data must be splitted
-- into multiple lines and each line of encoded data cannot exceed
-- 80 characters, including the new-line characters. Also, when
-- splitting the original data into pieces, the length of each chunk
-- of data before encoding must be a multiple of 3, except for the
-- last chunk. The constant demo_mail_heb.MAX_BASE64_LINE_WIDTH
-- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
-- of data before encoding.
req := utl_http.begin_request(p_file_URL);
resp := utl_http.get_response(req);
BEGIN
LOOP
utl_http.read_raw(resp, data, demo_mail_heb.MAX_BASE64_LINE_WIDTH);
demo_mail_heb.write_raw(
conn => conn,
message => utl_encode.base64_encode(data));
END LOOP;
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(resp);
END;
demo_mail_heb.end_attachment( conn => conn );
demo_mail_heb.end_mail( conn => conn );
end;
-- Return the next email address in the list of email addresses, separated
-- by either a "," or a ";". The format of mailbox may be in one of these:
-- someone@some-domain
-- "Someone at some domain" <someone@some-domain>
-- Someone at some domain <someone@some-domain>
FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
addr VARCHAR2(256);
i pls_integer;
FUNCTION lookup_unquoted_char(str IN VARCHAR2,
chrs IN VARCHAR2) RETURN pls_integer AS
c VARCHAR2(5);
i pls_integer;
len pls_integer;
inside_quote BOOLEAN;
BEGIN
inside_quote := false;
i := 1;
len := length(str);
WHILE (i <= len) LOOP
c := substr(str, i, 1);
IF (inside_quote) THEN
IF (c = '"') THEN
inside_quote := false;
ELSIF (c = '\') THEN
i := i + 1; -- Skip the quote character
END IF;
GOTO next_char;
END IF;
IF (c = '"') THEN
inside_quote := true;
GOTO next_char;
END IF;
IF (instr(chrs, c) >= 1) THEN
RETURN i;
END IF;
<<next_char>>
i := i + 1;
END LOOP;
RETURN 0;
END;
BEGIN
addr_list := ltrim(addr_list);
i := lookup_unquoted_char(addr_list, ',;');
IF (i >= 1) THEN
addr := substr(addr_list, 1, i - 1);
addr_list := substr(addr_list, i + 1);
ELSE
addr := addr_list;
addr_list := '';
END IF;
i := lookup_unquoted_char(addr, '<');
IF (i >= 1) THEN
addr := substr(addr, i + 1);
i := instr(addr, '>');
IF (i >= 1) THEN
addr := substr(addr, 1, i - 1);
END IF;
END IF;
RETURN addr;
END;
-- Write a MIME header
PROCEDURE write_mime_header(conn IN OUT NOCOPY utl_smtp.connection,
name IN VARCHAR2,
value IN VARCHAR2) IS
BEGIN
-- utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
utl_smtp.write_raw_data(conn, UTL_RAW.CAST_TO_RAW(name || ': ' ||value || utl_tcp.CRLF));
END;
-- Mark a message-part boundary. Set <last> to TRUE for the last boundary.
PROCEDURE write_boundary(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE) AS
BEGIN
IF (last) THEN
utl_smtp.write_data(conn, LAST_BOUNDARY);
ELSE
utl_smtp.write_data(conn, FIRST_BOUNDARY);
END IF;
END;
PROCEDURE mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2) IS
conn utl_smtp.connection;
BEGIN
conn := begin_mail(sender, recipients, subject);
write_text(conn, message);
end_mail(conn);
END;
FUNCTION begin_mail(sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
priority IN PLS_INTEGER DEFAULT NULL)
RETURN utl_smtp.connection IS
conn utl_smtp.connection;
BEGIN
conn := begin_session;
begin_mail_in_session(conn, sender, recipients, subject, mime_type,
priority);
RETURN conn;
END;
PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2) IS
BEGIN
utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(CONVERT(message,'IW8ISO8859P8')));
-- utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
END;
PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
message IN VARCHAR2) IS
BEGIN
utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
END;
PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
message IN RAW) IS
BEGIN
utl_smtp.write_raw_data(conn, message);
END;
PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
data IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE) IS
BEGIN
begin_attachment(conn, mime_type, inline, filename);
write_text(conn, data);
end_attachment(conn, last);
END;
PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
data IN RAW,
mime_type IN VARCHAR2 DEFAULT 'application/octet',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
last IN BOOLEAN DEFAULT FALSE) IS
i PLS_INTEGER;
len PLS_INTEGER;
BEGIN
begin_attachment(conn, mime_type, inline, filename, 'base64');
-- Split the Base64-encoded attachment into multiple lines
i := 1;
len := utl_raw.length(data);
WHILE (i < len) LOOP
IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
utl_smtp.write_raw_data(conn,
utl_encode.base64_encode(utl_raw.substr(data, i,
MAX_BASE64_LINE_WIDTH)));
ELSE
utl_smtp.write_raw_data(conn,
utl_encode.base64_encode(utl_raw.substr(data, i)));
END IF;
utl_smtp.write_data(conn, utl_tcp.CRLF);
i := i + MAX_BASE64_LINE_WIDTH;
END LOOP;
end_attachment(conn, last);
END;
PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
inline IN BOOLEAN DEFAULT TRUE,
filename IN VARCHAR2 DEFAULT NULL,
transfer_enc IN VARCHAR2 DEFAULT NULL) IS
BEGIN
write_boundary(conn);
write_mime_header(conn, 'Content-Type', mime_type);
IF (filename IS NOT NULL) THEN
IF (inline) THEN
write_mime_header(conn, 'Content-Disposition',
'inline; filename="'||filename||'"');
ELSE
write_mime_header(conn, 'Content-Disposition',
'attachment; filename="'||filename||'"');
END IF;
END IF;
IF (transfer_enc IS NOT NULL) THEN
write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
END IF;
utl_smtp.write_data(conn, utl_tcp.CRLF);
END;
PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
last IN BOOLEAN DEFAULT FALSE) IS
BEGIN
utl_smtp.write_data(conn, utl_tcp.CRLF);
IF (last) THEN
write_boundary(conn, last);
END IF;
END;
PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
end_mail_in_session(conn);
end_session(conn);
END;
FUNCTION begin_session RETURN utl_smtp.connection IS
conn utl_smtp.connection;
BEGIN
-- open SMTP connection
conn := utl_smtp.open_connection(smtp_host, smtp_port);
utl_smtp.helo(conn, smtp_domain);
RETURN conn;
END;
-- Handling the Email Subject Line
function mimeheader_encode(
p_str varchar2
, p_charset varchar2 := 'UTF-8') return varchar2 is
l_str varchar2(2000);
begin
l_str:=utl_raw.cast_to_varchar2(utl_encode.quoted_printable_encode(utl_raw.cast_to_raw(p_str)));
l_str:=replace(l_str,'='||chr(13)||chr(10),''); --unfold the data
l_str:=replace(l_str,'?','=3f'); --quote question marks
l_str:=replace(l_str,' ','=20'); --quote spaces
l_str:='=?'||p_charset||'?Q?'||l_str||'?='; -- add prefix and suffix
return l_str;
end;
PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
sender IN VARCHAR2,
recipients IN VARCHAR2,
subject IN VARCHAR2,
mime_type IN VARCHAR2 DEFAULT 'text/plain',
-- mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
priority IN PLS_INTEGER DEFAULT NULL) IS
my_recipients VARCHAR2(32767) := recipients;
my_sender VARCHAR2(32767) := sender;
BEGIN
-- Specify sender's address (our server allows bogus address
-- as long as it is a full email address ([email protected]).
utl_smtp.mail(conn, get_address(my_sender));
-- Specify recipient(s) of the email.
WHILE (my_recipients IS NOT NULL) LOOP
utl_smtp.rcpt(conn, get_address(my_recipients));
END LOOP;
-- Start body of email
utl_smtp.open_data(conn);
-- Set "From" MIME header
write_mime_header(conn, 'From', sender);
-- Set "To" MIME header
write_mime_header(conn, 'To', recipients);
-- Set "Content-Type" MIME header
write_mime_header(conn, 'Content-Type', mime_type);
-- write_mime_header(conn, 'Content-Type', 'text/html; charset=UTF-8');
-- Set "Subject" MIME header
-- write_mime_header(conn, 'Subject', subject);
-- write_mime_header(conn, 'Subject', CONVERT(subject,'IW8ISO8859P8'));
write_mime_header(conn, 'Subject',mimeheader_encode(p_str => subject,p_charset => 'UTF-8'));
-- write_mime_header(conn, 'Subject',CONVERT(subject,'IW8MSWIN1255'));
-- Set "X-Mailer" MIME header
write_mime_header(conn, 'X-Mailer', MAILER_ID);
-- Set priority:
-- High Normal Low
-- 1 2 3 4 5
IF (priority IS NOT NULL) THEN
write_mime_header(conn, 'X-Priority', priority);
END IF;
-- Send an empty line to denotes end of MIME headers and
-- beginning of message body.
utl_smtp.write_data(conn, utl_tcp.CRLF);
IF (mime_type LIKE 'multipart/mixed%') THEN
write_text(conn, 'This is a multi-part message in MIME format.' ||
utl_tcp.crlf);
END IF;
END;
PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
utl_smtp.close_data(conn);
END;
PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
BEGIN
utl_smtp.quit(conn);
END;
END; -
How to send a mail as .txt attachment ?
Hi all,
I got a requirement to write code for sending mail in oops.
i have written code for .xls which is working fine. But requirement is to send the mail in the format of txt.
i just only chnge the .xls to .txt where i can see the output properly in sap but problem is that i am unable to get the proper alignment. when i execute the report and see the output in sost i can see the attachment.i am downloading the attachment there only(Our server is not configured to get the mails directly) .So when i open the saved text file on my pc the output is appearing as follows...
pernr nachn vorna
0001 L0001 F0001
0002 L0002 F0002
0003 L0003 F0003
0004 L0004 F0004...
Where it should come in straight line as follows in my o/p code..
pernr nachn vorna
0001 L0001 F0001
0002 L0002 F0002
0003 L0003 F0003
0004 L0004 F0004...
i am puttin g my code ..please correct me where i am wrong .....waiting for your valuabel inputs..
*& Report ZGBTEST02
REPORT YSAS_MAIL2.
*Changes done by sas
*PARAMETERS: P_MAIL TYPE AD_SMTPADR OBLIGATORY, " G C by sas
*P_MAIL1 TYPE AD_SMTPADR OBLIGATORY." G by sas
TABLES: ADR6.
SELECT-OPTIONS:P_EADDR FOR ADR6-SMTP_ADDR NO INTERVALS .
*end of changes by sas
DATA: I_GLT0 TYPE STANDARD TABLE OF GLT0.
*DATA: I_pernr TYPE STANDARD TABLE OF pa0002. " MARA Entries
DATA: BEGIN OF I_PERNR OCCURS 1 ,
PERNR TYPE PA0002-PERNR,
NACHN TYPE PA0002-NACHN,
VORNA TYPE PA0002-VORNA,
END OF I_PERNR..
* I_MARC TYPE STANDARD TABLE OF MARC. " MARC Entries
DATA: L_TEXT TYPE CHAR255. " Text
DATA: L_LINES TYPE I,
L_SIZE TYPE SOOD-OBJLEN.
" Size of Attachment
* Mail related
DATA: I_CONTENT TYPE SOLI_TAB, " Mail content
I_ATTACH TYPE SOLI_TAB, " Attachment
I_ATTACH1 TYPE SOLIX_TAB. " Attachment
DATA: L_SEND_REQUEST TYPE REF TO CL_BCS,
" E-Mail Send Request
L_DOCUMENT TYPE REF TO CL_DOCUMENT_BCS,
" E-Mail Attachment
L_RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,
" Distribution List
L_SENDER TYPE REF TO IF_SENDER_BCS,
" Address of Sender
L_UNAME TYPE SALRTDRCPT,
" Sender Name(SY-UNAME)
L_BCS_EXCEPTION TYPE REF TO CX_DOCUMENT_BCS,
" BCS Exception
L_ADDR_EXCEPTION TYPE REF TO CX_ADDRESS_BCS,
" Address Exception
L_SEND_EXCEPTION TYPE REF TO CX_SEND_REQ_BCS.
" E-Mail sending Exception
*Constants------------------------------------------------------------*
CONSTANTS: C_TAB(1) TYPE C VALUE
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
" Tab Character
C_CR(1) TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
" Line Feed for End-Of_line
C_EXT TYPE SOODK-OBJTP VALUE 'TXT'. " XLS Extension
START-OF-SELECTION.
SELECT PERNR NACHN VORNA FROM PA0002 INTO CORRESPONDING FIELDS OF TABLE I_PERNR UP TO 20 ROWS.
*select * from glt0 into table i_glt0.
* Preparing body of the Mail
* MOVE 'SAP Material Master Records' TO L_TEXT.
* APPEND L_TEXT TO I_CONTENT.
* CLEAR L_TEXT.
* APPEND L_TEXT TO I_CONTENT.
* MOVE 'Thanks,' TO L_TEXT.
* APPEND L_TEXT TO I_CONTENT.
* MOVE 'SAP MM' TO L_TEXT.
* APPEND L_TEXT TO I_CONTENT.
MOVE '<BR>Attached is your HRIS report(s) generated from the Firm''s' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
MOVE ' Human Resources Information System (SAP).' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
MOVE '<BR> ' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
MOVE '<BR>This is an automated report.' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
* MOVE '<BR> ' TO l_text.
* APPEND l_text TO i_content.
MOVE '<BR> ' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
* MOVE '<BR>Please do not reply to this email' TO l_text.
* APPEND l_text TO i_content.
* MOVE '<BR> ' TO l_text.
* APPEND l_text TO i_content.
MOVE '<BR>Thank you.' TO L_TEXT.
APPEND L_TEXT TO I_CONTENT.
* Creates persistent send request
TRY.
L_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
* Creating Document
L_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW'
I_TEXT = I_CONTENT[]
I_SUBJECT = 'Automated HRIS (SAP) Report' ).
DATA: W_PERNR LIKE I_PERNR.
* Preparing contents of attachment with Change Log
PERFORM PREPARE_ATTACHMENT.
DATA: compressed like solisti1 occurs 10 with header line.
DATA: decompressed like solisti1 occurs 10 with header line.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
* in = eerec
in = i_attach
out = compressed.
CALL FUNCTION 'TABLE_DECOMPRESS'
TABLES
in = compressed
out = decompressed.
DESCRIBE TABLE decompressed LINES L_LINES.
* Size to multiplied by 2 for UNICODE enabled systems
L_SIZE = L_LINES * 2 * 255.
* Adding Attachment
CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = C_EXT
I_ATTACHMENT_SIZE = L_SIZE
I_ATTACHMENT_SUBJECT = 'Hr Details'
* i_att_content_hex = i_attach[].
I_ATT_CONTENT_TEXT = decompressed[].
* DESCRIBE TABLE I_MARC LINES L_LINES.
* Size to multiplied by 2 for UNICODE enabled systems
* L_SIZE = L_LINES * 2 * 255.
** Adding Attachment
* CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
* EXPORTING
* I_ATTACHMENT_TYPE = C_EXT
* I_ATTACHMENT_SIZE = L_SIZE
* I_ATTACHMENT_SUBJECT = 'MARC Details'
* I_ATT_CONTENT_HEX = I_ATTACH1[].
** i_att_content_text = i_attach1[].
* Add document to send request
CALL METHOD L_SEND_REQUEST->SET_DOCUMENT( L_DOCUMENT ).
DATA:LR_SENDER TYPE REF TO IF_SENDER_BCS,
LR_SEND TYPE REF TO CL_BCS.
* Preparing the sender object
* LR_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( sy-uname ).
DATA: L1_UNAME TYPE SY-UNAME.
L1_UNAME = SY-UNAME.
LR_SENDER = CL_SAPUSER_BCS=>CREATE( L1_UNAME ).
* Setting the sender
CALL METHOD L_SEND_REQUEST->SET_SENDER
EXPORTING
I_SENDER = LR_SENDER.
* E-Mail
LOOP AT P_EADDR.
TRANSLATE P_EADDR-LOW TO LOWER CASE.
L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_EADDR-LOW ).
CALL METHOD L_SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = L_RECIPIENT
I_EXPRESS = 'U'
I_COPY = ' '
I_BLIND_COPY = ' '
I_NO_FORWARD = ' '.
IF SY-SUBRC EQ 0.
WRITE:/'** SUCCESS: Email Sent to', P_EADDR-LOW COLOR COL_NORMAL.
ELSE.
WRITE:/'** ERROR: Failed to send Email to',P_EADDR-LOW COLOR COL_NEGATIVE .
ENDIF.
ENDLOOP.
*Trigger E-Mail immediately
L_SEND_REQUEST->SET_SEND_IMMEDIATELY( ' ' ).
CALL METHOD L_SEND_REQUEST->SEND( ).
COMMIT WORK.
CATCH CX_DOCUMENT_BCS INTO L_BCS_EXCEPTION.
CATCH CX_SEND_REQ_BCS INTO L_SEND_EXCEPTION.
CATCH CX_ADDRESS_BCS INTO L_ADDR_EXCEPTION.
ENDTRY.
*& Form PREPARE_ATTACHMENT
FORM PREPARE_ATTACHMENT .
FIELD-SYMBOLS: <LFS_TABLE>, " Internal table structure
<LFS_CON>. " Field Content
DATA: L_TEXT TYPE CHAR1024. " Text content for mail attachment
DATA: L_CON TYPE STRING. "(50) TYPE c. " Field Content in character format
DATA: L_STR TYPE STRING,
L_STR1 TYPE STRING.
*data: w_pernr type TABLE OF I_PERNR.
DATA: LS_SOLIX TYPE SOLIX.
* CONCATENATE 'PERNR' 'FIRST NAME' 'Last Name' C_CR INTO L_TEXT SEPARATED BY '|'.
* append l_text to i_attach.
* clear l_text.
* Columns to be tab delimeted
LOOP AT I_PERNR ASSIGNING <LFS_TABLE>.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
TO <LFS_CON>.
IF SY-SUBRC NE 0.
CONCATENATE C_CR L_TEXT INTO L_TEXT.
* CONCATENATE l_str c_cr l_text INTO l_str.
* ls_solix-line = l_text.
* APPEND ls_solix TO i_attach.
APPEND L_TEXT TO I_ATTACH.
EXIT.
ELSE.
CLEAR: L_CON.
MOVE <LFS_CON> TO L_CON.
CONDENSE L_CON.
IF SY-INDEX = 1.
CLEAR: L_TEXT.
MOVE L_CON TO L_TEXT.
ELSE.
CONCATENATE L_TEXT L_CON INTO L_TEXT
SEPARATED BY C_TAB.
ENDIF.
ENDIF.
ENDDO.
ENDLOOP.
* i_attach1[] = i_attach[].
ENDFORM. " PREPARE_ATTACHMENT
Please if any one having 6.0 version please upload it and see..
Regards
SasHi ,
Did you downloaded from SOST using the display icon and inside that 4th tab for attachment ....
and see?
Regards
sas
pS: THE FIRST page is not allowing the spaces in sdn...
i am getting o/p as
pernr vochn norna
.........0001 f0001 l0001
.................0002 F0002 L0002
.......................0003 F0003 L0003.....
Please remove dots and understand that is the o/p i am getting in my presenation file
i just expecting the o/p as told earlier..
Regards
sas -
Dear Expert,
I am using the folowing code to get the content of smartform as otfdata :
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = v_formname
IMPORTING
fm_name = v_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = control_parameters
output_options = output_options
orderadm_h = orderadm_h
activity_h = activity_h
status_i = status_i
working_set_e_s_bbp = working_set_e_s_bbp
language = l_langu "sY-LANGU
IMPORTING
document_output_info = document_output_info
job_output_info = job_output_info
job_output_options = job_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
How can I send the data in job_output_info-otfdata in the email body without putting it into attachment?
I am using the function u201CSO_DOCUMENT_SEND_API1u201D.
I am sending also a normal text in the email and I want to put the data in the job_output_info-otfdata at the end of the text.
Thank for very much in advance.
Best regards
Ahmed HadiHi Ahmed,
I believe this blog will help you:
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID1330314450DB01968839116473008128End?blog=/pub/wlg/2273
Kind regards,
Garcia
Maybe you are looking for
-
Sales order charge to several different GL account instead of to customer
Hi Guru, We have a process that need to create a sales order and charge to three different GL account instead of charging to a customer. The following details the situation: In regular sales order: Debit customer $1000 Credit Sales $1000 In this bus
-
Error -50 when trying to sync photos
we have a 3 gen red nano that is just over 1 year old. When trying to sync photos, we get a message that the idod can't be synced. An unknown error (-50) occurred. Can anyone please help??
-
Document Dimensions "Box" Disappeared (black box)
I started Illustrator CS3 today and the dimensions box is no longer visible when I create a new document (sorry, I don't know the term for what I am trying to describe). Instead of the usual "black box" that shows my canvas, Illustrator loads a Gree
-
MSS iView 'Team Calendar' display only one Month
Hi , The Managers want to see at least 3 months for the leave , in order to schedule resources/coverage .MSS iView 'Team Calendar' display only one Month . Can we change the number of months ? or use another tool/functionality via the portal ? Any he
-
BI presentation Services are down
Hi Gurus, My Presentation services are down and i am not able to start the same. I am receiving below error File:cachemgr.cpp Line:287 Location: saw.sqlNodeCacheMgr.loadCatalog saw.webextensionbase.init saw.sawserver ecid: [OBIPS] [NOTIFICATION:1] []