Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Emailing An icon ie Gif File

Hi all,

I have a Folder which contains two files and 2 gif images.At present i am able to mail the two files.I want to mail the two giff files also.CAn any let know about that.My perform for sending mail is.

PERFORM send_file_as_email_attachment

TABLES it_message

it_attach

USING 'Ramesh.Mahankali@ranbaxy.com'

'TCS Details'

'HTM'

'filename'

' '

' '

' '

CHANGING gd_error

gd_reciever.

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.

CONSTANTS:

con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

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,

w_doc_data LIKE sodocchgi1.

DATA v_sent TYPE sonv-flag.

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 = 'P'.

CLEAR it_message.

REFRESH it_message.

it_message[] = 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 = 1.

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

REFRESH it_message.

it_message[] = it_html[].

t_packing_list-transf_bin = ' '.

t_packing_list-head_start = 1.

t_packing_list-head_num = 4.

t_packing_list-body_start = 1.

CLEAR v_num.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

v_num = t_packing_list-body_num.

t_packing_list-doc_type = ld_format.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = 'TCS Scenario'.

t_packing_list-doc_size = t_packing_list-body_num * 255.

APPEND t_packing_list.

  • Second attachment

REFRESH it_message1.

CONCATENATE 'Product'

'Description'

'Plant'

'SNP Planner'

'Product Class'

'Mode'

'Curr. TCS Value'

'Proposed TCS Value'

'New TCS Value'

INTO it_message1-line SEPARATED BY con_tab.

APPEND it_message1.

LOOP AT t_scr_upload INTO s_scr_upload.

v_cat102 = s_scr_upload-cat102.

v_pat102 = s_scr_upload-pat102.

v_nat102 = s_scr_upload-nat102.

CONCATENATE s_scr_upload-matnr

s_scr_upload-maktx

s_scr_upload-locno

s_scr_upload-planner_snp

s_scr_upload-at103

s_scr_upload-dmode

v_cat102

v_pat102

v_nat102

INTO it_message1-line SEPARATED BY con_tab.

APPEND it_message1.

ENDLOOP.

APPEND LINES OF it_message1 TO it_message.

v_num = v_num + 1.

t_packing_list-transf_bin = ' '.

t_packing_list-head_start = 1.

t_packing_list-head_num = 4.

t_packing_list-body_start = v_num.

DESCRIBE TABLE it_message LINES t_packing_list-body_num.

t_packing_list-doc_type = 'XLS'.

t_packing_list-obj_descr = ld_attdescription.

t_packing_list-obj_name = 'TCS UPload'.

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.

SELECT SINGLE email FROM zdrp_tcsmail INTO v_email WHERE vkorg = p_vkorg.

SPLIT v_email AT ',' INTO TABLE itab_temp_email.

LOOP AT itab_temp_email.

t_receivers-receiver = itab_temp_email-emailid.

t_receivers-rec_type = 'U'.

t_receivers-com_type = 'INT'.

t_receivers-notif_del = 'X'.

t_receivers-notif_ndel = 'X'.

APPEND t_receivers.

ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = w_doc_data

put_in_outbox = 'X'

commit_work = 'X'

IMPORTING

sent_to_all = v_sent

  • NEW_OBJECT_ID =

TABLES

packing_list = t_packing_list

  • OBJECT_HEADER =

  • CONTENTS_BIN =

contents_txt = it_message

  • CONTENTS_HEX =

  • 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

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • Populate zreceiver return code

LOOP AT t_receivers.

ld_receiver = t_receivers-retrn_code.

ENDLOOP.

Regards

Ahsan

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question