2006 Nov 21 9:35 AM
Hi Anversha ,
Yesterday u have send me a mail regarding sending mail as attachement (PDF) .
I have few queries like are there any additional connnections required to send a mail to receipient .
I have done the coding for sending the mail but I dont understand what the problem is.
Can u please go thru code and guide me..My file to be attached is in C:\Incometax\MNR.PDF filepath .
PERFORM send_form_via_email.
form send_form_via_email .
Refresh OBJTXT. clear OBJTXT.
Refresh OBJPACK. clear OBJPACK.
Refresh objbin. clear objbin.
Refresh OBJHEAD. clear OBJHEAD.
Refresh RECLIST. Clear RECLIST.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'Incometax'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Incometax'.
Mail Contents
OBJTXT = 'This e-mail was sent from an automated system...'.
APPEND OBJTXT.
OBJTXT = 'Do not reply to this message.'.
APPEND OBJTXT.
OBJTXT = 'Please open the attachment to view the Incometax report'.
APPEND OBJTXT.
OBJTXT = ''.
APPEND OBJTXT.
if not msgtxt1 is initial.
OBJTXT = msgtxt1.
APPEND OBJTXT.
endif.
*
if not msgtxt2 is initial.
OBJTXT = msgtxt2.
APPEND OBJTXT.
endif.
*
if not msgtxt3 is initial.
OBJTXT = msgtxt3.
APPEND OBJTXT.
endif.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of 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.
Creation of the document attachment
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = wi_mtab_pdf
t_target_tab = objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
describe table objbin lines tab_lines.
OBJHEAD = 'MNR.PDF' .
APPEND OBJHEAD.
Creation of 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 = 'PDF'.
OBJPACK-OBJ_NAME = 'Incometax'.
OBJPACK-OBJ_DESCR = 'Incometax'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
Read table i_pa0105 with key pernr = pernr-pernr binary search.
if sy-subrc = 0.
IF i_pa0105-USRTY = '0010'.
RECLIST-RECEIVER = '[email protected]' .
elseIF i_pa0105-USRTY = 'MAIL'.
RECLIST-RECEIVER = '[email protected]'.
endif.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ''
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.
LOOP AT RECLIST.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
IF RECLIST-RETRN_CODE = 0.
Concatenate error1 ': The document was sent' into error1.
i_errors-descr = pernr-pernr.
i_errors-type = 'S'.
append i_errors.
ELSE.
Concatenate error1 ': The document could not be sent' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDIF.
ENDLOOP.
WHEN 1.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': No authorization for sending to the recipients' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 2.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': Document could not be sent to the recipient' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 4.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': No send authorization' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN OTHERS.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': Error occurred while sending' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDCASE.
else.
error1 = pernr-pernr.
Concatenate error1 ': Maintain Infotype 0105.' into error1.
i_errors-descr = error1.
i_errors-type = 'M'.
append i_errors.
endif.
endform. " send_form_via_email
Thanks
Santosh P
Hi Anversha ,
Yesterday u have send me a mail regarding sending mail as attachement (PDF) .
I have few queries like are there any additional connnections required to send a mail to receipient .
I have done the coding for sending the mail but I dont understand what the problem is.
Can u please go thru code and guide me..My file to be attached is in C:\Incometax\MNR.PDF filepath .
PERFORM send_form_via_email.
form send_form_via_email .
Refresh OBJTXT. clear OBJTXT.
Refresh OBJPACK. clear OBJPACK.
Refresh objbin. clear objbin.
Refresh OBJHEAD. clear OBJHEAD.
Refresh RECLIST. Clear RECLIST.
Creation of the document to be sent
File Name
DOC_CHNG-OBJ_NAME = 'Incometax'.
Mail Subject
DOC_CHNG-OBJ_DESCR = 'Incometax'.
Mail Contents
OBJTXT = 'This e-mail was sent from an automated system...'.
APPEND OBJTXT.
OBJTXT = 'Do not reply to this message.'.
APPEND OBJTXT.
OBJTXT = 'Please open the attachment to view the Incometax report'.
APPEND OBJTXT.
OBJTXT = ''.
APPEND OBJTXT.
if not msgtxt1 is initial.
OBJTXT = msgtxt1.
APPEND OBJTXT.
endif.
*
if not msgtxt2 is initial.
OBJTXT = msgtxt2.
APPEND OBJTXT.
endif.
*
if not msgtxt3 is initial.
OBJTXT = msgtxt3.
APPEND OBJTXT.
endif.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of 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.
Creation of the document attachment
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = wi_mtab_pdf
t_target_tab = objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
describe table objbin lines tab_lines.
OBJHEAD = 'MNR.PDF' .
APPEND OBJHEAD.
Creation of 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 = 'PDF'.
OBJPACK-OBJ_NAME = 'Incometax'.
OBJPACK-OBJ_DESCR = 'Incometax'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
Read table i_pa0105 with key pernr = pernr-pernr binary search.
if sy-subrc = 0.
IF i_pa0105-USRTY = '0010'.
RECLIST-RECEIVER = '[email protected]' .
elseIF i_pa0105-USRTY = 'MAIL'.
RECLIST-RECEIVER = '[email protected]'.
endif.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = ''
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.
LOOP AT RECLIST.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
IF RECLIST-RETRN_CODE = 0.
Concatenate error1 ': The document was sent' into error1.
i_errors-descr = pernr-pernr.
i_errors-type = 'S'.
append i_errors.
ELSE.
Concatenate error1 ': The document could not be sent' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDIF.
ENDLOOP.
WHEN 1.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': No authorization for sending to the recipients' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 2.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': Document could not be sent to the recipient' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN 4.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': No send authorization' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
WHEN OTHERS.
Concatenate pernr-pernr '-' RECLIST-RECEIVER(48) into error1.
Concatenate error1 ': Error occurred while sending' into error1.
i_errors-descr = error1.
i_errors-type = 'E'.
append i_errors.
ENDCASE.
else.
error1 = pernr-pernr.
Concatenate error1 ': Maintain Infotype 0105.' into error1.
i_errors-descr = error1.
i_errors-type = 'M'.
append i_errors.
endif.
endform. " send_form_via_email
Thanks
Santosh P
2006 Nov 21 9:44 AM
hi,
pls check this sample code and compare.
REPORT Z895_DOCATTC.
data : wa_doc_data like SODOCCHGI1,
v_lin like Sy-tabix,
v_obj_id like SOFOLENTI1-OBJECT_ID.
data : wa_reciever like SOMLRECI1,
t_reciever like standard table of wa_reciever.
data : wa_pk_list like SOPCKLSTI1,
t_pk_list like standard table of wa_pk_list.
data : wa_con_txt like SOLISTI1,
t_TEMP like standard table of wa_con_txt,
t_con_txt like standard table of wa_con_txt.
wa_con_txt = 'hello'.
append wa_con_txt to t_con_txt.
append wa_con_txt to t_con_txt.
describe table t_con_txt lines v_lin.
read table t_con_txt index v_lin into wa_con_txt.
wa_doc_data-doc_size = ( v_lin - 1 ) * 255 + strlen( wa_con_txt ).
wa_doc_data-OBJ_NAME = 'ATC'.
wa_doc_data-OBJ_DESCR = 'to send an attachment'.
wa_doc_data-OBJ_LANGU = 'E'.
wa_reciever-RECEIVER = ''.
wa_reciever-REC_TYPE = 'B'.
wa_reciever-com_type = 'INT'.
append wa_reciever to t_reciever.
clear wa_pk_list-transf_bin.
wa_pk_list-head_start = 1.
wa_pk_list-head_num = 0.
wa_pk_list-BODY_START = 1.
wa_pk_list-body_num = v_lin.
wa_pk_list-doc_type = 'RAW'.
append wa_pk_list to t_pk_list.
*to upload a pdf file*
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:Documents and Settings'
FILETYPE = 'BIN'
TABLES
DATA_TAB = T_TEMP
.
DESCRIBE TABLE T_TEMP LINES V_LIN.
WA_PK_LIST-TRANSF_BIN = 'X'.
WA_PK_LIST-HEAD_NUM = 0.
WA_PK_LIST-BODY_START = 1.
WA_PK_LIST-BODY_NUM = V_LIN.
WA_PK_LIST-DOC_TYPE = 'PDF'.
WA_PK_LIST-OBJ_NAME = 'ATTACHMENT'.
WA_PK_LIST-OBJ_DESCR = 'Reproduction object 138'.
WA_PK_LIST-DOC_SIZE = V_LIN * 255.
APPEND WA_PK_LIST TO T_PK_LIST..
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = wa_doc_data
IMPORTING
NEW_OBJECT_ID = v_obj_id
TABLES
PACKING_LIST = t_pk_list
CONTENTS_BIN = T_TEMP
CONTENTS_TXT = t_con_txt
RECEIVERS = t_reciever
.Regards
Anver
2006 Nov 21 9:48 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |