*&---------------------------------------------------------------------*
*& 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. spring4.0之八:Groovy DSL

    4.0的一个重要特征就是完全支持Groovy,Groovy是Spring主导的一门基于JVM的脚本语言(动态语言).在spring 2.x,脚本语言通过 Java scripting engine在S ...

  2. HTML背景图片自适应

    由于<body>标签的图片不能够拉伸, 解决办法: 1.图片不够大,又background属性不能拉伸图片: 2.只能用个div,把其z-index值设为负,并使这个div大小为整个bod ...

  3. lucene索引查看工具luke和文本提取工具Tika

    luke可以方便的查看lucene的索引信息,当然也可以查看solr和es中的索引信息(基于lucene实现). 查看索引前,要注意lucene版本的问题,高版本的lucene用低版本的luke工具就 ...

  4. Access、SQLServer、Oracle常见SQL语句应用区别

    Access.SQLServer.Oracle常见SQL语句应用区别 关劲松 PMP 如果要兼容Access.SQL Server.Oracle三个数据库版本:我们在编写SQL语句的过程中,尽量使用一 ...

  5. android websocket

    https://github.com/TakahikoKawasaki/nv-websocket-client

  6. servlet和jsp概述

    1.servlet的作用 B/S系统:浏览器/服务器(Servlet的服务模式) Servlet是运行在web服务器或应用服务器上的java程序,它是一个中间层,负责连接来自web浏览器或其它HTTP ...

  7. 基于Boost的同步TCP通信

    1:客户端 #include <iostream> #include <boost/asio.hpp> using namespace boost; using namespa ...

  8. Android购物车的实现,仿淘宝天猫京东等APP。处理RecyclerView或listview中的选中事件;

    很久之前的代码了,拉出来晾晾! 购物车大致思路: 分为:商品.店铺.全选: 商品全部选中后--店铺自动选中:商品未全部选中(若有一个商品未选中)--店铺不选中. 店铺全部选中后--全选自动选中:店铺未 ...

  9. JAVA List合并集合

    import java.util.ArrayList; import java.util.List; public class test { public static void main(Strin ...

  10. 【Git使用】sourcetree跳过注册的方法(转)

    当前只有Win的版本,Mac自行百度(笑) 很多人用git命令行不熟练,那么可以尝试使用sourcetree进行操作. 然鹅~~sourcetree又一个比较严肃的问题就是,很多人不会跳过注册或者操作 ...