ABAP-邮件发送
*&---------------------------------------------------------------------*
*& Report ZRICO_TEST4
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zrico_test4. constants:
gc_tab type c value cl_bcs_convert=>gc_tab, "CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
gc_crlf type c value cl_bcs_convert=>gc_crlf. "CL_ABAP_CHAR_UTILITIES=>CR_LF parameters: mailto type ad_smtpadr default 'chenruike@geely.com'. " 收件人 data send_request type ref to cl_bcs.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs. data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
data sent_to_all type os_boolean. start-of-selection. perform create_content.
perform send. *&---------------------------------------------------------------------*
*& Form create_content
*&---------------------------------------------------------------------*
* Create Example Content
* 1) Write example text into a string
* 2) convert this string to solix_tab
*----------------------------------------------------------------------*
form create_content. data lv_string type string.
data ls_t100 type t100. * --------------------------------------------------------------
* as example content we use some system messages out of t100
* get them for all installed languages from db
* and write one line for each language into the spread sheet
* columns are separated by TAB and each line ends with CRLF concatenate '测试!'
gc_crlf gc_crlf
into lv_string. do times.
concatenate lv_string
'' gc_tab
'' gc_tab
'' gc_tab
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' gc_tab
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' gc_tab
'ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' gc_tab
'ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' gc_tab
'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' gc_tab
'fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff' gc_tab
'ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg' gc_tab
'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh' gc_tab
'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii' gc_tab
'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj' gc_tab
'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk' gc_crlf
into lv_string.
enddo.
* --------------------------------------------------------------
* convert the text string into UTF-16LE binary data including
* byte-order-mark. Mircosoft Excel prefers these settings
* all this is done by new class cl_bcs_convert (see note 1151257) try.
cl_bcs_convert=>string_to_solix(
exporting
iv_string = lv_string
iv_codepage = '' "suitable for MS Excel, leave empty
iv_add_bom = 'X' "for other doc types
importing
et_solix = binary_content
ev_size = size ).
catch cx_bcs.
message e445(so).
endtry. endform. "create_content *---------------------------------------------------------------
* NOTES:
*---------------------------------------------------------------
* UTF-16LE including the BOM (Byte order mark)
* is preferred by Microsoft Excel. If you want to create
* other binary content you may choose another codepage (e.g.
* '4110' (UTF-8) which is standard for e-mails).
* Find SAP codepage names in the drop down list
* for the codepage setting of node SMTP in transaction SCOT.
* Or: leave iv_codepage and iv_add_bom empty. Then the target
* codepage is set according to SAPconnect settings
*
* Important:
* SAP neither guarantees that the attachment created
* by this report can be opened by all Excel Versions nor
* that it can be opened by any 3rd party software at all *&---------------------------------------------------------------------*
*& Form send
*&---------------------------------------------------------------------*
form send. try. * -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ). * -------- create and set document with attachment ---------------
* create document object from internal table with text
append 'Hello world!' to main_text. " 邮件内容
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = main_text
i_subject = 'Test Created By ricochen' ). " 邮件主题名 * add the spread sheet as attachment to document object
document->add_attachment(
i_attachment_type = 'xls' " 附件格式
i_attachment_subject = 'ExampleSpreadSheet' " attachment name
i_attachment_size = size "附件大小
i_att_content_hex = binary_content ). "附件内容 * add document object to send request
send_request->set_document( document ). * --------- add recipient (e-mail address) -----------------------
* create recipient object
recipient = cl_cam_address_bcs=>create_internet_address( mailto ). * add recipient object to send request
send_request->add_recipient( recipient ). * recipient = cl_cam_address_bcs=>create_internet_address( 'congh@geely.com' ).
* send_request->add_recipient( recipient ). * ---------- send document ---------------------------------------
sent_to_all = send_request->send( i_with_error_screen = 'X' ). commit work.
wait up to seconds.
submit rsconn01 with mode = 'INT'
with output = ''
and return.
if sent_to_all is initial.
message i500(sbcoms) with mailto.
else.
message s022(so).
endif.
* ------------ exception handling ----------------------------------
* replace this rudimentary exception handling with your own one !!!
catch cx_bcs into bcs_exception.
message i865(so) with bcs_exception->error_type.
endtry. endform. "send
ABAP-邮件发送的更多相关文章
- 【ABAP系列】SAP ABAP实现发送外部邮件(添加附件)功能
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP实现发送外部邮件(添 ...
- .NET开发邮件发送功能的全面教程(含邮件组件源码)
今天,给大家分享的是如何在.NET平台中开发“邮件发送”功能.在网上搜的到的各种资料一般都介绍的比较简单,那今天我想比较细的整理介绍下: 1) 邮件基础理论知识 2) ...
- J2EE 邮件发送那些事儿
距离自己写的关于java邮件发送的第一篇博客已经有很长一段时间了,现在回过头看看.虽然代码质量方面有待提高,整体结构也不怎样,但是基本思路和过程还是比较纯的.现在有空写写J2EE中邮件发送的开发,实际 ...
- 结合ABP源码实现邮件发送功能
1. 前言 2. 实现过程 1. 代码图(重) 2.具体实现 2.1 定义AppSettingNames及AppSettingProvider 2.2 EmailSenderConfiguration ...
- SSH项目里面 忘记密码的邮件发送功能
package com.xxx.util; import java.util.Date; import java.util.Properties; import javax.mail.Address; ...
- [UWP]UWP中获取联系人/邮件发送/SMS消息发送操作
这篇博客将介绍如何在UWP程序中获取联系人/邮件发送/SMS发送的基础操作. 1. 获取联系人 UWP中联系人获取需要引入Windows.ApplicationModel.Contacts名称空间. ...
- java spring 邮件发送
开发中经常会遇到发送邮件进行用户验证,或者其它推送信息的情况,本文基于spring,完成邮件的发送,主要支持普通文本邮件的发送,html文本邮件的发送,带附件的邮件发送,没有实现群发.多个附件发送等需 ...
- Java邮件发送与接收原理
一. 邮件开发涉及到的一些基本概念 1.1.邮件服务器和电子邮箱 要在Internet上提供电子邮件功能,必须有专门的电子邮件服务器.例如现在Internet很多提供邮件服务的厂商:sina.sohu ...
- c#实现邮件发送链接激活
2016-08-24 10:09:52 public void MailSend(string email) { MailMessage MyMail = new MailMessage(); MyM ...
- .Net(C#)最简单的邮件发送案例
一.序言 刚开始接触邮件发送功能的时候,在网上找的资料都挺复杂的!对于新手入门有点难(至少对于本人来说,第一次接触的时候确实不容易).这里就写一段简单的邮箱发送代码,备忘,也给新手一个参考(相关类的字 ...
随机推荐
- 廖雪峰Java2面向对象编程-5包和classpath-4classpath和jar
1.classpath 1.1classpath定义 classpath是一个环境变量 classpath指示JVM如何搜索class classpath设置的搜索路径与操作系统相关 * window ...
- 拓扑试验划分简单的静态VLAN
拓扑图 说明: 把交换机连接到PC机的网口类型设置成为access 把交换机与交换机之间的网口类型设置成为truck 然后再给交换机每一个接口划分VLAN 操作如下: 交换机LSW1的配置: 进入输入 ...
- [UE4]工程设置:自动捕获鼠标、通过代码设置鼠标显示隐藏、输入模式、编译时自动保存
一.在4.20版本中运行游戏,在没有进行任何设置的情况下,游戏不会自动捕获鼠标,游戏不会接受输入,需要手动点一下游戏界面才行.如果要跟老版本一样运行游戏自动捕获鼠标,需要进行设置 二.也可以通过代码的 ...
- 00002 - echo命令详解
用于字符串的输出 格式 echo string 使用echo实现更复杂的输出格式控制 1.显示普通字符串: echo "It is a test" 这里的双引号完全可以省略,以下命 ...
- tf.nn.embedding_lookup
tf.nn.embedding_lookup(params, ids, partition_strategy=’mod’, name=None, validate_indices=True, max_ ...
- 支持向量机(SVM)算法分析——周志华的西瓜书学习
1.线性可分 对于一个数据集: 如果存在一个超平面X能够将D中的正负样本精确地划分到S的两侧,超平面如下: 那么数据集D就是线性可分的,否则,不可分. w称为法向量,决定了超平面的方向:b为位移量,决 ...
- javascript-保留2位小数函数方法
function zero(num){ var str=num.toString(); if(str.indexOf(".")==-1){ return num+'.00'; }e ...
- linux 安装scala
1. 下载scala 到scala官网下载scala https://www.scala-lang.org/download/,目前最新版本是2.12.8 wget https://downloads ...
- SQL SERVER 数据压缩
从SQL SERVER 2008开始,SQL SERVER 提供了对数据进行压缩的功能,启用数据压缩无须修改应用程序. 数据压缩可有效减少数据的占用空间,读取和写入相同数据花费的IO也响应减少,从而可 ...
- hive类型转化错误,会错误提示指定分区参数
select * from TRAD_LIST t WHERE t.dt >= '2017-10-18' and t.dt <= '2017-11-01' and t.con_level ...