ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 实现将生成的文件发送邮件的功能

实现将生成的文件发送邮件的功能

原创 Linux操作系统 作者:cheer77 时间:2008-04-02 14:53:47 0 删除 编辑

发送邮件功能的实现

选择已经保存到本地的文件,再发送邮件(代码仅实现发送邮件功能)

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:\AAA.xls'.
PARAMETERS: ws_file LIKE rlgrap-filename.

g_user-sapname = sy-uname.

CALL FUNCTION 'SO_USER_READ_API1'
     EXPORTING
          user            = g_user
     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 =  'WDN Report'.
g_header-file_ext = 'XLS'.

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.

* 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.


*Send the mail..
method1 = 'SEND'.

g_receipients-recnam = 'BAITZ'.
*g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
*g_receipients-att_fix ='X' .
APPEND  g_receipients.

*g_receipients-recnam = 'ZHENGLL'.
**g_receipients-recesc = 'B'.
*g_receipients-sndex = 'X'.
*g_receipients-att_fix ='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.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13245491/viewspace-224941/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-03-18

  • 博文量
    9
  • 访问量
    14805