發郵件的例子
下面是一個利用通用模塊SO_NEW_DOCUMENT_ATT_SEND_API1進行發郵件的例子。
發送的檔案內容及附件內容:
***************
Record No. Record Description Error Text
1 1st record 1st record in attachment
2 2st record 2st record in attachment
****************
file name was : Arcos Error Report.TXT.
mail body was : Short description of contents(subject)subject : SOME DESCRIPTION
REPORT ZPRG_MAIL.
*----------------------------------------------------------------------*
* PARAMETERS DEFINITION
*----------------------------------------------------------------------*PARAMETERS:
P_EMAIL(40) TYPE C DEFAULT .
*----------------------------------------------------------------------*
* DATA DEFINITION
*----------------------------------------------------------------------*DATA:
G_TABLE_LINES LIKE SY-TABIX, " table index
G_TAB TYPE X VALUE '09'. " TAB value
DATA:
X_DOC_CHNG LIKE SODOCCHGI1, " document attributes
IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
" attachment table
IT_OBJHEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
" object header table
IT_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
" binary table
IT_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* INITIALIZATION
*----------------------------------------------------------------------*INITIALIZATION.
CLEAR IT_RECLIST.
REFRESH IT_RECLIST.
*----------------------------------------------------------------------*
* START-OF-SELECTION
*----------------------------------------------------------------------*START-OF-SELECTION.
*-fill email ids
IT_RECLIST-RECEIVER = P_EMAIL.
IT_RECLIST-REC_TYPE = 'U'.
*-append receiver table
APPEND IT_RECLIST.
CLEAR IT_RECLIST.
*-set document attributes
CLEAR: X_DOC_CHNG.
X_DOC_CHNG-OBJ_NAME = 'HEADING'.
X_DOC_CHNG-OBJ_DESCR = 'Short description of contents(subject)'.
*-set body text
IT_OBJTXT = 'This is the first line of the mail'.
APPEND IT_OBJTXT.
IT_OBJTXT = 'This is the second line of the mail'.
APPEND IT_OBJTXT.
*-document size
CLEAR G_TABLE_LINES.
DESCRIBE TABLE IT_OBJTXT LINES G_TABLE_LINES.
READ TABLE IT_OBJTXT INDEX G_TABLE_LINES.
X_DOC_CHNG-DOC_SIZE =
( G_TABLE_LINES - 1 ) * 255 + STRLEN( IT_OBJTXT ).
*-set packing list for body text
CLEAR IT_OBJPACK-TRANSF_BIN.
IT_OBJPACK-HEAD_START = 1.
IT_OBJPACK-HEAD_NUM = 0.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = G_TABLE_LINES.
IT_OBJPACK-DOC_TYPE = 'RAW'.
APPEND IT_OBJPACK.
CLEAR IT_OBJPACK.
*-set object header
IT_OBJHEAD = 'Arcos Error Report'(057).
APPEND IT_OBJHEAD.
CLEAR IT_OBJHEAD.
*--for attachment ---start
*-populate object bin table for attachment
*-column header
CONCATENATE 'Record No.'
'Record Description'
'Error Text'
INTO IT_OBJBIN
SEPARATED BY G_TAB.
APPEND IT_OBJBIN.
CLEAR IT_OBJBIN.
*-error details
CONCATENATE '1'
'1st record'
'1st record in attachment'
INTO IT_OBJBIN
SEPARATED BY G_TAB.
APPEND IT_OBJBIN.
CLEAR IT_OBJBIN.
CONCATENATE '2'
'2st record'
'2st record in attachment'
INTO IT_OBJBIN
SEPARATED BY G_TAB.
APPEND IT_OBJBIN.
CLEAR IT_OBJBIN.
*-get total no.of lines of Object table(attachment)
CLEAR : G_TABLE_LINES.
DESCRIBE TABLE IT_OBJBIN LINES G_TABLE_LINES.
*-populate object header
IT_OBJHEAD = 'Report'.
APPEND IT_OBJHEAD.
CLEAR IT_OBJHEAD.
*-packing list for attachment
IT_OBJPACK-TRANSF_BIN = 'X'.
IT_OBJPACK-HEAD_START = 1.
IT_OBJPACK-HEAD_NUM = 1.
IT_OBJPACK-BODY_START = 1.
IT_OBJPACK-BODY_NUM = G_TABLE_LINES .
IT_OBJPACK-DOC_TYPE = 'RAW' .
IT_OBJPACK-OBJ_NAME = 'ABCD'.
IT_OBJPACK-OBJ_DESCR = 'ERROR REPORT'.
IT_OBJPACK-DOC_SIZE = G_TABLE_LINES * 255.
APPEND IT_OBJPACK.
CLEAR IT_OBJPACK.
*--code for attachment -- end
*-Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = X_DOC_CHNG
PUT_IN_OUTBOX = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
PACKING_LIST = IT_OBJPACK
OBJECT_HEADER = IT_OBJHEAD
CONTENTS_BIN = IT_OBJBIN
CONTENTS_TXT = IT_OBJTXT
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.
ENDIF.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8214011/viewspace-897022/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux 發郵件Linux
- 群發郵件
- python 發個郵件Python
- python自動發郵件Python
- 利用godaddy的cpanel郵箱伺服器的smtp發郵件Go伺服器
- 在FoxMail裡收發ZohoMail的郵件AI
- 郵件營銷用純文字郵件還是html郵件HTML
- PbootCMS郵件配置修改發件人資訊boot
- JS實現發郵件功能JS
- 郵件的傳送
- C#使用 MailKit 收發郵件C#AI
- seafile QQ郵件的配置
- Ubuntu的郵件傳送Ubuntu
- 脆弱的HTML郵件模板HTML
- win10系統自帶郵箱發不出去郵件怎麼辦_win10郵箱發不出去郵件解決方案Win10
- SpringBoot整合Mail傳送郵件&傳送模板郵件Spring BootAI
- 如何傳送電子郵件到別人郵箱?電子郵件傳送的方法
- 多部門下發補貼?假的!Coremail郵件安全提醒:詐騙型釣魚郵件正在活躍!REMAI
- 郵件營銷容易成為垃圾郵件的原因及解決方法
- 卡巴斯基:2020年垃圾郵件佔全球電子郵件流量的50.37%
- Java Mail 郵件傳送(二):簡單封裝的郵件傳送JavaAI封裝
- 你的郵件安全嗎? 電子郵件威脅與防禦剖析
- 用Gmail做QQ郵件群發的一種方式AI
- 救命!我的電子郵件發不到 500 英里以外!
- 一次性解決python smtp 傳送outlook郵件,163郵件,qq郵件等等.Python
- 電子郵件
- 傳送郵件
- 郵件傳送
- Laravel 郵件配置Laravel
- 電子郵件協議及GO傳送QQ郵件協議Go
- 郵件功能中的那些事
- golang傳送郵件(qq郵箱)Golang
- 全球郵件營銷利器:推薦知名的海外郵件營銷平臺
- word怎麼使用郵件合併功能 word郵件合併的步驟
- SharePoint Online 觸發 Outlook 郵件內審批
- WireShark駭客發現之旅(7)—勒索郵件
- 如何用 Linux 命令列發電子郵件Linux命令列
- 用 vscode 配置 java 開發環境發 qq 郵件VSCodeJava開發環境
- win10郵件怎麼用qq郵箱 win10郵件如何使用qq郵箱Win10