2017 Jun 08 11:36 AM
Hi Experts,
I would like to know how to send the mail with image by using the FM SO_DOCUMENT_SEND_API1.
I am using the following statement for logo in my email body.
lt_message = '<img width=130 height=21 src="mylogo.bmp"'.
I don't know which tcode will be used to upload the image. I have uploaded the image in both se78 and oaer. But it does not work. Kindly help me.
Regards,
Tamilselvan.M
Hi Experts,
I would like to know how to send the mail with image by using the FM SO_DOCUMENT_SEND_API1.
I am using the following statement for logo in my email body.
lt_message = '<img width=130 height=21 src="mylogo.bmp"'.
I don't know which tcode will be used to upload the image. I have uploaded the image in both se78 and oaer. But it does not work. Kindly help me.
Regards,
Tamilselvan.M
2017 Jun 08 12:49 PM
NB: No longer use an outdated FM like SO_DOCUMENT_SEND_API1, even if it already allowed attachments, but a class like CL_BCS...
Attach the image to the mail and in the html body use an url like CID:logo.gif using same name than appended document. Perform some search for methods cl_document_bcs->create_document and add_attachment, cl_bcs->set_document in scn forums.
If you don't feel confident with class, old SAPscript FM like SAPSCRIPT_[GET,SEARCH]_GRAPHIC_BDS and SAPSCRIPT_CONVERT_BITMAP can extract and convert SE78 images.
2017 Jun 08 2:57 PM
Hi Raymond,
Thanks!
I am still having the doubt. If you see my question, there is src property in image tag. In that, I have used mylogo.bmp. I have maintained in both SE78 and OAER. But it is still not working.
Can you tell me where to store the mylogo.bmp logo for this scenario?
Regards,
Tamilselvan.M
2017 Jun 08 3:03 PM
2017 Jun 08 5:40 PM
Hi Raymond,
Well, I can understand that. My question is very simple and straight forward. I have declared the mylogo.bmp in HTML body. When I checked SOSG tcode, I am not able to see my logo in mail body.
In order to access mylogo.bmp, where shall I upload the logo in sap system?
Regards,
Tamilselvan.M
2017 Jun 09 6:32 AM
2017 Jun 11 9:53 AM
Hi Raymond,
Thanks.
When I try to upload the logo in SMW0, it is asking for the package. Even though I have given the customized package, it does not accept. How shall we upload the image in custom package in SMW0?
Regards,
Tamilselvan.M
2017 Jun 12 4:11 AM
hi tamil,
Just see that code for send mail with CL_BCS class and 'HTM' Usage.
TABLES : eine ,
marc ,
lfa1 .
TYPES : BEGIN OF st_apvend ,
lifnr TYPE lifnr,
name1 TYPE name1_gp,
matnr TYPE matnr,
maktx TYPE maktx,
adrnr TYPE lfa1-adrnr,
END OF st_apvend.
DATA: wa_apvend TYPE st_apvend,
wa_apvend1 TYPE st_apvend, "FOR MAIL
itvend TYPE TABLE OF st_apvend.
DATA : whr_clause TYPE string,
opr(4) TYPE c VALUE ' AND'.
TYPES : BEGIN OF st_adr6,
smtp_addr TYPE adr6-smtp_addr,
addrnumber TYPE adr6-addrnumber,
END OF st_adr6.
DATA : wa_adr6 TYPE st_adr6.
DATA: vend TYPE lfa1-lifnr .
SELECT-OPTIONS : ekgrp FOR eine-ekgrp NO-DISPLAY,
vend1 FOR vend NO-DISPLAY ,
lgpro FOR marc-lgpro NO-DISPLAY.
PARAMETERS p_lifnr TYPE lifnr NO-DISPLAY.
CONSTANTS: gc_tab TYPE c VALUE cl_bcs_convert=>gc_tab,
gc_crlf TYPE c VALUE cl_bcs_convert=>gc_crlf.
DATA: mailto TYPE ad_smtpadr.
DATA send_request TYPE REF TO cl_bcs.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA bcs_exception TYPE REF TO cx_bcs.
DATA : it_contents TYPE soli_tab,
wa_contents LIKE LINE OF it_contents.
DATA binary_content TYPE solix_tab.
DATA size TYPE so_obj_len.
DATA sent_to_all TYPE os_boolean.
TYPES : BEGIN OF st_lfa1,
lifnr TYPE lfa1-lifnr,
adrnr TYPE lfa1-adrnr,
END OF st_lfa1.
DATA : it_lfa1 TYPE TABLE OF st_lfa1,
wa_lfa1 TYPE st_lfa1.
TYPES : BEGIN OF st_lfm1,
lifnr TYPE lfm1-lifnr,
verkf TYPE lfm1-verkf,
END OF st_lfm1.
DATA : wa_lfm1 TYPE st_lfm1.
TYPES : BEGIN OF ty_mail,
addrnumber TYPE adr6-addrnumber,
smtp_addr TYPE adr6-smtp_addr,
END OF ty_mail.
DATA : it_mail TYPE TABLE OF ty_mail WITH HEADER LINE.
SELECT-OPTIONS s_lifnr FOR lfa1-lifnr.
START-OF-SELECTION.
IF s_lifnr IS NOT INITIAL.
SELECT lifnr adrnr FROM lfa1 INTO CORRESPONDING FIELDS OF TABLE it_lfa1 WHERE lifnr IN s_lifnr.
LOOP AT it_lfa1 INTO wa_lfa1.
p_lifnr = wa_lfa1-lifnr.
REFRESH: it_mail[].
PERFORM create_content.
SELECT addrnumber smtp_addr INTO TABLE it_mail FROM adr6 WHERE addrnumber = wa_lfa1-adrnr.
LOOP AT it_mail.
mailto = it_mail-smtp_addr.
PERFORM send.
ENDLOOP.
ENDLOOP.
ELSE.
MESSAGE 'Please Fill Supplier Number In Field' TYPE 'I'.
ENDIF.
FORM send.
CLEAR : wa_contents.
REFRESH : it_contents[].
TRY.
send_request = cl_bcs=>create_persistent( ).
wa_contents-line = text-001.
REPLACE '&1' WITH wa_lfm1-verkf INTO wa_contents-line.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-024.
APPEND wa_contents TO it_contents.
wa_contents-line = text-002.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-003.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-004.
APPEND wa_contents TO it_contents.
wa_contents-line = text-005.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-006.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-007.
APPEND wa_contents TO it_contents.
wa_contents-line = text-008.
APPEND wa_contents TO it_contents.
wa_contents-line = ' '.
APPEND wa_contents TO it_contents.
wa_contents-line = text-009.
APPEND wa_contents TO it_contents.
wa_contents-line = text-010.
APPEND wa_contents TO it_contents.
wa_contents-line = ''.
APPEND wa_contents TO it_contents.
wa_contents-line = text-025. "'<h2><U>Note:<U><h2/>'.
APPEND wa_contents TO it_contents.
wa_contents-line = text-026.
APPEND wa_contents TO it_contents.
wa_contents-line = text-027.
APPEND wa_contents TO it_contents.
wa_contents-line = text-028.
APPEND wa_contents TO it_contents.
wa_contents-line = text-029.
APPEND wa_contents TO it_contents.
wa_contents-line = text-030.
APPEND wa_contents TO it_contents.
wa_contents-line = text-031.
APPEND wa_contents TO it_contents.
wa_contents-line = text-011.
APPEND wa_contents TO it_contents.
wa_contents-line = ''.
APPEND wa_contents TO it_contents.
wa_contents-line = text-012.
APPEND wa_contents TO it_contents.
wa_contents-line = text-013.
APPEND wa_contents TO it_contents.
wa_contents-line = text-014.
APPEND wa_contents TO it_contents.
wa_contents-line = text-015.
APPEND wa_contents TO it_contents.
wa_contents-line = text-016.
APPEND wa_contents TO it_contents.
wa_contents-line = text-017.
APPEND wa_contents TO it_contents.
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = it_contents "main_text
i_subject = text-022 ). "#EC NOTEXT
document->add_attachment(
i_attachment_type = 'xls' "#EC NOTEXT
i_attachment_subject = 'HSN-SpreadSheet' "#EC NOTEXT
i_attachment_size = size
i_att_content_hex = binary_content ).
send_request->set_document( document ).
IF mailto IS NOT INITIAL .
recipient = cl_cam_address_bcs=>create_internet_address( mailto ).
ELSE.
MESSAGE text-023 TYPE 'I'.
EXIT.
ENDIF.
send_request->add_recipient( recipient ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
IF sent_to_all IS INITIAL.
MESSAGE i500(sbcoms) WITH mailto.
ELSE.
MESSAGE s022(so).
ENDIF.
CATCH cx_bcs INTO bcs_exception.
MESSAGE i865(so) WITH bcs_exception->error_type.
ENDTRY.
ENDFORM. "send
FORM create_content.
DATA lv_string TYPE string.
CLEAR : lv_string.
* REFRESH : lv_string.
CONCATENATE ' E~ESOKZ = ' ' 0 ' opr ' A~URZTP = ' ' 1 ' opr ' C~SOBSL = ' ''' ''' INTO whr_clause .
SELECT
a~matnr
m~maktx
a~lifnr
l~name1
l~adrnr
INTO CORRESPONDING FIELDS OF TABLE itvend
FROM eina AS a INNER JOIN eine AS e ON a~infnr = e~infnr AND e~loekz <> 'X'
INNER JOIN eord AS b ON a~matnr = b~matnr AND a~lifnr = b~lifnr
INNER JOIN lfa1 AS l ON l~lifnr = a~lifnr
INNER JOIN makt AS m ON m~matnr = a~matnr
INNER JOIN marc AS c ON c~matnr = a~matnr
WHERE (whr_clause) AND c~ekgrp IN ekgrp
AND c~lgpro IN lgpro AND m~matnr = a~matnr AND c~matnr = a~matnr AND a~urztp <> 2 AND e~werks = 'LEP1' AND l~lifnr IN vend1. "AND e~loekz <> 'X'.
SORT itvend BY lifnr.
DELETE itvend WHERE lifnr <> p_lifnr.
READ TABLE itvend INTO wa_apvend1 INDEX 1.
* SELECT SINGLE smtp_addr FROM adr6 INTO CORRESPONDING FIELDS OF wa_adr6 WHERE addrnumber = wa_apvend1-adrnr.
* mailto = wa_adr6-smtp_addr.
SELECT SINGLE verkf lifnr FROM lfm1 INTO CORRESPONDING FIELDS OF wa_lfm1 WHERE lifnr = p_lifnr.
CONCATENATE 'SUPPLIER HSN CODE MASTER' "#EC NOTEXT
gc_crlf gc_crlf
INTO lv_string.
CONCATENATE lv_string
text-018 gc_tab
wa_apvend1-name1 gc_crlf
INTO lv_string.
CONCATENATE lv_string
text-019 gc_tab
p_lifnr gc_crlf
INTO lv_string.
CONCATENATE lv_string
text-020 gc_tab
gc_crlf gc_crlf
INTO lv_string.
CONCATENATE lv_string
text-021 gc_tab
gc_crlf gc_crlf
INTO lv_string.
* header line
CONCATENATE lv_string
'LECS Material Code' gc_tab "#EC NOTEXT
'Material Description' gc_tab "#EC NOTEXT
'Supplier Description of goods' gc_tab "#EC NOTEXT
'HSN Code Of Goods (SAC)' gc_tab "#EC NOTEXT
'Material Group' gc_crlf "#EC NOTEXT
INTO lv_string.
**********************************************************************
SORT itvend BY matnr.
DELETE ADJACENT DUPLICATES FROM itvend COMPARING matnr.
**********************************************************************
LOOP AT itvend INTO wa_apvend.
CONCATENATE lv_string
wa_apvend-matnr gc_tab
wa_apvend-maktx gc_crlf
INTO lv_string.
ENDLOOP.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = lv_string
iv_codepage = '4103'
iv_add_bom = 'X'
IMPORTING
et_solix = binary_content
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
ENDFORM. "create_content
regards,
umayaraja