*&---------------------------------------------------------------------*
*& 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-邮件发送的更多相关文章

  1. 【ABAP系列】SAP ABAP实现发送外部邮件(添加附件)功能

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP实现发送外部邮件(添 ...

  2. .NET开发邮件发送功能的全面教程(含邮件组件源码)

    今天,给大家分享的是如何在.NET平台中开发“邮件发送”功能.在网上搜的到的各种资料一般都介绍的比较简单,那今天我想比较细的整理介绍下: 1)         邮件基础理论知识 2)         ...

  3. J2EE 邮件发送那些事儿

    距离自己写的关于java邮件发送的第一篇博客已经有很长一段时间了,现在回过头看看.虽然代码质量方面有待提高,整体结构也不怎样,但是基本思路和过程还是比较纯的.现在有空写写J2EE中邮件发送的开发,实际 ...

  4. 结合ABP源码实现邮件发送功能

    1. 前言 2. 实现过程 1. 代码图(重) 2.具体实现 2.1 定义AppSettingNames及AppSettingProvider 2.2 EmailSenderConfiguration ...

  5. SSH项目里面 忘记密码的邮件发送功能

    package com.xxx.util; import java.util.Date; import java.util.Properties; import javax.mail.Address; ...

  6. [UWP]UWP中获取联系人/邮件发送/SMS消息发送操作

    这篇博客将介绍如何在UWP程序中获取联系人/邮件发送/SMS发送的基础操作. 1. 获取联系人 UWP中联系人获取需要引入Windows.ApplicationModel.Contacts名称空间. ...

  7. java spring 邮件发送

    开发中经常会遇到发送邮件进行用户验证,或者其它推送信息的情况,本文基于spring,完成邮件的发送,主要支持普通文本邮件的发送,html文本邮件的发送,带附件的邮件发送,没有实现群发.多个附件发送等需 ...

  8. Java邮件发送与接收原理

    一. 邮件开发涉及到的一些基本概念 1.1.邮件服务器和电子邮箱 要在Internet上提供电子邮件功能,必须有专门的电子邮件服务器.例如现在Internet很多提供邮件服务的厂商:sina.sohu ...

  9. c#实现邮件发送链接激活

    2016-08-24 10:09:52 public void MailSend(string email) { MailMessage MyMail = new MailMessage(); MyM ...

  10. .Net(C#)最简单的邮件发送案例

    一.序言 刚开始接触邮件发送功能的时候,在网上找的资料都挺复杂的!对于新手入门有点难(至少对于本人来说,第一次接触的时候确实不容易).这里就写一段简单的邮箱发送代码,备忘,也给新手一个参考(相关类的字 ...

随机推荐

  1. [转]Win 10 的 Win 按键没反应

    来自:http://www.pc0359.cn/article/win10/66397.html 方法步骤: 1.首先我们需要将任务管理器运行出来.方法有两种,第一种:使用鼠标右键单击屏幕下方的任务栏 ...

  2. visual studio中新建和使用dll

    本文的目的是 创建一个最小化的dll并使用它 环境:win7 + vs2012 一个VS的解决方案(sln)下面可以有多个项目(project),所以这里新建一个解决方案,然后下面创建两个项目. 新建 ...

  3. dos命令及github介绍

    dos命令:(不区分大小写)(尽量不要用汉字) 1.打开终端的快捷方式: window+r 输入cmd 或点击 开始栏 输入cmd 2.终端的目录:c盘默认 user/administator: 想在 ...

  4. java中友元的完美实现(转载)

    http://blog.sina.com.cn/s/blog_ce5b9f7e0102vhiv.html C++中有一个友元机制,可以给予一个类访问另一个类中私有成员的权限.   这个机制有时候是很有 ...

  5. KPPW2.5 漏洞利用--SQL注入

    KPPW2.5 漏洞利用--SQL注入 SQL注入--布尔型盲注 环境搭建 1,集成环境简单方便,如wamp,phpstudy.... 2,KPPW v2.2源码一份(文末有分享)放到WWW目录下面 ...

  6. Round544div3E(1133E)

    一.题目链接 https://codeforces.com/problemset/problem/1133/E 二.思路 显然要使用dp,因为中间有部分人不会选取. 令$dp[i][j]$表示在前$i ...

  7. system 系统调用、gcc编译过程

    system 库函数的功能是执行操作系统的命令或者运行指定的程序 #include <stdio.h> #include <stdlib.h>//引入库 int main() ...

  8. KVM总结-KVM性能优化之内存优化

    我们说完CPU方面的优化(http://blog.csdn.net/dylloveyou/article/details/71169463),接着继续第二块内容,也就是内存方面的优化.内存方面有以下四 ...

  9. HTML中head与body标签

    一 head内常用标签 1.meta相关 #1.指定字符集 <meta charset="gbk"> #2.页面描述 <meta name="Descr ...

  10. Hive快捷查询:不启用Mapreduce job启用Fetch task

    启用MapReduce Job是会消耗系统开销的.对于这个问题,从Hive0.10.0版本开始,对于简单的不需要聚合的类似SELECT <col> from <table> L ...