<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Mail using ABAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648334#M878683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also follo this link for wiki.....&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/sending%2bemails%2band%2bsap%2bmails%2busing%2babap" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/sending%2bemails%2band%2bsap%2bmails%2busing%2babap&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; Report ZWBSAP_EMAIL * 
*&amp;amp; * 
&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; * 
*&amp;amp; * 
&amp;amp;--------------------------------------------------------------------- 
*Send an email via SAP Workplace 
*Select files from SAP server 


*Note: 

Uses custom table zlookup to pick up a group of email addresses to send to 
if more than one is needed. 

Please note some hard coding. 

REPORT zsap_email MESSAGE-ID z001. 

TABLES: rlgrap, btcxpm, zlookup. 

DATA: 
v_zcode(3) TYPE c, 
svrname LIKE zlookup-zdesc, 
wa_error(80) TYPE c, 
global_filemask_all(80). 


DATA: t_soud LIKE soud. 
DATA: p_infolder LIKE sofdk. 
DATA: p_outfolder LIKE sofdk. 
DATA: object_hd_display LIKE sood2. 
DATA: object_id LIKE soodk. 
DATA: document LIKE sood4. 
DATA: header_data LIKE sood2. 
DATA: link_folder_id LIKE soodk. 
DATA: folder_selections LIKE sofds. 

DATA: folder_list LIKE soxli OCCURS 0 WITH HEADER LINE. 
DATA: receivers LIKE soos1 OCCURS 0 WITH HEADER LINE. 
DATA: objcont LIKE soli OCCURS 0 WITH HEADER LINE. 
DATA: objhead LIKE soli OCCURS 0 WITH HEADER LINE. 
DATA: object_content LIKE solisti1 OCCURS 0 WITH HEADER LINE. 
DATA: object_hd_change LIKE sood1. 



DATA: BEGIN OF files OCCURS 0, 
line(200) TYPE c, 
END OF files. 
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE. 


*Email to addresses 
SELECTION-SCREEN: BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1. 
PARAMETERS: p_mailto(240) TYPE c. 
SELECTION-SCREEN SKIP 1. 
SELECTION-SCREEN COMMENT 10(2) text-001. 
*Use zlookup-ztype as group to define multiple email to addresses 
SELECT-OPTIONS: s_mailto FOR zlookup-ztype. 
SELECTION-SCREEN: END OF BLOCK bl1. 

*Subject 
SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-bl2. 
PARAMETERS: p_subj LIKE document-objdes. 
SELECTION-SCREEN: END OF BLOCK bl2. 

*Body 
SELECTION-SCREEN: BEGIN OF BLOCK bl3 WITH FRAME TITLE text-bl3. 
PARAMETERS: p_body1 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body2 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body3 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body4 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body5 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body6 LIKE solisti1-line LOWER CASE. 
SELECTION-SCREEN: END OF BLOCK bl3. 

*Attachments 
SELECTION-SCREEN: BEGIN OF BLOCK bl4 WITH FRAME TITLE text-bl4. 
PARAMETERS: p_fname1 LIKE files-line. 
PARAMETERS: p_fname2 LIKE files-line. 
PARAMETERS: p_fname3 LIKE files-line. 
PARAMETERS: p_fname4 LIKE files-line. 
PARAMETERS: p_fname5 LIKE files-line. 
PARAMETERS: p_fname6 LIKE files-line. 
SELECTION-SCREEN: END OF BLOCK bl4. 


AT SELECTION-SCREEN. 

PERFORM chk_selection. 
IF NOT wa_error IS INITIAL. 
MESSAGE e001 WITH wa_error. 
ENDIF. 


START-OF-SELECTION. 

END-OF-SELECTION. 

PERFORM send_email. 


--------------------------------------------------------------------- 


FORM chk_selection * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM chk_selection. 
CLEAR wa_error. 
*Loop only once ??? 
*If more checkings to be done. 
*Think about it and if not clear. 
*Let it sink in for a couple of minutes. 
*Still doesn't make sence? Go home and sleep on it. 
DO 1 TIMES. 
*Check Email to 
IF p_mailto IS INITIAL 
AND s_mailto IS INITIAL. 
wa_error = 'Invalid or no EMAIL TO selection'. 
EXIT. 
ENDIF. 
ENDDO. 
ENDFORM. 

&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; Form send_email 
&amp;amp;--------------------------------------------------------------------- 


text 
---------------------------------------------------------------------- 

--&amp;gt; p1 text 
&amp;lt;-- p2 text 
---------------------------------------------------------------------- 
FORM send_email. 
PERFORM get_folder_info. 
PERFORM fill_body. 
PERFORM ins_new_object. 
PERFORM crt_attachments. 
PERFORM fill_receivers_info. 
PERFORM snd_email. 
ENDFORM. " send_email 

--------------------------------------------------------------------- 


FORM Get_folder_info * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM get_folder_info. 
CLEAR t_soud. 
*Small so should be quick. 
SELECT * FROM soud 
INTO t_soud 
WHERE sapnam = sy-uname. 
p_infolder-foltp = 'FOL'. 
p_infolder-folyr = t_soud-inbyr. "inbox 
p_infolder-folno = t_soud-inbno. 
p_outfolder-foltp = 'FOL'. 
p_outfolder-folyr = t_soud-outyr. "outbox 
p_outfolder-folno = t_soud-outno. 
ENDSELECT. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM fill_body * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM fill_body. 
object_content-line = p_body1. 
APPEND object_content. 
object_content-line = p_body2. 
APPEND object_content. 
object_content-line = p_body3. 
APPEND object_content. 
object_content-line = p_body4. 
APPEND object_content. 
object_content-line = p_body5. 
APPEND object_content. 
object_content-line = p_body6. 
APPEND object_content. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM ins_new_object * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM ins_new_object. 
object_hd_change-objnam = 'Notes'. 
object_hd_change-objdes = p_subj. 

CALL FUNCTION 'SO_OBJECT_INSERT' 
EXPORTING 
folder_id = p_outfolder 
object_hd_change = object_hd_change 
object_type = 'RAW' 
owner = sy-uname 
IMPORTING 
object_hd_display = object_hd_display 
object_id = object_id 
TABLES 
objcont = object_content 
objhead = objhead 
EXCEPTIONS 
active_user_not_exist = 1 
communication_failure = 2 
component_not_available = 3 
dl_name_exist = 4 
folder_not_exist = 5 
folder_no_authorization = 6 
object_type_not_exist = 7 
operation_no_authorization = 8 
owner_not_exist = 9 
parameter_error = 10 
substitute_not_active = 11 
substitute_not_defined = 12 
system_failure = 13 
x_error = 14 
OTHERS = 15. 
IF sy-subrc 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM crt_attachments * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 

--&amp;gt; P_SUBJ * 
--------------------------------------------------------------------- 
FORM crt_attachments. 
document-foltp = p_outfolder-foltp. 
document-folyr = p_outfolder-folyr. 
document-folno = p_outfolder-folno. 
document-objtp = object_id-objtp. 
document-objyr = object_id-objyr. 
document-objno = object_id-objno. 
document-objnam = 'Notes'. 
document-objdes = p_subj. 
document-okcode = 'CHNG'. 
document-file_ext = 'TXT'. 
link_folder_id = object_id. 

header_data-objla = 'EN'. 
header_data-objnam = document-objnam. 
header_data-objdes = document-objdes. 
header_data-objpri = '5'. 
header_data-objsns = 'O'. 
header_data-file_ext = 'TXT'. 

REFRESH files. 
CLEAR files. 
IF NOT p_fname1 IS INITIAL. 
files-line = p_fname1. 
APPEND files. 
ENDIF. 
IF NOT p_fname2 IS INITIAL. 
files-line = p_fname2. 
APPEND files. 
ENDIF. 
IF NOT p_fname3 IS INITIAL. 
files-line = p_fname3. 
APPEND files. 
ENDIF. 
IF NOT p_fname4 IS INITIAL. 
files-line = p_fname4. 
APPEND files. 
ENDIF. 
IF NOT p_fname5 IS INITIAL. 
files-line = p_fname5. 
APPEND files. 
ENDIF. 
IF NOT p_fname6 IS INITIAL. 
files-line = p_fname6. 
APPEND files. 
ENDIF. 
IF NOT files[] IS INITIAL. 
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER' 
EXPORTING 
method = 'ATTCREATEFROMPC' 
TABLES 
files = files 
CHANGING 
document = document 
header_data = header_data. 

IF sy-subrc = 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDIF. 
ENDFORM. 


--------------------------------------------------------------------- 


FORM fill_receivers_info * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM fill_receivers_info. 
DATA: BEGIN OF reclist OCCURS 0, 
rec LIKE receivers-recextnam, 
END OF reclist. 

*Build reclist 
REFRESH reclist. 
IF NOT p_mailto IS INITIAL. 
reclist-rec = p_mailto. 
APPEND reclist. 
ENDIF. 

IF NOT s_mailto IS INITIAL. 
SELECT zdesc 
INTO reclist-rec 
FROM zlookup 
WHERE ztype IN s_mailto. 
APPEND reclist. 
ENDSELECT. 
ENDIF. 

REFRESH receivers. 
LOOP AT reclist. 

folder_selections-folnam = 'INBOX'. 
CALL FUNCTION 'SO_FOLDER_LIST_READ' 
EXPORTING 
folder_selections = folder_selections 
owner = sy-uname 
region = 'P' 
TABLES 
folder_list = folder_list 
EXCEPTIONS 
component_not_available = 1 
operation_no_authorization = 2 
owner_not_exist = 3 
parameter_error = 4 
x_error = 5 
OTHERS = 6. 
IF sy-subrc = 0. 
CLEAR receivers. 
receivers-rcdat = sy-datum. 
receivers-rctim = sy-uzeit. 
receivers-recnam = reclist-rec. 
receivers-recno = folder_list-parno. 
receivers-rectp = folder_list-partp. 
receivers-recyr = folder_list-paryr. 
receivers-sndtp = folder_list-partp. 
receivers-sndyr = folder_list-paryr. 
receivers-sndno = folder_list-parno. 
receivers-sndnam = sy-uname. 
receivers-sndpri = '1'. 
receivers-msgid = 'SO'. 
receivers-msgno = '619'. 
receivers-deliver = 'X'. 
receivers-not_deli = 'X'. 
receivers-read = 'X'. 
receivers-mailstatus = 'E'. 
*receivers-ADR_NAME 
receivers-resend = ' '. 
receivers-sortfield = ' '. "'USER WF_BATCH INDIGO BATCH'. 
receivers-sortclass = '5'. 
APPEND receivers. 
ELSE. 
CLEAR receivers. 
receivers-sel = 'X'. 
receivers-recesc = 'U'. 
receivers-recnam = 'U-'. 
receivers-recextnam = reclist-rec. 
receivers-deliver = 'X'. 
receivers-not_deli = 'X'. 
receivers-read = 'X'. 
receivers-mailstatus = 'E'. 
receivers-adr_name = reclist-rec. 
receivers-sortfield = reclist-rec. 
receivers-sortclass = '5'. 
APPEND receivers. 
ENDIF. 
ENDLOOP. 
ENDFORM. 

--------------------------------------------------------------------- 


FORM snd_email * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM snd_email. 
CALL FUNCTION 'SO_OBJECT_SEND' 
EXPORTING 
folder_id = p_outfolder 
object_id = object_id 
outbox_flag = 'X' 
owner = sy-uname 
check_send_authority = 'X' 
originator_type = 'J' 
link_folder_id = link_folder_id 
TABLES 
objcont = object_content 
receivers = receivers 
EXCEPTIONS 
active_user_not_exist = 1 
communication_failure = 2 
component_not_available = 3 
folder_not_exist = 4 
folder_no_authorization = 5 
forwarder_not_exist = 6 
note_not_exist = 7 
object_not_exist = 8 
object_not_sent = 9 
object_no_authorization = 10 
object_type_not_exist = 11 
operation_no_authorization = 12 
owner_not_exist = 13 
parameter_error = 14 
substitute_not_active = 15 
substitute_not_defined = 16 
system_failure = 17 
too_much_receivers = 18 
user_not_exist = 19 
originator_not_exist = 20 
x_error = 21 
OTHERS = 22. 

IF sy-subrc 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDFORM. 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope this helps, Do reward.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Runal Singh on Apr 3, 2008 12:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Apr 2008 07:09:09 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-03T07:09:09Z</dc:date>
    <item>
      <title>Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648332#M878681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is mail using ABAP?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reply me soon,&lt;/P&gt;&lt;P&gt;s.suresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:06:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648332#M878681</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648333#M878682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Refer to the link below:&lt;/P&gt;&lt;P&gt;&lt;A href="http://sapdev.co.uk/reporting/email/emailhome.htm" target="test_blank"&gt;http://sapdev.co.uk/reporting/email/emailhome.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sipra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:08:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648333#M878682</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648334#M878683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also follo this link for wiki.....&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/sending%2bemails%2band%2bsap%2bmails%2busing%2babap" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/sending%2bemails%2band%2bsap%2bmails%2busing%2babap&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; Report ZWBSAP_EMAIL * 
*&amp;amp; * 
&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; * 
*&amp;amp; * 
&amp;amp;--------------------------------------------------------------------- 
*Send an email via SAP Workplace 
*Select files from SAP server 


*Note: 

Uses custom table zlookup to pick up a group of email addresses to send to 
if more than one is needed. 

Please note some hard coding. 

REPORT zsap_email MESSAGE-ID z001. 

TABLES: rlgrap, btcxpm, zlookup. 

DATA: 
v_zcode(3) TYPE c, 
svrname LIKE zlookup-zdesc, 
wa_error(80) TYPE c, 
global_filemask_all(80). 


DATA: t_soud LIKE soud. 
DATA: p_infolder LIKE sofdk. 
DATA: p_outfolder LIKE sofdk. 
DATA: object_hd_display LIKE sood2. 
DATA: object_id LIKE soodk. 
DATA: document LIKE sood4. 
DATA: header_data LIKE sood2. 
DATA: link_folder_id LIKE soodk. 
DATA: folder_selections LIKE sofds. 

DATA: folder_list LIKE soxli OCCURS 0 WITH HEADER LINE. 
DATA: receivers LIKE soos1 OCCURS 0 WITH HEADER LINE. 
DATA: objcont LIKE soli OCCURS 0 WITH HEADER LINE. 
DATA: objhead LIKE soli OCCURS 0 WITH HEADER LINE. 
DATA: object_content LIKE solisti1 OCCURS 0 WITH HEADER LINE. 
DATA: object_hd_change LIKE sood1. 



DATA: BEGIN OF files OCCURS 0, 
line(200) TYPE c, 
END OF files. 
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE. 


*Email to addresses 
SELECTION-SCREEN: BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1. 
PARAMETERS: p_mailto(240) TYPE c. 
SELECTION-SCREEN SKIP 1. 
SELECTION-SCREEN COMMENT 10(2) text-001. 
*Use zlookup-ztype as group to define multiple email to addresses 
SELECT-OPTIONS: s_mailto FOR zlookup-ztype. 
SELECTION-SCREEN: END OF BLOCK bl1. 

*Subject 
SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-bl2. 
PARAMETERS: p_subj LIKE document-objdes. 
SELECTION-SCREEN: END OF BLOCK bl2. 

*Body 
SELECTION-SCREEN: BEGIN OF BLOCK bl3 WITH FRAME TITLE text-bl3. 
PARAMETERS: p_body1 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body2 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body3 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body4 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body5 LIKE solisti1-line LOWER CASE. 
PARAMETERS: p_body6 LIKE solisti1-line LOWER CASE. 
SELECTION-SCREEN: END OF BLOCK bl3. 

*Attachments 
SELECTION-SCREEN: BEGIN OF BLOCK bl4 WITH FRAME TITLE text-bl4. 
PARAMETERS: p_fname1 LIKE files-line. 
PARAMETERS: p_fname2 LIKE files-line. 
PARAMETERS: p_fname3 LIKE files-line. 
PARAMETERS: p_fname4 LIKE files-line. 
PARAMETERS: p_fname5 LIKE files-line. 
PARAMETERS: p_fname6 LIKE files-line. 
SELECTION-SCREEN: END OF BLOCK bl4. 


AT SELECTION-SCREEN. 

PERFORM chk_selection. 
IF NOT wa_error IS INITIAL. 
MESSAGE e001 WITH wa_error. 
ENDIF. 


START-OF-SELECTION. 

END-OF-SELECTION. 

PERFORM send_email. 


--------------------------------------------------------------------- 


FORM chk_selection * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM chk_selection. 
CLEAR wa_error. 
*Loop only once ??? 
*If more checkings to be done. 
*Think about it and if not clear. 
*Let it sink in for a couple of minutes. 
*Still doesn't make sence? Go home and sleep on it. 
DO 1 TIMES. 
*Check Email to 
IF p_mailto IS INITIAL 
AND s_mailto IS INITIAL. 
wa_error = 'Invalid or no EMAIL TO selection'. 
EXIT. 
ENDIF. 
ENDDO. 
ENDFORM. 

&amp;amp;--------------------------------------------------------------------- 
*&amp;amp; Form send_email 
&amp;amp;--------------------------------------------------------------------- 


text 
---------------------------------------------------------------------- 

--&amp;gt; p1 text 
&amp;lt;-- p2 text 
---------------------------------------------------------------------- 
FORM send_email. 
PERFORM get_folder_info. 
PERFORM fill_body. 
PERFORM ins_new_object. 
PERFORM crt_attachments. 
PERFORM fill_receivers_info. 
PERFORM snd_email. 
ENDFORM. " send_email 

--------------------------------------------------------------------- 


FORM Get_folder_info * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM get_folder_info. 
CLEAR t_soud. 
*Small so should be quick. 
SELECT * FROM soud 
INTO t_soud 
WHERE sapnam = sy-uname. 
p_infolder-foltp = 'FOL'. 
p_infolder-folyr = t_soud-inbyr. "inbox 
p_infolder-folno = t_soud-inbno. 
p_outfolder-foltp = 'FOL'. 
p_outfolder-folyr = t_soud-outyr. "outbox 
p_outfolder-folno = t_soud-outno. 
ENDSELECT. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM fill_body * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM fill_body. 
object_content-line = p_body1. 
APPEND object_content. 
object_content-line = p_body2. 
APPEND object_content. 
object_content-line = p_body3. 
APPEND object_content. 
object_content-line = p_body4. 
APPEND object_content. 
object_content-line = p_body5. 
APPEND object_content. 
object_content-line = p_body6. 
APPEND object_content. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM ins_new_object * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM ins_new_object. 
object_hd_change-objnam = 'Notes'. 
object_hd_change-objdes = p_subj. 

CALL FUNCTION 'SO_OBJECT_INSERT' 
EXPORTING 
folder_id = p_outfolder 
object_hd_change = object_hd_change 
object_type = 'RAW' 
owner = sy-uname 
IMPORTING 
object_hd_display = object_hd_display 
object_id = object_id 
TABLES 
objcont = object_content 
objhead = objhead 
EXCEPTIONS 
active_user_not_exist = 1 
communication_failure = 2 
component_not_available = 3 
dl_name_exist = 4 
folder_not_exist = 5 
folder_no_authorization = 6 
object_type_not_exist = 7 
operation_no_authorization = 8 
owner_not_exist = 9 
parameter_error = 10 
substitute_not_active = 11 
substitute_not_defined = 12 
system_failure = 13 
x_error = 14 
OTHERS = 15. 
IF sy-subrc 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDFORM. 

--------------------------------------------------------------------- 

FORM crt_attachments * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 

--&amp;gt; P_SUBJ * 
--------------------------------------------------------------------- 
FORM crt_attachments. 
document-foltp = p_outfolder-foltp. 
document-folyr = p_outfolder-folyr. 
document-folno = p_outfolder-folno. 
document-objtp = object_id-objtp. 
document-objyr = object_id-objyr. 
document-objno = object_id-objno. 
document-objnam = 'Notes'. 
document-objdes = p_subj. 
document-okcode = 'CHNG'. 
document-file_ext = 'TXT'. 
link_folder_id = object_id. 

header_data-objla = 'EN'. 
header_data-objnam = document-objnam. 
header_data-objdes = document-objdes. 
header_data-objpri = '5'. 
header_data-objsns = 'O'. 
header_data-file_ext = 'TXT'. 

REFRESH files. 
CLEAR files. 
IF NOT p_fname1 IS INITIAL. 
files-line = p_fname1. 
APPEND files. 
ENDIF. 
IF NOT p_fname2 IS INITIAL. 
files-line = p_fname2. 
APPEND files. 
ENDIF. 
IF NOT p_fname3 IS INITIAL. 
files-line = p_fname3. 
APPEND files. 
ENDIF. 
IF NOT p_fname4 IS INITIAL. 
files-line = p_fname4. 
APPEND files. 
ENDIF. 
IF NOT p_fname5 IS INITIAL. 
files-line = p_fname5. 
APPEND files. 
ENDIF. 
IF NOT p_fname6 IS INITIAL. 
files-line = p_fname6. 
APPEND files. 
ENDIF. 
IF NOT files[] IS INITIAL. 
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER' 
EXPORTING 
method = 'ATTCREATEFROMPC' 
TABLES 
files = files 
CHANGING 
document = document 
header_data = header_data. 

IF sy-subrc = 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDIF. 
ENDFORM. 


--------------------------------------------------------------------- 


FORM fill_receivers_info * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM fill_receivers_info. 
DATA: BEGIN OF reclist OCCURS 0, 
rec LIKE receivers-recextnam, 
END OF reclist. 

*Build reclist 
REFRESH reclist. 
IF NOT p_mailto IS INITIAL. 
reclist-rec = p_mailto. 
APPEND reclist. 
ENDIF. 

IF NOT s_mailto IS INITIAL. 
SELECT zdesc 
INTO reclist-rec 
FROM zlookup 
WHERE ztype IN s_mailto. 
APPEND reclist. 
ENDSELECT. 
ENDIF. 

REFRESH receivers. 
LOOP AT reclist. 

folder_selections-folnam = 'INBOX'. 
CALL FUNCTION 'SO_FOLDER_LIST_READ' 
EXPORTING 
folder_selections = folder_selections 
owner = sy-uname 
region = 'P' 
TABLES 
folder_list = folder_list 
EXCEPTIONS 
component_not_available = 1 
operation_no_authorization = 2 
owner_not_exist = 3 
parameter_error = 4 
x_error = 5 
OTHERS = 6. 
IF sy-subrc = 0. 
CLEAR receivers. 
receivers-rcdat = sy-datum. 
receivers-rctim = sy-uzeit. 
receivers-recnam = reclist-rec. 
receivers-recno = folder_list-parno. 
receivers-rectp = folder_list-partp. 
receivers-recyr = folder_list-paryr. 
receivers-sndtp = folder_list-partp. 
receivers-sndyr = folder_list-paryr. 
receivers-sndno = folder_list-parno. 
receivers-sndnam = sy-uname. 
receivers-sndpri = '1'. 
receivers-msgid = 'SO'. 
receivers-msgno = '619'. 
receivers-deliver = 'X'. 
receivers-not_deli = 'X'. 
receivers-read = 'X'. 
receivers-mailstatus = 'E'. 
*receivers-ADR_NAME 
receivers-resend = ' '. 
receivers-sortfield = ' '. "'USER WF_BATCH INDIGO BATCH'. 
receivers-sortclass = '5'. 
APPEND receivers. 
ELSE. 
CLEAR receivers. 
receivers-sel = 'X'. 
receivers-recesc = 'U'. 
receivers-recnam = 'U-'. 
receivers-recextnam = reclist-rec. 
receivers-deliver = 'X'. 
receivers-not_deli = 'X'. 
receivers-read = 'X'. 
receivers-mailstatus = 'E'. 
receivers-adr_name = reclist-rec. 
receivers-sortfield = reclist-rec. 
receivers-sortclass = '5'. 
APPEND receivers. 
ENDIF. 
ENDLOOP. 
ENDFORM. 

--------------------------------------------------------------------- 


FORM snd_email * 
--------------------------------------------------------------------- 

........ * 
--------------------------------------------------------------------- 
FORM snd_email. 
CALL FUNCTION 'SO_OBJECT_SEND' 
EXPORTING 
folder_id = p_outfolder 
object_id = object_id 
outbox_flag = 'X' 
owner = sy-uname 
check_send_authority = 'X' 
originator_type = 'J' 
link_folder_id = link_folder_id 
TABLES 
objcont = object_content 
receivers = receivers 
EXCEPTIONS 
active_user_not_exist = 1 
communication_failure = 2 
component_not_available = 3 
folder_not_exist = 4 
folder_no_authorization = 5 
forwarder_not_exist = 6 
note_not_exist = 7 
object_not_exist = 8 
object_not_sent = 9 
object_no_authorization = 10 
object_type_not_exist = 11 
operation_no_authorization = 12 
owner_not_exist = 13 
parameter_error = 14 
substitute_not_active = 15 
substitute_not_defined = 16 
system_failure = 17 
too_much_receivers = 18 
user_not_exist = 19 
originator_not_exist = 20 
x_error = 21 
OTHERS = 22. 

IF sy-subrc 0. 
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno 
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. 
ENDIF. 
ENDFORM. 


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope this helps, Do reward.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Runal Singh on Apr 3, 2008 12:40 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:09:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648334#M878683</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648335#M878684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi check out the similar forums below..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="5054184"&gt;&lt;/A&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4909551"&gt;&lt;/A&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_message" href="https://community.sap.com/" __jive_macro_name="message" modifiedtitle="true" __default_attr="4734073"&gt;&lt;/A&gt;]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balaram&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:13:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648335#M878684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648336#M878685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Runal,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I cannot understand your program.......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:41:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648336#M878685</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T07:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Mail using ABAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648337#M878686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Follow this link, it gives step by step procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope this helps&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Apr 2008 08:54:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/mail-using-abap/m-p/3648337#M878686</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-03T08:54:11Z</dc:date>
    </item>
  </channel>
</rss>

