<?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: Email in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208804#M1005772</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Imran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use these function modules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SO_DOCUMENT_SEND_API1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SO_NEW_DOCUMENT_ATT_SEND_API1&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/sending-email-with-attachment.htm" target="test_blank"&gt;http://www.sap-img.com/abap/sending-email-with-attachment.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandra Sekhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 19 Jul 2008 14:22:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-07-19T14:22:19Z</dc:date>
    <item>
      <title>Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208801#M1005769</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hye Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I have requirement where a mail has to be triggered, it should contain an attachment which is an internal table and it should also have CC and BCC. Please send a sample code and relevant documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Imran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 12:45:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208801#M1005769</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-19T12:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208802#M1005770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;sorry &lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attachement should be an excel sheel (*.xls).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 12:47:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208802#M1005770</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-19T12:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208803#M1005771</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;Check the following link&lt;/P&gt;&lt;P&gt;[Attach xls to email|&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="199562"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;shrinivas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 13:09:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208803#M1005771</guid>
      <dc:creator>former_member31961</dc:creator>
      <dc:date>2008-07-19T13:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208804#M1005772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Imran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use these function modules:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SO_DOCUMENT_SEND_API1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SO_NEW_DOCUMENT_ATT_SEND_API1&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this link:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/sending-email-with-attachment.htm" target="test_blank"&gt;http://www.sap-img.com/abap/sending-email-with-attachment.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandra Sekhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 14:22:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208804#M1005772</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-19T14:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: Email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208805#M1005773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Imran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can try this piece of code...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;report yh_sample.

data: p_email type somlreci1-receiver
value '&amp;lt;the email-id &amp;gt;'.

data: begin of it001 occurs 0,
bukrs type t001-bukrs,
butxt type t001-butxt,
end of it001.

data: imessage type standard table of solisti1 with header line,
iattach type standard table of solisti1 with header line,
ipacking_list like sopcklsti1 occurs 0 with header line,
ireceivers like somlreci1 occurs 0 with header line,
iattachment like solisti1 occurs 0 with header line.

start-of-selection.

select bukrs butxt into table it001 from t001.

    * Populate table with detaisl to be entered into .xls file

perform build_xls_data .

    * Populate message body text

clear imessage. refresh imessage.
imessage = 'Please find attached excel file'.
append imessage.

    * Send file by email as .xls speadsheet

perform send_email_with_xls tables imessage
iattach
using p_email
'Example Excel Attachment'
'XLS'
'TestFileName'
'CompanyCodes'.

************************************************************************

    * Form BUILD_XLS_DATA

************************************************************************
form build_xls_data .

    * constants: con_cret type x value '0D', "OK for non Unicode
    * con_tab type x value '09'. "OK for non Unicode


*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=&amp;gt;horizontal_tab,
con_cret type c value cl_abap_char_utilities=&amp;gt;cr_lf.

concatenate 'BUKRS' 'BUTXT'
into iattach separated by con_tab.

concatenate con_cret iattach into iattach.
append iattach.

loop at it001 .
concatenate it001-bukrs it001-butxt
into iattach separated by con_tab.
concatenate con_cret iattach into iattach.
append iattach.
endloop .

endform.

************************************************************************

    * Form SEND_EMAIL_WITH_XLS

************************************************************************
form send_email_with_xls tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription.

data: xdocdata like sodocchgi1,
xcnt type i.

    * Fill the document data.

xdocdata-doc_size = 1.

    * Populate the subject/generic message attributes

xdocdata-obj_langu = sy-langu .
xdocdata-obj_name = 'SAPRPT' .
xdocdata-obj_descr = p_mtitle .

    * Fill the document data and get size of attachment

clear xdocdata.
read table iattach index xcnt.
xdocdata-doc_size =
( xcnt - 1 ) * 255 + strlen( iattach ).
xdocdata-obj_langu = sy-langu.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_descr = p_mtitle.
clear iattachment. refresh iattachment.
iattachment = pit_attach.

    * Describe the body of the message

clear ipacking_list. refresh ipacking_list.
ipacking_list-transf_bin = space.
ipacking_list-head_start = 1.
ipacking_list-head_num = 0.
ipacking_list-body_start = 1.
describe table imessage lines ipacking_list-body_num.
ipacking_list-doc_type = 'RAW'.
append ipacking_list.

    * Create attachment notification

ipacking_list-transf_bin = 'X'.
ipacking_list-head_start = 1.
ipacking_list-head_num = 1.
ipacking_list-body_start = 1.

describe table iattachment lines ipacking_list-body_num.
ipacking_list-doc_type = p_format.
ipacking_list-obj_descr = p_attdescription.
ipacking_list-obj_name = p_filename.
ipacking_list-doc_size = ipacking_list-body_num * 255.
append ipacking_list.

    * Add the recipients email address

clear ireceivers. refresh ireceivers.
ireceivers-receiver = p_email.
ireceivers-rec_type = 'U'.
ireceivers-com_type = 'INT'.
ireceivers-notif_del = 'X'.
ireceivers-notif_ndel = 'X'.
append ireceivers.

call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = xdocdata
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = ipacking_list
contents_bin = iattachment
contents_txt = imessage
receivers = ireceivers
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.

endform.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get in the CC section, you have another parameter in receivers as RECEIVERS-COPY. Declare that work variable as you did it for the email-id and fill it and append it to the ireceivers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;clear ireceivers. refresh ireceivers.
ireceivers-receiver = p_email.
ireceivers-copy = p_copy.
ireceivers-rec_type = 'U'.
ireceivers-com_type = 'INT'.
ireceivers-notif_del = 'X'.
ireceivers-notif_ndel = 'X'.
append ireceivers.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it works out for you&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Indu.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 14:49:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/email/m-p/4208805#M1005773</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-19T14:49:11Z</dc:date>
    </item>
  </channel>
</rss>

