Send Email with Attachment in BSP?

Hello,
     I have trouble about sending Email in BSP .
     I don't know how to <b>Send Email with attachment in BSP</b> . Please give me some advice .
    Thank you very much!

Here is a sample application..
<b>Layout</b>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
  <htmlb:page title="Send Mail with Attachment " >
    <htmlb:form id           = "form1"
                encodingType = "multipart/form-data" >
      <htmlb:label for  = "MAILTO"
                   text = "Mail to" />
      <htmlb:inputField id    = "MAILTO"
                        size  = "20"
                        value = "<%= mail_to %>"
                        type  = "string" />
      <htmlb:fileUpload id          = "myUpload"
                        onUpload    = "HandleUpload"
                        upload_text = "Attach"
                        size        = "90" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>
<b>Page attributes:</b>
mail_to     TYPE     ADR6-SMTP_ADDR     E-Mail Address
<b> Event handler OnInputprocessing..</b>
DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD,
      file_content TYPE XSTRING,
      file_length TYPE STRING,
      file_mime_type TYPE STRING,
      file_name TYPE STRING.
fileUpload ?= CL_HTMLB_MANAGER=>GET_DATA(
                       request = request
                       id      = 'myUpload'
                       name    = 'fileUpload' ).
if fileUpload is not INITIAL.
  file_name      = fileUpload->file_name.
  file_mime_type = fileUpload->file_content_type.
  file_length    = fileUpload->file_length.
  file_content   = fileUpload->file_content.
  mail_to = request->get_form_field( `MAILTO` ).
* Send mail part..
  CLASS cl_bcs DEFINITION LOAD.
  DATA:
        lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
  lo_send_request = cl_bcs=>create_persistent( ).
* Message body and subject
  DATA:
        lt_message_body TYPE bcsy_text VALUE IS INITIAL,
        lt_att_content_hex type solix_tab,
        lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
  APPEND 'Dear Vendor,' TO lt_message_body.
  append ' ' to lt_message_body.
  APPEND 'Please find the attached report.'
  TO lt_message_body.
  append ' ' to lt_message_body.
  APPEND 'Thank You,' TO lt_message_body.
  lo_document = cl_document_bcs=>create_document(
  i_type = 'RAW'
  i_text = lt_message_body
  i_subject = 'Visit report' ).
  data: data_tab type solix_tab,
  p_data type XSTRING.
* Pass the data of the document we have uploaded..
  p_data = file_content.
  call function 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = p_data
    TABLES
      binary_tab = data_tab.
  DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
  TRY.
      lo_document->add_attachment(
      EXPORTING
      i_attachment_type = 'PDF'
      i_attachment_subject = 'Visit Report'
      i_att_content_hex = data_tab ).
    CATCH cx_document_bcs INTO lx_document_bcs.
  ENDTRY.
* Add attachment
* Pass the document to send request
  lo_send_request->set_document( lo_document ).
* Create sender
  DATA:
  lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
  l_send type ADR6-SMTP_ADDR value '[email protected]'.
* Set sender
  l_send = mail_to.
  lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
  lo_send_request->set_sender(
  EXPORTING
  i_sender = lo_sender ).
* Create recipient
  DATA:
  lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
  lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
** Set recipient
  lo_send_request->add_recipient(
  EXPORTING
  i_recipient = lo_recipient
  i_express = 'X' ).
  lo_send_request->add_recipient(
  EXPORTING
  i_recipient = lo_recipient
  i_express = 'X' ).
* Send email
  DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
  lo_send_request->send(
  EXPORTING
  i_with_error_screen = 'X'
  RECEIVING
  result = lv_sent_to_all ).
  COMMIT WORK.
endif.
Hope this will be helpful.
Raja T

Similar Messages

  • XI Mail Adapter: sending emails with attachment with help of java mapping

    Hi ,
    On trying out the scenerio mentioned in the blog, using the java mapping provided
    "XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    The scenerio works just fine.
    But the payload as the content of the attachment is not getting generated in proper XML format.
    I suppose it's because of the replace special characters code part..
    Can anyone help me state the modification required in the code.
    Thanks!
    Regards,
    Faria Mithani

    It might be a codepage issue. Is your original payload UTF-8?

  • Sharepoint Online - Send email with attachment

    Hi All,
    is there some way how to send email with attachment, which is attached to list item in host web?
    I tried some of solutions but none of them not working.
    Server side:
    For example event receiver after added list item with attachment - Because it is office 365, in SandBox solution I can´t use SmtpClient class.
    Any other ideas?
    Client side:
    For example client web part with REST call. It works fine until I don´t need access to attachment.
    string oDataUrlAttach = "/_api/Web/lists/getbytitle('ListName')/Items(6)/AttachmentFiles('Document.docx')/$value";
                HttpWebRequest itemRequestAttach = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + oDataUrlAttach);
                itemRequest.Method = "GET";
                itemRequest.Accept = "application/atom+xml";
                itemRequest.ContentType = "application/atom+xml;type=entry";
                itemRequest.Headers.Add("Authorization", "Bearer " + accessToken);
                HttpWebResponse itemResponseAttach = (HttpWebResponse)itemRequestAttach.GetResponse();
    Here I get error: The remote server returned an error: (403) Forbidden.
    But other calls are OK. I can get all items from my list except attachments.
    Any ideas?
    Thank you.

    Why hasn't this been answered?
    Sam Ogle

  • How i can send email with attachment ?

    any body can help me ..............??????????????????

    Hello,
    please, use "Search" utility in the forum before ask something like this...
    I've just tried with :
    "send email with attachment"
    and ... you have the solution in the first result...
    Regards,
    Jose.

  • Sending email with attachment from iCloud

    when i am sending email with attachment, when i am sending email with attachment I found that the mail was send and still on draft on the client software on my mac book pro. Any solution please??

    That happens at times.  Don't know why.  Just delete the email in the drafts folder, as long as you are sure it was sent (check the sent folder).  I've wondered whether it's a timing issue.

  • BPEL send email with attachment

    Hi guys,,
    Now i want to send email with attachment from the bpel console. In bpel console, if i want to use, "browse" button, how can i create this button in my xsd file?

    Hello,
    Well I'm using the BPEL build in decoder. It works for txt file but how about PDF? Will it be the same?
    it give me this message in the email process.
    XML Parsing Error: reference to invalid character number
    p/s: it working to txt but not pdf.
    below is the script
    <bpelx:exec name="decoder" language="java" version="1.5">
    <![CDATA[String inputString = new String();
                inputString =(String)getVariableData("attachmentContentVar");  
        try {
                String decoded = Base64Decoder.decode(inputString);  
                setVariableData("decoded",decoded); 
    catch(Exception e)
    e.printStackTrace();
    }]]>
    </bpelx:exec>
    <copy>
    <from variable="retriveAttachment_retriveAttachmentSelect_TASKID_OutputVariable"
    part="WfattachmentCollection"
    query="/ns3:WfattachmentCollection/ns3:Wfattachment/ns3:encoding"/>
    <to variable="varNotificationReq" part="EmailPayload"
    query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:MimeType"/>
    </copy>
    <copy>
    <from variable="retriveAttachment_retriveAttachmentSelect_TASKID_OutputVariable"
    part="WfattachmentCollection"
    query="/ns3:WfattachmentCollection/ns3:Wfattachment/ns3:name"/>
    <to variable="varNotificationReq" part="EmailPayload"
    query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:BodyPartName"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('decoded')"/>
    <to variable="varNotificationReq" part="EmailPayload"
    query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:ContentBody"/>
    </copy>
    </assign>
    Edited by: kpchong on Oct 20, 2009 12:00 AM

  • Send Email with Attachment Callable Object

    Hello,
    I have a GP Application where i have 2 steps....in the first action the initiator attaches a document through standard GP functionality......i want to send this attachment to the approver alongwith the email i am already sending using 'Send email with Attachment (optional)' callable obejct.....how can i implement this....?
    Any help would be highly appreciated.
    Regards,
    Anil

    Hello Anil!
    Well, if i really undestand your question, i think you resolve it using callable object mail with attachment, you said that do it, so, you only need to configure your smtp on youser server and you don´t need more work.
    Please write any doubts.

  • Send Email with attachment further .

    Hello All,
          Thank Raja Thangamani for giving me an answer about <b>Send Email with attachment</b>  . But now I have a new question that when I sene Email with attachment beyond 500M , this funtion is not applied .
          Pls give me some advice! Thanks very much!

    Look at this link & thread..
    http://www.thespot4sap.com/Articles/SAP_Mail_UNIX_Example_ABAP.asp
    Send PDF Attachment to SAP Mail Inbox.
    Hope this will solve your problem.
    Raja T
    Message was edited by:
            Raja Thangamani

  • Send email with attachment via XI

    Hi,
    I need some help regarding sending out email with attchment via XI. My scenario will be I will need to send an email with attachment of Purchase Order (PDF format). I need to do it via XI. Is there any best way for me to configure my SENDER/RECEIVER Mail Adapter in order to send the email with PDF attachment via XI.
    Appreciate any valuable thoughts and advice.
    Thanks,
    Zubair

    Have you seen these blogs
    https://weblogs.sdn.sap.com/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    regards
    SKM

  • How to send email with attachment

    Hi friends,
    I am using soa 11.1.1.7.0
    Jdev 11.1.1.7.0
    WebLogic:- 10.3
    I want to generated email with attachment in BPEL 11g. Below is what i did in my bpel process
    Create simple hello world bpel process.
    In email activity below details are given
    <scope name="Email1">
    <bpelx:annotation>
    <bpelx:pattern patternName="bpelx:email"></bpelx:pattern>
    </bpelx:annotation>
       <variables>
       <variable name="varNotificationReq"
                              messageType="ns1:EmailNotificationRequest"/>
                    <variable name="varNotificationResponse"
                              messageType="ns1:ArrayOfResponse"/>
                    <variable name="NotificationServiceFaultVariable"
                              messageType="ns1:NotificationServiceErrorMessage"/>
                </variables>
                <sequence name="Sequence1">
                    <assign name="EmailParamsAssign">
                        <copy>
                            <from expression="string('Default')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:FromAccountName"/>
                        </copy>
                        <copy>
                            <from expression="string('')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:FromUserName"/>
                        </copy>
                        <copy>
                            <from expression="string('')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Bcc"/>
                        </copy>
                        <copy>
                            <from expression="string('')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Cc"/>
                        </copy>
                        <copy>
                            <from expression="string('')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:ReplyToAddress"/>
                        </copy>
                        <copy>
                            <from expression="bpws:getVariableData('inputVariable','payload','/client:process/client:subject')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Subject"/>
                        </copy>
                        <copy>
                            <from expression="bpws:getVariableData('inputVariable','payload','/client:process/client:to')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:To"/>
                        </copy>
                        <copy>
                            <from><Content xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"><MimeType xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService">multipart/mixed</MimeType><ContentBody xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"><MultiPart xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"> <BodyPart xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"><MimeType xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/><ContentBody xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/><BodyPartName xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/></BodyPart> <BodyPart xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"><MimeType xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/><ContentBody xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/><BodyPartName xmlns="http://xmlns.oracle.com/ias/pcbpel/NotificationService"/></BodyPart></MultiPart></ContentBody></Content></from>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content"/>
                        </copy>
                        <copy>
                            <from expression="string('text/html; charset=UTF-8')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[1]/ns1:MimeType"/>
                        </copy>
                        <copy>
                            <from expression="bpws:getVariableData('inputVariable','payload','/client:process/client:body')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[1]/ns1:ContentBody"/>
                        </copy>
                        <copy>
                            <from expression="string('text/plain')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:MimeType"/>
                        </copy>
                        <copy>
                            <from expression="string('SampleStudent.txt')"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:BodyPartName"/>
                        </copy>
                        <copy>
                            <from expression="concat('file:///', bpws:getVariableData('inputVariable','payload','/client:process/client:attachmentURI'))"/>
                            <to variable="varNotificationReq" part="EmailPayload"
                                query="/EmailPayload/ns1:Content/ns1:ContentBody/ns1:MultiPart/ns1:BodyPart[2]/ns1:ContentBody"/>
                        </copy>                
                    </assign>
                    <invoke name="InvokeNotificationService"
                            portType="ns1:NotificationService"
                            partnerLink="NotificationService1"
                            inputVariable="varNotificationReq"
                            outputVariable="varNotificationResponse"
                            operation="sendEmailNotification"/>
                </sequence>
            </scope>
            <!--
              Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
            -->
            <invoke name="callbackClient"
                    partnerLink="sendingemailwithattachmentsprcs_client"
                    portType="client:SendingEmailWithAttachmentsPrcsCallback"
                    operation="processResponse" inputVariable="outputVariable"/>
        </sequence>
    </process>
    I am able to generate Email with attachment but i cant see the data in the attached file.
    I think i need to convert the data before sending as a attachment. Could someone please help me in generating the txt files.
    Regards,
    Rajireddy.

    Re: sending fax

  • Problem in sending email with attachment more than 32kb through utl_mail

    Hi friends
    I am able to send an email with attachment upto 32kb using utl_mail.
    But whenever I increase the size of attachment from 32kb, it prompts me an error.
    ===============================================
    ORA-20001: The following error has occured:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ===============================================
    i have also used LONG RAW instead of RAW, bu still the problem is same.
    please help me in solving this issue.
    Thanks in advance,
    Ankur

    Yeah that's an issue with UTL_MAIL it only has 3 procedures, and none of them let you send data to the SMTP server incrementally. To send files larger than 32k you will need to switch over to using UTL_SMTP directly or via a helper package such as the [DEMO_MAIL package|http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html] available from otn.

  • Sending email with attachment (image)

    Is there any way or workaround to send emails with attachments? The only way known to me is to use mailto but how to include attachment then? Has anyone tried to do that with native extensions on iOS?

    Maybe someone experienced in ObjectiveC could support the community and write a native extension for sending email with attachments and post it here: http://www.adobe.com/devnet/air/native-extensions-for-air.html

  • Sending email with attachment SO_DOCUMENT_SEND_API1, chinese Charactors

    Hi all,
    Using SO_DOCUMENT_SEND_API1 to send an email with attachment of an xls file, those chinese charactors cant be written properly into the xls file. During my debug proccess, those chinese charactors seems fine, look good in the internal table. But the xls file received, those chinese charactors changed into weird charactors....
    Thank you....

    Hai Kokwei Wong
    Check the following Code
      DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
      DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
      DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
      DATA: DOC_CHNG  LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
      DATA L_NUM(3).
    Creation of the document to be sent
    File Name
      DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
      DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
    Mail Contents
      OBJTXT = 'Object text'.
      APPEND OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    Creation of the document attachment
      LOOP AT ITAB_DATA.
        CONCATENATE ITAB_DATA-PRODUCTOR
                    ITAB_DATA-VBELN
                    ITAB_DATA-POSNR
                    ITAB_DATA-MATNR INTO OBJBIN.
        APPEND OBJBIN.
      ENDLOOP.
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = 'ORDERS'.
      APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM   = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM   = TAB_LINES.
      OBJPACK-DOC_TYPE   = 'TXT'.
      OBJPACK-OBJ_NAME   = 'WEBSITE'.
      OBJPACK-OBJ_DESCR  = 'ORDERS.TXT'.
      OBJPACK-DOC_SIZE   = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
    target recipent
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      RECLIST-EXPRESS  = 'X'.
      RECLIST-REC_TYPE = 'U'.
      APPEND RECLIST.
    copy recipents
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      RECLIST-EXPRESS  = 'X'.
      RECLIST-REC_TYPE = 'U'.
      RECLIST-COPY     = 'X'.
      APPEND RECLIST.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = DOC_CHNG
           TABLES
                PACKING_LIST               = OBJPACK
                OBJECT_HEADER              = OBJHEAD
                CONTENTS_BIN               = OBJBIN
                CONTENTS_TXT               = OBJTXT
                RECEIVERS                  = RECLIST
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
    Thanks & regards
    Sreenivasulu P

  • Problem sending email with attachment by android

    Good Morning, I'm Luca.
    I have this problem:
    through a smartphone with Android system,
    synchronized via ActiveSync, the user
    is unable to send emails with attachments.
    While you can receive them and
    open them without problem.
    We have a server with Exchange 2010.
    Is there any authorization that I have to give
    you?
    Other devices, always with Android system,
    with other accounts of course,
    does not have the same problem.
    Thank you very much
    Best regards

    Luca, if one user is able to send attachments, the other should be able to as well.  However, if an attachment is too large, it won't be delivered.  
    Agreed, This does sound like a size limitation issue.
    Have the person try to send the same file from his outlook on his PC and see if he can send it out, that should be a good indication.

  • Send email with attachment PDF

    Hi,
    i have two environments. One is updated with support package 16 and the other environment isn't updated.
    in the environment that is not updated i can send normally email with attachment using smartforms with the function 'SO_NEW_DOCUMENT_ATT_SEND_API1' but now i copied this program to the environment that is updated but the attachment have issue...it don't open.
    anybody have some idea to solution?
    tks
    Patricia

    Hi,
    Check the program 'BCS_EXAMPLE_6' for sending PDF as an attachment. Try sending your PDF using the method specified.
    Regards,
    Sagar

Maybe you are looking for