Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Hi,

Look into the below program which will help us to send any type of document using email from SAP. This program will post the document from our desktop into the Outbox of the mail box, then we have to configure using SM59 to open the Gateway to send mail to the addressee.

 

Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT:  ZSEND_EMAIL.
DATA METHOD1 LIKE SY-UCOMM.
DATA G_USER LIKE SOUDNAMEI1.
DATA G_USER_DATA LIKE SOUDATAI1.
DATA G_OWNER LIKE SOUD-USRNAM.
DATA G_RECEIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
DATA G_DOCUMENT LIKE SOOD4 .
DATA G_HEADER LIKE SOOD2.
DATA G_FOLMAM LIKE SOFM2.
DATA G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE.
DATA G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE.
DATA G_OBJPARA  LIKE SELC OCCURS 0 WITH HEADER LINE.
DATA G_OBJPARB  LIKE SOOP1 OCCURS 0 WITH HEADER LINE.
DATA G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE.
DATA G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE.
DATA G_AUTHORITY LIKE SOFA-USRACC.
DATA G_REF_DOCUMENT LIKE SOOD4.
DATA G_NEW_PARENT LIKE SOODK.
DATA: BEGIN OF G_FILES OCCURS 10 ,
  TEXT(4096) TYPE C,
   END OF G_FILES.
DATA : FOLD_NUMBER(12) TYPE C,
       FOLD_YR(2) TYPE C,
       FOLD_TYPE(3) TYPE C.
PARAMETERS WS_FILE(4096) TYPE C DEFAULT 'c:\document.txt'.
* Can me any file fromyour pc ....either xls or word or ppt etc ...
G_USER-SAPNAME = SY-UNAME.
CALL FUNCTION 'SO_USER_READ_API1'
EXPORTING
   USER                            = G_USER
*    PREPARE_FOR_FOLDER_ACCESS       = ' '
IMPORTING
   USER_DATA                       = G_USER_DATA
*  EXCEPTIONS
*    USER_NOT_EXIST                  = 1
*    PARAMETER_ERROR                 = 2
*    X_ERROR                         = 3
*    OTHERS                          = 4
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FOLD_TYPE = G_USER_DATA-OUTBOXFOL+0(3).
FOLD_YR = G_USER_DATA-OUTBOXFOL+3(2).
FOLD_NUMBER =  G_USER_DATA-OUTBOXFOL+5(12).
CLEAR G_FILES.
REFRESH : G_OBJCNT,
  G_OBJHEAD,
  G_OBJPARA,
  G_OBJPARB,
  G_RECEIPIENTS,
  G_ATTACHMENTS,
  G_REFERENCES,
  G_FILES.
METHOD1 = 'SAVE'.
G_DOCUMENT-FOLTP  = FOLD_TYPE.
G_DOCUMENT-FOLYR   = FOLD_YR.
G_DOCUMENT-FOLNO   = FOLD_NUMBER.
G_DOCUMENT-OBJTP   = G_USER_DATA-OBJECT_TYP.
*g_document-OBJYR   = '27'.
*g_document-OBJNO   = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
G_DOCUMENT-OBJDES   = 'sap-img.com testing by program'.
G_DOCUMENT-FOLRG   = 'O'.
*g_document-okcode   = 'CHNG'.
G_DOCUMENT-OBJLEN = '0'.
G_DOCUMENT-FILE_EXT = 'TXT'.
G_HEADER-OBJDES =  'sap-img.com testing by program'.
G_HEADER-FILE_EXT = 'TXT'.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
  EXPORTING
    METHOD             = METHOD1
   OFFICE_USER        = SY-UNAME
   REF_DOCUMENT       = G_REF_DOCUMENT
   NEW_PARENT         =  G_NEW_PARENT
IMPORTING
   AUTHORITY          =  G_AUTHORITY
TABLES
   OBJCONT            = G_OBJCNT
   OBJHEAD            = G_OBJHEAD
   OBJPARA            = G_OBJPARA
   OBJPARB            = G_OBJPARB
   RECIPIENTS         = G_RECEIPIENTS
   ATTACHMENTS        = G_ATTACHMENTS
   REFERENCES         = G_REFERENCES
   FILES              = G_FILES
  CHANGING
    DOCUMENT           = G_DOCUMENT
   HEADER_DATA        = G_HEADER
*   FOLMEM_DATA        =
*   RECEIVE_DATA       =
          .
* File from the pc to send...
METHOD1 = 'ATTCREATEFROMPC'.
G_FILES-TEXT = WS_FILE.
APPEND G_FILES.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
  EXPORTING
    METHOD       = METHOD1
    OFFICE_USER  = G_OWNER
    REF_DOCUMENT = G_REF_DOCUMENT
    NEW_PARENT   = G_NEW_PARENT
  IMPORTING
    AUTHORITY    = G_AUTHORITY
  TABLES
    OBJCONT      = G_OBJCNT
    OBJHEAD      = G_OBJHEAD
    OBJPARA      = G_OBJPARA
    OBJPARB      = G_OBJPARB
    RECIPIENTS   = G_RECEIPIENTS
    ATTACHMENTS  = G_ATTACHMENTS
    REFERENCES   = G_REFERENCES
    FILES        = G_FILES
  CHANGING
    DOCUMENT     = G_DOCUMENT
    HEADER_DATA  = G_HEADER.
METHOD1 = 'SEND'.
G_RECEIPIENTS-RECNAM = 'MK085'.
G_RECEIPIENTS-RECESC = 'B'.
G_RECEIPIENTS-SNDEX = 'X'.
APPEND  G_RECEIPIENTS.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
  EXPORTING
    METHOD       = METHOD1
    OFFICE_USER  = G_OWNER
    REF_DOCUMENT = G_REF_DOCUMENT
    NEW_PARENT   = G_NEW_PARENT
  IMPORTING
    AUTHORITY    = G_AUTHORITY
  TABLES
    OBJCONT      = G_OBJCNT
    OBJHEAD      = G_OBJHEAD
    OBJPARA      = G_OBJPARA
    OBJPARB      = G_OBJPARB
    RECIPIENTS   = G_RECEIPIENTS
    ATTACHMENTS  = G_ATTACHMENTS
    REFERENCES   = G_REFERENCES
    FILES        = G_FILES
  CHANGING
    DOCUMENT     = G_DOCUMENT
    HEADER_DATA  = G_HEADER.

 

 

Above program can be directly used to send documents .

Thanks ,

Vengal Rao.

  • No labels

1 Comment

  1. Former Member

    Very Helpfull for sending extrnal mail from SAP without using Workflow.

    Thanks,

    Anmol