Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Email sending

Hi All,

iam using following code iam getting in sap inbox also but iam not reciving the mail iam missing any parameters

WA_MAILDATA-obj_descr = IS_BACKMON-Message_Subject.

*Collect the mailid and reciver type to send an email

WA_RECEIVER-receiver = IS_BACKMON-DIST_LIST.

WA_RECEIVER-rec_type = c_revtype.

WA_RECEIVER-com_type = c_int.

APPEND WA_RECEIVER to i_RECEIVER.

*Display the context of the message

is_contents_txt = IS_BACKMON-Message_Body.

APPEND is_contents_txt to i_contents_txt.

clear is_contents_txt.

*Send an Email to a Particular person

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

document_data = WA_MAILDATA

put_in_outbox = c_flag

commit_work = c_flag

tables

  • object_header = I_MESSAGE

OBJECT_CONTENT = i_contents_txt

receivers = i_RECEIVER

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.

Regards

Warun

Tags:
Former Member
Former Member replied

Here is some sample code from a program where I was using SO_NEW_DOCUMENT_ATT_SEND_API1 to send eMails. I don't remember the specifics of this API but compare it to yours and see if there is anything you're missing.

Hope it helps.

~Ian

FORM f_OutputToDistributionList
                       using
                         l_SelectionScreen type t_SelectionScreen
                         l_Document type t_HTMLDocument.

  Data:
    i_Recievers type Somlreci1 occurs 0,
    wa_Recievers type Somlreci1,
    i_Contents_Txt type SOLISTI1 occurs 0,
    wa_Contents_Txt type SOLISTI1,
    i_PackingList type SOPCKLSTI1 occurs 0,
    wa_PackingList type SOPCKLSTI1,
    i_Contents_Bin type SOLISTI1 occurs 0,
    wa_Contents_Bin type SOLISTI1,
    i_ObjectHeader type SOLISTI1 occurs 0,
    wa_ObjectHeader type SOLISTI1,
    wa_DocumentData type SODOCCHGI1,
    l_MainLines type i,
    l_AttachLines type i.

* Set distribution list
  Refresh i_Recievers.
  clear wa_Recievers.
  wa_Recievers-Receiver = l_SelectionScreen-Dist.
  wa_Recievers-rec_type = 'C'.
  append wa_Recievers to i_Recievers.

* Set document header
  clear wa_DocumentData.
  wa_DocumentData-Obj_Name = text-026.
  wa_DocumentData-Obj_Descr = text-025.

* Set email text
  Refresh i_Contents_Txt.
  clear wa_Contents_Txt.
  wa_Contents_Txt-Line = text-027.
  Append wa_Contents_Txt to i_Contents_Txt.
  clear wa_Contents_Txt.
  wa_Contents_Txt-Line = text-025.
  Append wa_Contents_Txt to i_Contents_Txt.

  describe table i_Contents_Txt lines l_MainLines.

* Set Object Header
  Refresh i_ObjectHeader.
  Clear wa_ObjectHeader.
  Concatenate text-026 '_' sy-datum into wa_ObjectHeader.
  Append wa_ObjectHeader to i_ObjectHeader.

* Set packing list for body of email
  Refresh i_PackingList.
  clear wa_PackingList.
  wa_PackingList-transf_bin = space.
  wa_PackingList-head_start = 1.
  wa_PackingList-head_num = 0.
  wa_PackingList-body_start = 1.
  wa_PackingList-body_num = l_MainLines.
  wa_PackingList-Doc_Type = 'RAW'.

  clear wa_Contents_Txt.
  Read table i_Contents_Txt
  into wa_Contents_Txt
  index l_MainLines.
  wa_DocumentData-Doc_Size =
  ( ( l_MainLines - 1 ) * 255 + strlen( wa_Contents_Txt ) ).

  Append wa_PackingList to i_PackingList.


* Set attachment data
  Refresh i_Contents_BIN.
  Append lines of l_Document-Lines to i_Contents_BIN.
  Describe table i_Contents_BIN lines l_AttachLines.


* Set packing list for attachment
  Clear wa_PackingList.
  wa_PackingList-transf_bin = 'X'.
  wa_PackingList-head_start = 1.
  wa_PackingList-head_num = 0.
  wa_PackingList-body_start = 1.
  wa_PackingList-body_num = l_AttachLines.
  wa_PackingList-doc_type = 'HTML'.
  wa_PackingList-obj_descr = text-029.

  clear wa_Contents_BIN.
  Read table i_Contents_BIN
  into wa_Contents_BIN
  index l_AttachLines.
  wa_PackingList-doc_Size =
  ( ( l_AttachLines - 1 ) * 255 + strlen( wa_Contents_BIN ) ).

  Append wa_PackingList to i_Packinglist.


* Send emails

  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      DOCUMENT_DATA              = wa_DocumentData
      PUT_IN_OUTBOX              = l_SelectionScreen-SaveInOutBox
      COMMIT_WORK                = 'X'
    TABLES
      PACKING_LIST               = i_PackingList
      OBJECT_HEADER              = i_ObjectHeader
      CONTENTS_BIN               = i_Contents_Bin
      CONTENTS_TXT               = i_Contents_Txt
      RECEIVERS                  = i_Recievers
    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 E017(VIS_SD_721).
  else.
    message I018(VIS_SD_721).
  ENDIF.

ENDFORM.                    " f_OutputToDistributionList

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question