Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

send notification by email

Former Member
0 Kudos

hi

i ahve a talbe and email id maintained in that table

we need to send email notification from the table to the customer

please let me know the process how to acheive this

regards

Arora

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

> we need to send email notification from the table to the customer

What exactly you mean by sending notification from table to customer.

Do you want to send a email to the email maintained in the table.

If so use the FM:SO_NEW_DOCUMENT_SEND_API1. See the documentation of hwo to use it

And search the forum / blogs for sample code. You have many in the forums similar ones

Regards

Gopi

11 REPLIES 11

gopi_narendra
Active Contributor
0 Kudos

> we need to send email notification from the table to the customer

What exactly you mean by sending notification from table to customer.

Do you want to send a email to the email maintained in the table.

If so use the FM:SO_NEW_DOCUMENT_SEND_API1. See the documentation of hwo to use it

And search the forum / blogs for sample code. You have many in the forums similar ones

Regards

Gopi

0 Kudos

ya thts what i mean to take email id from table and send notification

0 Kudos

hi GOpi

can u please eloborate more and any other method to send notification

and can u please provide me the code to do so

there are three fields in table ztable

number name and email id

i need to pick up email id and send notification

Please suggest

Arora

0 Kudos

hi gopi

the function module u gave is to send doucment not email id notification i dont want to send any doucments>

just a email notification?

regards

arora

0 Kudos

Hi Nishant,

The FM SO_NEW_DOCUMENT_SEND_API1 can also be used to send mails.

Regards,

Atish

0 Kudos

hi atish

can u please give me code to do so

i just need to pick up email from a table and send notification to the email receipients maintained in that table

the table has fields cust no. name and email id

please suggest how to use this funtion module please provide me code to do so

regards

arora

0 Kudos

Hi Nishant,

I answered your query in another thread. Can you please close this one.

Regards,

Atish

0 Kudos

Hope you needed some sample code.

Here it is,

In my code i send an attachment, you can skip that part of attachment, but can just send the email with Text

Hi Arora, You can just skip the commented part and then proceed with the rest part just to send an email with "Shipment Sent" under TEXT-004.

form send_email.

  data : it_docdata     like sodocchgi1 occurs 0 with header line,
         it_objpacklist like sopcklsti1 occurs 0 with header line,
         it_contenttxt  like solisti1   occurs 0 with header line,
         it_reclist     like somlreci1  occurs 0 with header line,
         recipient_int  like sadrud.

  data : l_lines type i.

  refresh : it_docdata, it_objpacklist, " it_objheader
            it_contentbin, it_contenttxt, it_reclist.

* Text contents of the email
  it_contenttxt-line = text-004.
  append it_contenttxt.
  clear : it_contenttxt.

* Contents of the Excel File
  perform align_data.

* Attributes of new document
  it_docdata-obj_name  = 'Message'.
  it_docdata-obj_descr = text-002.

* For Email message
  describe table it_contenttxt lines l_lines.
  it_objpacklist-transf_bin = 'X'.
  it_objpacklist-head_start = 1.
  it_objpacklist-head_num   = 0.
  it_objpacklist-body_start = 1.
  it_objpacklist-body_num   = l_lines.
  it_objpacklist-doc_type   = 'TXT'.
  it_objpacklist-obj_name   = 'Message'.
  it_objpacklist-doc_size   = l_lines * 255.
  append it_objpacklist.
  clear : it_objpacklist.

"* For Email attachment
"  clear : l_lines.
"  describe table it_contentbin lines l_lines.
"*  describe table it_text lines l_lines.
"  it_objpacklist-transf_bin = 'X'.
"  it_objpacklist-head_start = 1.
"  it_objpacklist-head_num   = 0.
"  it_objpacklist-body_start = 1.
"  it_objpacklist-body_num   = l_lines.
"  it_objpacklist-doc_type   = 'XLS'.
"  it_objpacklist-obj_name   = 'Attachment'.
"  it_objpacklist-obj_descr  = 'Workload Statistics for this server'.
"  it_objpacklist-doc_size   = l_lines * 255.
"  append it_objpacklist.
"  clear : it_objpacklist.

* Receivers list
  loop at so_email.
    concatenate so_email-low '@YAHOO.COM' into
                recipient_int-address.
    it_reclist-receiver = recipient_int.
    it_reclist-rec_type = 'U'.
    append it_reclist.
    clear : it_reclist, so_email, recipient_int.
  endloop.

* Function module to send email with attachment
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       exporting
            document_data              = it_docdata
            put_in_outbox              = 'X'
       tables
            packing_list               = it_objpacklist
            contents_bin               = it_contentbin
            contents_txt               = it_contenttxt
            receivers                  = it_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.
    write 😕 'Error sending Email'.
  else.
    write 😕 'Mail successfully sent'.
  endif.

endform.                    " send_email

Regards

Gopi

0 Kudos

hi gopi

thanks for the code but please can u simplify it and eloborate a little according to my requirement

as i want to first select data from a ztable and there can be sevaral email ids maintained in that table may be 1000 or more and i want to send to all the email notification....

pls suggest

thanks in advance

regards

Arora

0 Kudos

HI GOPI

here are doubts PLEASE eloborate if possible for u and please can u help in my context?

form send_email.

WHAT ARE THESE DECLARATION FOR I SUPPOSE AS PR FUNTION MODULE DOCUMENTATION

data : it_docdata like sodocchgi1 occurs 0 with header line,

it_objpacklist like sopcklsti1 occurs 0 with header line,

it_contenttxt like solisti1 occurs 0 with header line,

it_reclist like somlreci1 occurs 0 with header line,

recipient_int like sadrud.

data : l_lines type i. WHAT IS T HIS FOR I SEE BEING USED IN it_contenttxt

BUT PARAMATERS USAGAE IS NOT CLEAR ?

refresh : it_docdata, it_objpacklist, " it_objheader

it_contentbin, it_contenttxt, it_reclist.

  • Text contents of the email

it_contenttxt-line = text-004. " SO HERE I HAV TO PUT MY TEXT WHICH I WANT TO MSSG RIGHT?

append it_contenttxt.

clear : it_contenttxt.

  • Contents of the Excel File

perform align_data. THIS PERFORM HAS NOT FORM? WHAT IS THIS FOR

  • Attributes of new document THIS IS USED FOR?

it_docdata-obj_name = 'Message'.

it_docdata-obj_descr = text-002.

  • For Email message PARAMETES NOT CLEAR AND WHAT IS PURPOSE OF THIS

describe table it_contenttxt lines l_lines.

it_objpacklist-transf_bin = 'X'. ?

it_objpacklist-head_start = 1. ?

it_objpacklist-head_num = 0. ?

it_objpacklist-body_start = 1. ?

it_objpacklist-body_num = l_lines. ?

it_objpacklist-doc_type = 'TXT'. ?

it_objpacklist-obj_name = 'Message'. ? WHAT IS OBJE NAME AND PURPOSE

it_objpacklist-doc_size = l_lines * 255. WHY THIS IS USED

append it_objpacklist.

clear : it_objpacklist.

  • For Email attachment THIS I HAVE TO SKIP ANYHOW

clear : l_lines.

describe table it_contentbin lines l_lines.

  • describe table it_text lines l_lines.

it_objpacklist-transf_bin = 'X'.

it_objpacklist-head_start = 1.

it_objpacklist-head_num = 0.

it_objpacklist-body_start = 1.

it_objpacklist-body_num = l_lines.

it_objpacklist-doc_type = 'XLS'.

it_objpacklist-obj_name = 'Attachment'.

it_objpacklist-obj_descr = 'Workload Statistics for this server'.

it_objpacklist-doc_size = l_lines * 255.

append it_objpacklist.

clear : it_objpacklist.

  • Receivers list SO/_MAIL ? HOW USE THIS FOR SEND ING EMAIL

LIKE I POPULATE DATA IN A INTERNAL TABLE IT_EMAIL AND IT HAS ALL RECEIPENTS WHICH NEEDS TO BE SEND EMAIL

SO HOW TO USE THIS TABLE IT_EMAIL HERE

loop at so_email.

concatenate so_email-low '@YAHOO.COM' into

<b>recipient_int-address.</b> WHAT IS THIS FOR

it_reclist-receiver = recipient_int. ?

it_reclist-rec_type = 'U'. ? WHAT IS U

append it_reclist.

clear : it_reclist, so_email, recipient_int.

endloop.

  • Function module to send email with attachment

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = it_docdata

put_in_outbox = 'X'

tables

packing_list = it_objpacklist

contents_bin = it_contentbin

contents_txt = it_contenttxt

receivers = it_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.

write 😕 'Error sending Email'.

else.

write 😕 'Mail successfully sent'.

endif.

endform. " send_email

Regards

Gopi

Former Member
0 Kudos

Hi,

refer

Regards