After sending attachment through mail using ABAP program.....
Hello Experts,
I am facing a problem to fulfill a requirement.
My requirement is....sending the data of the internal table to an external mail with attachment(excel format). I have done with this. But when o am opening the excel sheet(attachment) it is showing a message that 'The file you are trying to open is in different format than specified by the file extension'
I am using the extension 'XLS' and 'RAW ' in the coding for the file formats.
You can please suggest your solutions if you know or already faced this type of issues.
Thank you.
Regards,
Anand
Hi,
The system does not trust you....
I have the feeling that the file you are sending is a text file with the extension 'XLS'
If the file is comma separated values (http://en.wikipedia.org/wiki/Comma-separated_values) then
use the extension 'CSV' if it is a tab separated then use the extension 'TXT' .
Regards.
CSV is also good for tab separated I just checked by a copy of BCS_EXAMPLE_7 and changing:
i_attachment_type = 'CSV' "#EC NOTEXT
Similar Messages
-
Hello Gurus,
Please help me with the mail sending attachment(excel file) using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
Here is the actual problem.
I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in my prog.
My attachment(excel sheet which is taken from internal table) contains the 10 records with one header description and data related to that description.
I am able to send the attachment but the records in the attachment has more than 255 characters nearly 700 character length.
So I spilt up each internal table record(with structure type solisti1) into 3 internal table records and populated it.
It is showing the entire record in the attached file but I am not able to see some fields which are embeded deeply inside the cells.
And they are not having any proper allignment.
Please do help me.
Promise to reward points.
MacHere is the sample code....
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Creating the document to be sent
DOC_CHNG-OBJ_NAME = 'OFFER'.
DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
OBJTXT = 'Reserve price : $250000'.
APPEND OBJTXT.
OBJTXT = 'A reproduction of the painting to be auctioned'.
APPEND OBJTXT.
OBJTXT = 'is enclosed as an attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creating the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
OBJBIN = ' \O/ '. APPEND OBJBIN.
OBJBIN = ' '. APPEND OBJBIN.
OBJBIN = ' / \ '. APPEND OBJBIN.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
Creating the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'BMP'.
OBJPACK-OBJ_NAME = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK..
Entering names in the distribution list
RECLIST-RECEIVER = '<name>@yahoo.com'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = 'DLI-NEUREICH'.
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT RECLIST.
WRITE: / RECLIST-RECEIVER(48), ':'.
IF RECLIST-RETRN_CODE = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE:
/ 'no authorization to send to the specified number recipients!'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipient'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.
Regards,
Pavan. -
How to send pdf attachment through mail using Webdynpro-Java
How can i send the Adobe Interactive Form with data involved as a PDF attachment to mail? using Webdynpro-Java.
Is there any Adobe API or jar file for generating pdf?
Helpful answer is highly appreciable and rewarded with points.!Hi Sankar,
try [Offline Interactive PDF Form Using E-Mail|/docs/DOC-8061#49]
Michal -
How to stop the sending attachment through mail group policy
HI ,.,,,
Our employees using the gmail and yahoo accounts sometimes . Due to security issues they dont send attachements how is possible to deny sending attachments in group policy
rankiHi,
How do your employees using their personal mailbox? If they access it via Outlook, please refer to the suggestions Maffiow provided. If they access it via IE, we could not prevent them attaching
file to their mailbox via Group Policy. As a workaround, you may prevent them accessing the third party mailbox webpage via Group Policy.
For details, please refer to the following article.
How to use Group Policy to Allow or Block URL’s
http://www.grouppolicy.biz/2010/07/how-to-use-group-policy-to-allow-or-block-urls/
Hope this helps.
Best Regards,
Andy Qi
TechNet Subscriber Support
If you are
TechNet Subscription user and have any feedback on our support quality, please send your feedback
here.
Andy Qi
TechNet Community Support -
Hi all,
see below it.
TABLES: ZST2.
DATA : BEGIN OF ITAB OCCURS 0,
EMPNO LIKE ZST2-EMPNO,
EMPNAME LIKE ZST2-EMPNAME,
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 EMPNO EMPNAME "PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ZST2."WHERE PERNR < 50.
LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-EMPNO, 15 SY-VLINE , ITAB-EMPNAME.
*SY-VLINE.
ENDLOOP.
Receivers
receiver_list-recextnam = 'ur@company'. "-->
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.
how prepared it?
thx,
s.sureshhi,
chek this,,
TABLES :VARID. "Variant directory
DATA: GV_NAMES LIKE TSP01-RQ2NAME,
GD_BYTECOUNT LIKE TST01-DSIZE,
GD_BUFFER TYPE STRING,
PDF_LINES TYPE TLINE OCCURS 0 WITH HEADER LINE,
SEND_REQUEST TYPE REF TO CL_BCS,
L_SUBJECT LIKE SOOD-OBJDES,
DOCUMENT TYPE REF TO CL_DOCUMENT_BCS,
BCS_EXCEPTION TYPE REF TO CX_BCS,
V_CTR TYPE I VALUE 0,
IT_INPUT LIKE BDI_LINE OCCURS 0 WITH HEADER LINE,
IT_MESS_ATT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_BINARY_CONT TYPE SOLIX_TAB,
LEN_OUT TYPE I,
T_SPONO LIKE TSP01SYS OCCURS 0 WITH HEADER LINE.
DATA :GV_RQCRETIME LIKE TSP01-RQCRETIME.
DATA IT_VALUE LIKE RSPARAMS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF T_VARID OCCURS 0,
VARIANT LIKE VARID-VARIANT,
END OF T_VARID.
SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: S_VAR FOR VARID-VARIANT.
SELECTION-SCREEN END OF BLOCK B1.
Select the varinat name from the table VARID
SELECT VARIANT INTO TABLE T_VARID
FROM VARID
WHERE REPORT EQ 'ZAMRP003'
AND VARIANT IN S_VAR.
SORT T_VARID.
CHECK NOT T_VARID[] IS INITIAL.
LOOP AT T_VARID.
SUBMIT ZAMRP003 USING SELECTION-SET T_VARID-VARIANT
TO SAP-SPOOL SAP COVER PAGE ' '
DESTINATION ' '
IMMEDIATELY 'X'
KEEP IN SPOOL 'X'
LINE-COUNT 60000
LINE-SIZE 134
LAYOUT 'X_58_170'
WITHOUT SPOOL DYNPRO AND RETURN.
COMMIT WORK AND WAIT.
CONCATENATE SY-DATUM '000000' INTO GV_RQCRETIME.
CONCATENATE 'ZAMRP003_' SY-UNAME+0(3) INTO GV_NAMES.
SELECT * FROM TSP01 INTO TABLE T_SPONO
WHERE RQCLIENT = SY-MANDT
AND RQ0NAME = 'LIST1S'
AND RQ2NAME = GV_NAMES
AND RQOWNER = SY-UNAME
AND RQCRETIME GE GV_RQCRETIME.
SORT T_SPONO BY RQIDENT DESCENDING.
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
REPORT = 'ZAMRP003'
VARIANT = T_VARID-VARIANT
TABLES
VALUTAB = IT_VALUE
EXCEPTIONS
VARIANT_NON_EXISTENT = 1
VARIANT_OBSOLETE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE E000(ZH) WITH 'Error in processing variant'.
ENDIF.
Create the email request
PERFORM CREATE_EMAIL .
SORT T_SPONO BY RQIDENT DESCENDING.
READ TABLE T_SPONO INDEX 1.
IF SY-SUBRC NE 0.
MESSAGE E000(ZH) WITH 'Error creating spool'
RAISING CONVERSION_ERROR.
ENDIF.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = T_SPONO-RQIDENT
NO_DIALOG = ' '
IMPORTING
PDF_BYTECOUNT = GD_BYTECOUNT
TABLES
PDF = PDF_LINES
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
IF SY-SUBRC <> 0.
MESSAGE E000(ZH) WITH 'Error converting spool to PDF'
RAISING CONVERSION_ERROR.
ENDIF.
Transfer the 132-long strings to 255-long strings
LOOP AT PDF_LINES.
TRANSLATE PDF_LINES USING ' ~'.
CONCATENATE GD_BUFFER PDF_LINES INTO GD_BUFFER.
ENDLOOP.
TRANSLATE GD_BUFFER USING '~ '.
DO.
IT_MESS_ATT = GD_BUFFER.
APPEND IT_MESS_ATT.
SHIFT GD_BUFFER LEFT BY 255 PLACES.
IF GD_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Convert format of PDF data to that required for email
REFRESH IT_BINARY_CONT.
PERFORM CONVERT_134_TO_255_STR TABLES IT_MESS_ATT
IT_BINARY_CONT.
Now add it as an attachment
CONCATENATE 'ZAMRP003' '.pdf' INTO L_SUBJECT.
TRY.
CALL METHOD DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = 'PDF'
I_ATTACHMENT_SUBJECT = L_SUBJECT
I_ATT_CONTENT_HEX = IT_BINARY_CONT.
Add document to send request
CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
CATCH CX_BCS INTO BCS_EXCEPTION.
Send the message that occurred and then exit
MESSAGE ID BCS_EXCEPTION->MSGID
TYPE BCS_EXCEPTION->MSGTY
NUMBER BCS_EXCEPTION->MSGNO
WITH BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
EXIT.
ENDTRY.
Send the email now
PERFORM SEND_THE_EMAIL CHANGING SEND_REQUEST.
COMMIT WORK.
ENDLOOP.
*& Form convert_134_to_255_str
text
FORM CONVERT_134_TO_255_STR TABLES PT_134
PT_255.
DATA: L_DSN(100).
L_DSN = 'c:\temp\text_workarea.txt'.
Output file in 134 byte blocks
OPEN DATASET L_DSN FOR OUTPUT IN BINARY MODE.
IF SY-SUBRC NE 0.
WRITE :/ 'Error in PDF Conversion'.
STOP.
ENDIF.
LOOP AT PT_134.
TRANSFER PT_134 TO L_DSN.
ENDLOOP.
CLOSE DATASET L_DSN.
Read file in 255 byte blocks
OPEN DATASET L_DSN FOR INPUT IN BINARY MODE.
IF SY-SUBRC NE 0.
WRITE :/ 'Error in PDF Conversion'.
STOP.
ENDIF.
READ DATASET L_DSN INTO PT_255.
WHILE SY-SUBRC = 0.
APPEND PT_255.
READ DATASET L_DSN INTO PT_255.
ENDWHILE.
APPEND PT_255.
CLOSE DATASET L_DSN.
Clear file
OPEN DATASET L_DSN FOR OUTPUT IN BINARY MODE.
CLOSE DATASET L_DSN.
ENDFORM. " convert_134_to_255_str
*& Form send_the_email
text
FORM SEND_THE_EMAIL CHANGING P_SEND_REQUEST TYPE REF TO CL_BCS.
DATA: L_RECIPIENT TYPE REF TO IF_RECIPIENT_BCS,
L_SENT_TO_ALL TYPE OS_BOOLEAN,
LT_RECIP_ERROR TYPE BCSY_RE,
LT_ORIG_ERROR TYPE BCSY_ERCP,
LV_STR TYPE SZA5_D0700-SMTP_ADDR.
TRY.
Add recipients (e-mail address) ----------------------
LOOP AT IT_VALUE WHERE SELNAME = 'S_USER'.
Create recipient
LV_STR = IT_VALUE-LOW.
L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
LV_STR ).
Add recipient with its respective attributes to send request
SEND_REQUEST->ADD_RECIPIENT( L_RECIPIENT ).
ENDLOOP.
Send document ---------------------------------------
CALL METHOD SEND_REQUEST->SEND_WITHOUT_DIALOG(
IMPORTING
E_RECIPIENTS_WITH_ERROR = LT_RECIP_ERROR
E_ORIG_RECS_WITH_ERROR = LT_ORIG_ERROR
E_SENT_TO_ALL = L_SENT_TO_ALL ).
For internet addresses, this should always be OK. It is only later
that an express message is sent if it fails. Hence no need to do
much error processing here.
IF L_SENT_TO_ALL = 'X'.
MESSAGE I217(ZH). "Sent to all recipients.
ENDIF.
CATCH CX_BCS INTO BCS_EXCEPTION.
Send the message that occurred and then exit
MESSAGE ID BCS_EXCEPTION->MSGID
TYPE BCS_EXCEPTION->MSGTY
NUMBER BCS_EXCEPTION->MSGNO
WITH BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
EXIT.
ENDTRY.
ENDFORM. " send_the_email
*& Form create_email
FORM CREATE_EMAIL.
DATA: SUB TYPE SO_OBJ_DES,
WA_TEXT TYPE SOLI,
LT_TEXT TYPE SOLI_TAB.
TRY.
-------- create persistent send request ------------------------
SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
SEND_REQUEST->SET_STATUS_ATTRIBUTES( 'E' ).
SEND_REQUEST->SEND_REQUEST->SET_LINK_TO_OUTBOX( 'X' ).
-------- create and set document with attachment ---------------
WA_TEXT = 'Dear Recipient,'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
wa_text = 'We apologise for the inaccurate Fixed Asset '.
APPEND wa_text TO lt_text.
wa_text = 'Reports sent to you and any inconvenience caused by'.
APPEND wa_text TO lt_text.
wa_text = 'this error.'.
APPEND wa_text TO lt_text.
wa_text = ' '.
APPEND wa_text TO lt_text.
wa_text = 'The changing of the report from a manual to '.
APPEND wa_text TO lt_text.
wa_text = 'automatic process could not be fully tested in a test'
APPEND wa_text TO lt_text.
wa_text = ' environment and this has led to the problems that'.
APPEND wa_text TO lt_text.
wa_text = ' you have seen. We have now corrected these errors '.
APPEND wa_text TO lt_text.
wa_text = 'and the automated process will continue from now on'.
APPEND wa_text TO lt_text.
wa_text = ''.
APPEND wa_text TO lt_text.
wa_text = 'Thank you for your patience during this time.'.
APPEND wa_text TO lt_text.
wa_text = ''.
APPEND wa_text TO lt_text.
wa_text = ''.
APPEND wa_text TO lt_text.
WA_TEXT = 'This is the monthly fixed asset report for your'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'cost centre(s) which shows assets'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'for the previous calendar month.'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'N.B. The asset locations shown on this report'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'may be long out-of-date and are offered for'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'guidance only.'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'Please note that it is your responsibility to'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'know: Where each asset is; What it is; and Why'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'it is needed?'.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = ' '.
APPEND WA_TEXT TO LT_TEXT.
WA_TEXT = 'For any queries regarding the email or report'.
APPEND WA_TEXT TO LT_TEXT.
*-- Start of changes by SPUSA (001)
wa_text = 'please contact abc@com'.
WA_TEXT = 'please contact abc@com'.com'.
*-- End of changes by SPUSA (001)
APPEND WA_TEXT TO LT_TEXT.
SUB = 'Asset Management'.
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW'
I_TEXT = LT_TEXT
I_LENGTH = '24'
I_SUBJECT = SUB ).
CATCH CX_BCS INTO BCS_EXCEPTION.
Send the message that occurred and then exit
MESSAGE ID BCS_EXCEPTION->MSGID
TYPE BCS_EXCEPTION->MSGTY
NUMBER BCS_EXCEPTION->MSGNO
WITH BCS_EXCEPTION->MSGV1 BCS_EXCEPTION->MSGV2
BCS_EXCEPTION->MSGV3 BCS_EXCEPTION->MSGV4.
EXIT.
ENDTRY.
ENDFORM. " create_email
reward if helpful,
N.Rekha -
Convert ALV or layout in HTML or xls and send attachment through mail
Dear Expert,
Actually i have a ALV program and layout.
Now i want to open these program in HTML and XLS both the option, according to Radio Button selection for Html or XLS.
Then send this output to concern person via email as an attachment.
Plz. Help me as soon as posible
ByeHi Shalini,
based on your radio button call fm:
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = lv_document_data
put_in_outbox = space
commit_work = 'X'
tables
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_audit_output
contents_txt = i_objtxt
receivers = i_reclist
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Display message saying email was sent successfully.
else.
write: /1 text-t23.
endif. -
Hello Experts,
I want to send mail via ABAP program with the following requirements :
1. Recipient is OUTLOOK email -id
2. Sender address has to be an external email-id
3. Send mail as CC and BCC also to other email-id.
Is there any function module which can satisfy all the above requirements.
Regards,
Mansi.hi,
this code will definately help you just go through it:
firstly exported the data to memory using the FM LIST_FROM_MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE e000(su) WITH text-001.
ENDIF.
then i converted it into ASCII using LIST_TO_ASCI,
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_xlstab
listobject = t_listobject
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE e003(yuksdbfzs).
ENDIF.
This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
cl_abap_char_utilities=>horizontal_tab.
Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
This will create an excel attachment.
Sample code for formatting the data for the attachment in excel format.
u2022 Format the data for excel file download
LOOP AT t_xlstab INTO wa_xlstab .
DESCRIBE TABLE t_xlstab LINES lw_cnt.
CLEAR lw_sytabix.
lw_sytabix = sy-tabix.
u2022 If not new line then replace '|' by tabs
IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
WITH cl_abap_char_utilities=>horizontal_tab.
MODIFY t_xlstab FROM wa_xlstab .
CLEAR wa_xlstab.
wa_xlstab = cl_abap_char_utilities=>newline.
IF lw_cnt NE 0 .
lw_sytabix = lw_sytabix + 1.
u2022 Insert new line for the excel data
INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
lw_cnt = lw_cnt - 1.
ENDIF.
CLEAR wa_xlstab.
ENDIF.
ENDLOOP.
Sample code for creating attachment and sending mail:
FORM send_mail .
u2022 Define the attachment format
lw_doc_type = 'XLS'.
u2022 Create the document which is to be sent
lwa_doc_chng-obj_name = 'List'.
lwa_doc_chng-obj_descr = w_subject. "Subject
lwa_doc_chng-obj_langu = sy-langu.
u2022 Fill the document data and get size of message
LOOP AT t_message.
lt_objtxt = t_message-line.
APPEND lt_objtxt.
ENDLOOP.
DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
IF lw_tab_lines GT 0.
READ TABLE lt_objtxt INDEX lw_tab_lines.
lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
lwa_doc_chng-obj_langu = sy-langu.
lwa_doc_chng-sensitivty = 'F'.
ELSE.
lwa_doc_chng-doc_size = 0.
ENDIF.
u2022 Fill Packing List For the body of e-mail
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = 'RAW'.
APPEND lt_packing_list.
u2022 Create the attachment (the list itself)
DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
u2022 Fill the fields of the packing_list for creating the attachment:
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = lw_doc_type.
lt_packing_list-obj_name = 'Attach'.
lt_packing_list-obj_descr = w_docdesc.
lt_packing_list-doc_size = lw_tab_lines * 255.
APPEND lt_packing_list.
u2022 Fill the mail recipient list
lt_reclist-rec_type = 'U'.
LOOP AT t_recipient_list.
lt_reclist-receiver = t_recipient_list-address.
APPEND lt_reclist.
ENDLOOP.
u2022 Finally send E-Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = lw_sent_to_all
TABLES
packing_list = lt_packing_list
object_header = lt_objhead
contents_bin = t_xlstab
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Hope it will help you
regards
Rahul sharma -
Sending SAP Script output as a PDF attachment through mail
Dear Guru,
I am using SAP 4.0B version, DATABASE Oracle 8i, OS is sun solaris 7.5.
I want to send SAP script output as a
PDF attachement through mail.Please suggest a solution.
Regards,
RajeshHi Rajesh,
In your print program, while calling OPEN_FORM, pass options-TDGETOTF = 'X'. This is used for returning print output in OTF format.
Then in CLOSE_FORM, get the table OTFDATA returned from the function module. for example
DATA: OTF_DATA LIKE ITCOO OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = RESULT
TABLES
OTFDATA = OTF_DATA.
now you can convert this OTF data to PDF using function module CONVERT_OTF
Then send this data as attachment to a mail using function module SO_NEW_DOCUMENT_ATT_SEND_API1
Regards,
Komal. -
Sending log files for scheduled jobs as attachment through mail
Hi All,
Can any one please help me out to write a pl/sql program to send log files for scheduled jobs as attachment through mail.
Thanks.Why would anyone do that as this code has already been posted here a thousand times, it is all over the Internet, and the only thing you need to do is to search for it?
I agree it would cost you some effort, but you are getting paid for it, and we are not getting paid for delivering it on a golden plate on your doorstep, as you can not be bothered to use online resources.
Sybrand Bakker
Senior Oracle DBA -
How to send mail using jsp program
am very new to jsp and doing my final year project. i need to send mails using my jsp program.can anyone say wht to do that is wht to include to send mails using jsp program. n also a sample code to send mail using jsp program.
Thanx in advanceUse below script.
<%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "mailserver.com");
Session s = Session.getInstance(props,null);
InternetAddress from = new InternetAddress("[email protected]");
InternetAddress to = new InternetAddress([email protected]");
MimeMessage message = new MimeMessage(s);
message.setFrom(from);
message.addRecipient(Message.RecipientType.TO, to);
message.setSubject("Your subject");
message.setText("Your text");
Transport.send(message);
%>{code} -
TS3276 Trouble Sending Email Through Mail
I'm havng trouble sending email through Mail on MacBook Pro. I'm using Lion and everything is up to date. I receive email just fine, but when I go to reply the little wheel thingy just spins and spins, and eventually my emails get sent to the Out box and are never sent. It's an AT&T email account that I'm using. If I go through Yahoo, I can send the emails just fine, but I'd much rather use Mail. Any ideas on what to do? This just started.
Debby JYou have a setting wrong OR. I also use ATT/Yahoo mail for some of my email accounts and earlier this morning the ATT/Yahoo email system was down.
If that is not the problem, ATT/Yahoo system down, then it is simply you do not have the SMTP settings correct.
The server address is smtp.att.yahoo.com and you must have your complete email address, [email protected]/net where attdomian is bellsouth/att/southwest(not sure if that is one of them)/whatever DOT com or net for your domain. It has to included what comes after the @ sign. Some email programs strip what comes after the @ sign out of your logon info. And of course you must have the correct password entered. -
Hi Experts,
Please tell me how to send an e-mail using a ABAP program.
i have one variable having a calculated value and i need to send this value using the same program as E-mails.Here is a fairly generic procedure to do that. You'll need to supply p_addr as the email of the recipient.
* FORM send_email_message
* Routine to mail report to person
FORM send_email_message
TABLES
p_t_message TYPE STANDARD TABLE.
DATA:
l_t_packing_list TYPE TABLE OF sopcklsti1,
l_t_receivers TYPE TABLE OF somlreci1,
l_s_packing_list TYPE sopcklsti1,
l_s_receivers TYPE somlreci1,
l_doc_data TYPE sodocchgi1,
l_sent_all(1) TYPE c,
l_subject_cnt TYPE i,
l_subject TYPE string,
l_email_addr TYPE bapiadsmtp-e_mail.
FIELD-SYMBOLS: <selopts> TYPE ANY.
FIELD-SYMBOLS: <selopts_oncall> TYPE ANY.
DESCRIBE TABLE p_t_message LINES l_subject_cnt.
l_subject = l_subject_cnt.
CONCATENATE l_subject text-004 sy-sysid INTO l_subject SEPARATED BY space.
CONDENSE l_subject.
* Fill the document data.
l_doc_data-doc_size = 1.
l_doc_data-obj_langu = sy-langu.
l_doc_data-obj_name = 'SAPRPT'.
l_doc_data-obj_descr = l_subject.
l_doc_data-sensitivty = 'F'.
* Describe the body of the message
l_s_packing_list-transf_bin = space.
l_s_packing_list-head_start = 1.
l_s_packing_list-head_num = 0.
l_s_packing_list-body_start = 1.
DESCRIBE TABLE p_t_message LINES l_s_packing_list-body_num.
l_s_packing_list-doc_type = 'RAW'.
APPEND l_s_packing_list TO l_t_packing_list.
* For each on-call schedule in the selection screen, get the person
* on call and add them to the receiver list.
l_s_receivers-receiver = p_addr.
l_s_receivers-rec_type = 'U'.
l_s_receivers-com_type = 'INT'.
l_s_receivers-notif_del = ' '.
l_s_receivers-notif_ndel = ' '.
APPEND l_s_receivers TO l_t_receivers.
* Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = l_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = l_sent_all
TABLES
packing_list = l_t_packing_list
contents_txt = p_t_message
receivers = l_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
OR l_sent_all <> 'X'.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM flush_mail_queue.
ENDFORM."
* Flush mail queue
FORM flush_mail_queue.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
ENDFORM." -
Unable to send photo through email using iphoto theme (designs)
Unable to send photo through email using iPhoto theme (designs) using the SHARE button.
Error message:
Your email did not go through because the server did not reply.
Check your Internet connection.
If the connection is working properly, the email server may be down.
Try sending your email again later.Your email did not go through because the server did not reply.
Check your Internet connection.
If the connection is working properly, the email server may be down.
Try sending your email again later.
Are you using Yosemite and not apple's Mail app? Then you may need to set up an app-specific password: See the post below:
Re: I am using iPhoto version 9.6 and I can no longer get an email sent with a photo attached. I get an error message saying the email did not go through because the server did not reply. I can send the photo with Mail. Help!in response to Gary Kissler
This solution is for those of you using 2-step verification for your Apple ID and are using iCloud as the mail server that you are trying to mail photos with.
I too had this issue. The problem in my case occurred because I had setup 2-step authentication for my Apple ID. If you have done this then you will get the error message "the mail server did not recognize your email/password...". To solve the problem go to:
https://appleid.apple.com
Click "Manage Your Apple ID"
Verify your identity with the device you selected (if this step does not show up then you have not likely set up 2-step authentication and this is not your solution)
Click Password and Security in the left column
Click Generate an app-specific password
Enter iPhoto as the name of the app
Copy the password and paste this into the password box in iPhoto where you would normally enter your apple ID (in the mail account section in iPhoto preferences).
And...voila' (I hope) -
Is it possible to reset password for any user using abap program
Hi friends,
Is it possible to reset password for any user using abap program by specifying client number and user id. in selection screen.
if any code for that to reset password please mail me.
Thanks & Regards,
YogeshHello Yogesh,
Yes you can reset the password for any body using ABAP Code. But for that you really don't need any client number.
If this process is on regular basis, then recommended is to use BAPI for changing the user details Otherwise BDC also works fine.
=> Function Module - BAPI_USER_CHANGE
Call this in the program for resetting the password.
=> CALL TRANSACTION 'SU01' USING InternalTable
This will be executed in the BDC of SU01 transaction recording. Use the Password Change button in the application toolbar of transaction while recording.
Hope this helps.
PS If the answer solves your query, plz close the thread by marking it solved and rewarding each reply.
Regards -
Fork in process chain using ABAP program
Hello everyone.
I need a fork in my chain. Depending on the values in some db table I will make a decision: do some process or skip and go further. The only solution I can see is using ABAP program. But unfortunately It doesn't return status. Any suggestion will be appreciated.Hi,
You have few process to run after the abap program. So make all those process as a different chain, and at the end of the ABAP program include a function module to trigger this chain, based on your condition.
If you like this idea, please revert for more information.
Hope this helps.
Thank you,
Maybe you are looking for
-
Error to transport request when activate the Data Source: 2LIS_13_VDKON
Hi people, When I try to transport the request about my activation from Standard DataSource 2LIS_13_VDKON, the systen (in ECC6) show me a error: " 8: Transport carried out with errors. Individual objects could not be transported successfully" I alrea
-
Ipod Nano not showing in my computer or iTunes - have done everything?
I am running Windows XP Home Edition on a Dell Inspiron 8500. I have done and checked everything including running Windows Installer Cleanup Utility and reinstalling iTunes 8; resetting ipod which works fine; checking IEEE 1394 card. One thing that d
-
How to view movies in full screen?
i have a video i want to see in full screen that i made in imovie.. unfortunately when i view it in full screen.. the movie doesnt fit the screen... there are black borders around the clip. so how do i view the video in full screen?
-
Is it possible to have different fields go to different pages?
I have 6 fields that will serve to search records a button either hidden or not will then be called to branch to that page only if there are more than 1 records. Otherwise it will display the results on the same page, populating those fields that mat
-
The administrator doesn't work for my computer
I've never changed any information on my computer, but for whatever reason, my administrator password doesn't work - therefore, I cannot update anything! I've changed the password using the install disc, but it still didn't work. I have no idea what