Select within MAIL.SEND

If i have setup a MAIL.SEND and in the body i want to count how many rows are in a database and print it into the HTML body, how do i run the select if
P_BODY_HTML => ' This is the report
"'||(select count(distinct username) from gfmis.autobahndirectaccounts;)||'"

Here is the code <br>
<br>
FOR c1 IN (SELECT emailaddress from GFMIS.MISUSERS where userid = (select appitpm from GFMIS.GFAPPOWNERS where APPNAME = 'AUTOBAHNDIRECT')) LOOP
FOR c2 IN (select emailaddress from gfmis.misusers where mislogonid = :APP_USER) LOOP
   declare
    v_num_users number;
    begin select count(distinct username) into v_num_users from gfmis.autobahndirectaccounts;
    end;
   HTMLDB_MAIL.SEND(
      P_TO       => c1.emailaddress,
      P_CC       => c2.emailaddress,
      P_FROM     => '[email protected]',
      P_BODY     => ' ',
      P_SUBJ     => '### ! MIS Autobahn Direct Application user recertification ! ###',
      P_BODY_HTML => '
The user has recertified " '|| v_num_users||' " many users on the system.
HTMLDB_MAIL.PUSH_QUEUE( '10.143.10.38', '25');
   END LOOP;
END LOOP;
[pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Automator to select e-mail sender and copy text on excel

    I need to use automator to select e-mail sender, extract specific text and append it on an excel sheet. is it possible?
    I have OS Snow Leopard; Mail; a Master Excel 2011 file; several Output Excel 2011 files for the output
    I want Automator to check daily if new mails, on a specific account, have been received that match the mail address with a given list of names and related mail address in the Master Excel.
    If a new mail is present, Automator should: pick up specific text in the mail body; select and open the related Output Excel file (each output Excel file is saved with the name linked with the e-mail address in the Master Excel); append the text on the given worksheet in the Output Excel file; save the output file.
    This should be done with all the received mails that match with the Master Excel file
    Is it possible do this kind of thing with automator? may be with the support of VBA for some parts?
    I would appreciate any suggestion or idea to resources to investigate

    Hi Stephen,
    I had the same problem and it is a software bug.
    SAP release for us a special sap note number 1278473 - "Followup E-mail doesnot contain text of Notes of Activity".
    I dont know if this note was release for all customer, but you can open a message to sap asking help.
    My message at sap was 946981/2008.
    Regards,
    Lalas

  • Safari Services:Mail:Send Selection broken in Tiger

    Since upgrading to Tiger, I can no longer email selected text in Safari using the Services:Mail:Send Selection command. Nothing happens.
    Not that it should matter, but I'm using the Server version of Tiger.

    Yep, all updates are installed.
    It works on my two Tiger (client) machines, but not on my server machine.

  • Mail sending ONLY problems

    Just installed a new macintosh - 20" dual 2 core iMac - love it. Problem:
    Set up pop email account and it seems my ISP (excite.com) is rejecting the email traffic I send due to mis-matched info in the header. I included the reject message at the end of this note. Question: Does the macintosh automatically route an email through a mac.com server on its way to the smtp outgoing mail server? That seems to be my problem...or I have it all wrong - not sure!! Any help appreciated...
    Date: Sun Oct 29 19:04:34 2006
    From: Mail Delivery Subsystem <[email protected]>
    [ Add to Address Book | Block Address | Report as Spam | This is not Bulk Mail ]
    To: <[email protected]>
    Subject: Returned mail: see transcript for details
    The original message was received at Sun, 29 Oct 2006 16:04:32 -0800 (PST)
    from mail23-ce1 [10.13.11.50]
    ----- The following addresses had permanent fatal errors -----
    <[email protected]>
    (reason: 554 <[email protected]>: Sender address rejected: The mailserver used does not match the excite.com domain Error: WS-13)
    ----- Transcript of session follows -----
    ... while talking to xmxatip.excite.com.:
    DATA
    <<< 554 <[email protected]>: Sender address rejected: The mailserver used does not match the excite.com domain Error: WS-13
    554 5.0.0 Service unavailable
    <<< 554 Error: no valid recipients
    <div class="jive-quote">RSET
    <<< 421 xprdmx30.nwk.excite.com Error: too many errors
    Forwarded Message:
    Forwarded Message:
    Return-Path: <[email protected]>
    Received: from mail23-ce1 (mail23-ce1 [10.13.11.50])
    by smtpout.mac.com (Xserve/8.12.11/smtpout05/MantshX 4.0) with ESMTP id k9U04WL5009210
    for <[email protected]>; Sun, 29 Oct 2006 16:04:32 -0800 (PST)
    Received: from mac.com (smtpin45-en2 [10.13.9.113])
    by ms23.mac.com (iPlanet Messaging Server 5.2 HotFix 2.08 (built Sep 22 2005))
    with ESMTP id <[email protected]> for [email protected]

    OK.
    Receiving mail from these "excite-able" servers works.
    Sending mail does take more detailed precision.
    Reconfigured "many times". How many times?
    Probably about 5 - each time I made a tweak that I thought might work !!
    But you say that Mail.app shows it "Sent", no errors?
    YES - I would not know there was a problem if I did not send myself an email and never get it...
    What about the bounce msg you attached?
    Where does that appear?
    Only in webMail ('interent based mail >>application'...whatever that means?)
    WebMail
    And there's nothing in any of your setup where you >>see "mac.com"?
    Yes, mac.com is a server shown - but not selected
    That's sort of an indication that you've somehow set up >>your mail to send through the apple dot-mac.com >>arrangement that might have been a promotional feature >>with your new Mac.
    That was my thought - is it possible? How would I correct?
    As long as your setup to adelphia works within Mail, use >>that configuration and modify IT to match the Excite >>settings.
    Did not know that was possible - I will do - any hints on how?
    Too bad Excite doesn't have an interactive help page. >>But they're free, right?
    Email support is almost as putzy as the AppleDiscussions >>sometimes (just kidding)
    Not free for "pop" access - I am re-thinking that now...grin!

  • Mail Send Functionality using SO_NEW_DOCUMENT_ATT_SEND_API1

    hi,
    i m using Fn Module "SO_NEW_DOCUMENT_ATT_SEND_API1" to send email with attachment.
    I have written  a program which will fetch data in excel format . this excel should be sent as attachment to specified receiver. however i m having difficulties adding attachment to function module.
    I specified under parameter "contents_bin" but its giving some error message related wth structure.
    I chkd SDN and wasnt able to find any resolution yet.
    Any suggestion or idea which can be useful on this.
    Thanks.

    REPORT  zsendemail                    .
    PARAMETERS: psubject(40) type c default  'Hello',
                p_email(40)   type c default 'write email address' .
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *&      Form  POPULATE_MESSAGE_TABLE
          Adds text to email text table
    form populate_message_table.
      Append 'Email line 1' to it_message.
      Append 'Email line 2' to it_message.
      Append 'Email line 3' to it_message.
      Append 'Email line 4' to it_message.
    endform.                    " POPULATE_MESSAGE_TABLE
    *&      Form  SEND_EMAIL_MESSAGE
          Send email message
    form send_email_message.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Add the recipients email address
      clear it_receivers.
      refresh it_receivers.
      it_receivers-receiver = p_email.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      it_receivers-notif_del = 'X'.
      it_receivers-notif_ndel = 'X'.
      append it_receivers.
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_txt               = it_message
                receivers                  = it_receivers
           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.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    endform.                    " SEND_EMAIL_MESSAGE
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = 'X'
                        and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM

  • MAIL Sender adapter going in to error

    Hello Experts ,
    We have configured one mail sender adpater with a custom module to read the attachements in the email message. This was working fine before.
    We recently had a restart of the PI servers. After that the channel is going in to error. The first error as per NWA logs is :
    failed to call the adapter engine; caused by javax.ejb.EJBException: Exception in getMethodReady() for stateless bean sap.com/com.sap.aii.adapter.mail.app*xml|com.sap.aii.adapter.mail.ejb.jar*xml|XIMailAdapterBean; nested exception is: com.sap.engine.services.ejb3.util.pool.PoolException: javax.ejb.EJBException: Exception raised from invocation of public void com.sap.aii.adapter.mail.ejb.XIMailAdapterBean.ejbCreate() throws javax.ejb.CreateException method on bean instance com.sap.aii.adapter.mail.ejb.XIMailAdapterBean@243be1e1 for bean sap.com/com.sap.aii.adapter.mail.app*xml|com.sap.aii.adapter.mail.ejb.jar*xml|XIMailAdapterBean; nested exception is: javax.ejb.CreateException: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Failed to load messages into Queue AFWSend from database. Reason: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component "ejbContexts/sap.com/com.sap.aii.adapter.mail.app/com.sap.aii.adapter.mail.ejb.jar/XIMailAdapterBean" in application "sap.com/com.sap.aii.adapter.mail.app" is currently associated with a restricted resource set and it is not allowed to get connection within it.
    After that whenever it is trying to process a message its throwing the below error :
    exception caught during processing mail message [588]com.sap.aii.af.lib.mp.module.ModuleException
    Has anybody faced thsi error before? Please help!!!
    Thanks

    Hi VR
    Have you tried swapping by Payload name?
    Please try it out with the following configuration, and remove any extra lines - there are duplicate key names and values in your configuration.
    You should be able to see the successfully swap by payload name in the audit log as shown below.
    Rgds
    Eng Swee

  • Dynamic Configuration of Mail-Sender does not work

    Hi,
    we use XI 3.0 SPS 19.
    In my szenario I have a mail sender and I have receiver determination with conditions depending on the mail subject.
    In the condition editor, I selected the context object "SHeaderSUBJECT" to build my condition.
    In the mail communication channel I turned on the Checkbox "adapter specific message attributes".
    But the condition doesn't work!!!
    I wrote a small UDF to get the dynamic configuration of my mail sender-message - but it's NULL.
    If I change my scenario from Mail-Sender to a file-sender, everything works fine (I can select the filename, etc.).
    Is there a problem with dynamic configuration of a mail sender?
    Thx all for your help!
    Regards
    Wolfgang Hummel

    Check also "Variable Transport Binding".
    You see in the SXMB_MONI whether the ASMA is available or not.
    Regards
    Stefan

  • Help requierd on mail sender adapter

    i m workin on a scenario to send email from a mail server inbox to XI.i need to configure mail sender adapter....need step by step help on that.
    regards,
    latika.

    hi latika,
    the Message Structure to be defined depends on the message protocol that you are trying to use.
    I would recommend using XIPAYLOAD. From the help link,
    <b>XIPAYLOAD</b>
    In this mode, the content of the e-mail is put in the payload of the XI message. If you do not set the Use Mail Package indicator, the information about the sender (From), receiver (To), and subject of the e-mail is lost.
    If you have selected XIPAYLOAD as the message protocol, you must make the following additional specifications under Mail Attributes:
    If you want to put the entire e-mail message including the header information (From, To, Subject) in the payload, set the Use Mail Package indicator. See the example below. The header information is included in an XML mail package format.
    <i>
    Source Structure</i>
    <i><?xml version="1.0" encoding="UTF-8"?>
    <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
      <Subject>Subject</Subject>
      <From>[email protected]</From>
      <To>[email protected]</To>
      <Reply_To />
      <Content_Type>text/plain</Content_Type>
      <Content>
      This is the content.
      </Content>
    </ns:Mail></i>
    Regards,
    Bhavesh

  • Is it a way to read Multiple Attachment and send all     - Mail Sender?

    Hi Friends ,
                          Can you please tell me how to send multiple Attachment in Mail Sender Adapter  ?
                     <b>      I am able to bring Multiple Attachement in Payload .But, Only one attachemen't data is passed to IS.</b>
                        First form the attachement i read as row bye row. Rowe like  <b>123 56 98 56 9</b>6 like that  , then in Integration Process i am using<b> XSLT Mapping</b> to get   my required format .
                         It is getting the data from the First Attachement   only. <b>But i am having Three attachement in payload  as MailAttachement-1  , MailAttachement-2 , MailAttachement-3 like that .</b>
                     <b>Can you please tell me how to pass to IS as one by one attachement  ?</b>
    Regards .,
    V.Rangarajan

    You want to separate each attachment in one single message?
    If yeah, change your xslt mapping to a multimapping, which generate the several messages.
    If not, in the receiver mail adapter, select "keep atachments" checkbox.
    Regards,
    Henrique.

  • Mail sending problem......

    dear all,
    i want to send external mail through sap......
    in that i m making spool & convert to pdf and send as a attachment.......
    i hv a got idea from
    <a href="http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm.">http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm.</a>
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm.
    but as per requirement i m changing some logic.....but it is not work.......
    i m calling some other program using submit.
    i m giving code here.....
    SUBMIT YPPDAILYUPDATE "VIA SELECTION-SCREEN
                           with pstngdt in temp
                           with entdate eq ' '
                           with posdate eq 'X'
                           with rdata eq 'X'
                           with logic eq ' '
                           with high eq 'X'
                           with trend eq ' '
                             AND RETURN
    new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
      select yemail as p_email into CORRESPONDING FIELDS OF TABLE mailtab
          from ymail
          where ytcode = 'YPP18'.
          gd_attachment_desc1 = 'YPP18'.
        PERFORM convert_spool_to_pdf.
        loop at mailtab into mailstr.
          p_email1 = mailstr-p_email.
        PERFORM process_email.
        endloop.
      wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
       ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool & mail sending',
                'request to be created.'.
      ENDIF.
    but using this i m running this program in background then also it not generate any spool......
    pls give a solution for this problem.....
    i will provide points for that....
    Regards,
    Arpit
    <a href="http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm.">http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm.</a>

    Hi Arpit,
    You can create spool in the Report itself.
    have a look at this code and paste it where do you want to create it and convert it into PDF for mailin purpose.
       CONSTANTS : l_c_device(4)    VALUE 'LOCL'.
    **   Create Spool Request
      NEW-PAGE PRINT ON
      LINE-SIZE 120
      DESTINATION l_c_device
      IMMEDIATELY ' '
      KEEP IN SPOOL 'X'
      NEW LIST IDENTIFICATION 'X'
      NO DIALOG.
    Regards,
    Vikas.
    plz reward if helpful...

  • Bug report: Mail sends messages with empty bodies

    Over the last year, I have experienced a particularly irritating bug in Mail.app at least a dozen times. I finally have a good idea as to what causes it.
    The problem involves long email messages (often with attachments) that end up being sent with blank bodies (and no attachments). Even the copy in the "Sent" folder ends up blank, and several minutes or hours of work vanishes into thin air, not to be seen ever again.
    I finally realized that this bug only occurs when sending mail through our work SMTP server while outside the work firewall, and only as a result of a certain sequence of events. Here is what happens:
    When we connect to our work SMTP server from outside the local network and without going through the VPN, the SMTP server requires password authentication. If the current SMTP selection in Mail.app is the one that does not require authentication, the SMTP server rejects the message. At that point, Mail.app opens the email I am trying to send and brings up a modal dialog that says "Cannot send message using the server xxx.xxx -- The server response was: xxx@xxx relaying prohibited. You should authenticate first." The dialog also presents a drop-down list of SMTP server choices. I choose the password-authenticated version of the server and then click on "Use Selected Server" to send the message.
    This works almost all the time, but on occasion it ends up sending a blank message! If I have a long email, particularly with attachments such as PDFs that are rendered in the body of the message, it takes a few seconds for the mail message to be rendered underneath the modal dialog box. Since I am used to this STMP rejection behavior, sometimes I am too fast to choose another STMP server from the list and click on "Use Selected Server" before the mail message is rendered on screen! The result, invariably, is a blank email message that gets sent.
    I guess what is happening is that when the STMP server rejects the message and hands it back to Mail.app, the message gets copied into a buffer in order to be displayed on screen. Selecting another server and resending it immediately (before the message is copied into the buffer completely) causes the message body to get trashed.
    I hope that this description is adequate for Apple QA folks to replicate and isolate the problem (and hopefully fix it). One solution (although not the most elegant one) would be to disable the "Use Selected Server" action until the message is copied into the buffer and rendered on screen.

    This could be related to another bug reported here recently:
    E-mail looses all images if mail server doesn't accept outgoing email...
    You cannot count on Apple looking into this or even noticing it if you report it here, so I suggest you the same I suggested in the other thread, i.e. report it in one of the following places:
    http://www.apple.com/macosx/feedback/
    http://developer.apple.com/bugreporter/

  • Unblock e-mail sender

    I don't know if this is the appropriate forum, but I have a problem.   I recently inadvertently block a e-mail sender.  How can I unblock the sender?
    This question was solved.
    View Solution.

    Wayne, not a problem.  We were all new to the game at one time or another.
    Here are the instructions for removing a sender from the Blocked List in Windows Live Mail:
    Remove an Address from Blocked Senders in Windows Live Mail or Windows Mail
    To allow a sender's messages back to your Windows Live Mail or Windows Mail Inbox:
    In Windows Live Mail:Select Actions | Junk e-mail | Safety options… from the menu. Press Alt if you cannot see the menu.
    In Windows Mail:Select Tools | Junk E-mail Options... from the menu.
    Go to the Blocked Senders tab.
    Highlight the address or domain you want to delete from the list.
    Click Remove.
    Please click "KUDOS" if I have helped you and click "Accept as Solution" if your problem is solved.
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

  • PO mail output sender set as po release person, how to changet mail sender?

    Hi expert
    Now we setup po mail output. But we found when po released, the release person become the po mail sender. this is not we wanted. We checked with sap, they mentioned this is current sap logic. there is one function which need add some program , but sap doesn't support it.
    So we hope to check if there is any user exit, We hope to select purhcase group id 's mail address as po mail sender, But which user exit could work for this po output send? 
    Thanks
    Alice

    Hi....
    Did you get any solution to your problem ? If yes, can you please share the same with me ?
    I have a similar requriement from my customer, but am not able to figure out how to do this.
    Thanks in advance,,,,,Devendra

  • Mail sending probelm

    hi experts
    I want to  send 2 attachments(.XLS) to email ,through the function module 'SO_DOCUMENT_SEND_API1' can any 1 guide me through step by step procedure.
    regards
    PRASUN

    hi check this example..
    REPORT  ZMAIL.
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver .
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      data: ld_store(50) type c.  "Leading zeros
      CONSTANTS: con_cret(5) TYPE c VALUE '0D',  "OK for non Unicode
                 con_tab(5) TYPE c VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
    *Modification to retain leading zeros
      inserts code for excell REPLACE command into ld_store
      =REPLACE("00100",1,5,"00100")
        concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
                                 wa_charekpo-ebelp '")' into ld_store .
      concatenate ld_store into .xls file instead of actual value(ebelp)
        CONCATENATE wa_charekpo-ebeln ld_store  wa_charekpo-aedat wa_charekpo-matnr  INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           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.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    regards,
    venkat

  • Mail sends itself.

    This is something new.  My mail sends itself, multiple times, before I've finished writing.  What's the deal? 
    Thank you.

    What does “I have 4 x Outbox.mbox” mean? Where is each of them? There is no way you could have more than one Outbox.mbox in ~/Library/Mail/Mailboxes/...
    Anyway, this problem in Mail is caused by some index corruption (which in turn might be caused by some filesystem corruption) that makes messages to randomly appear in a mailbox different from where they’re supposed to be. If that mailbox happens to be Outbox, Mail thinks they’re waiting to be sent and dutifully proceeds to try to send them.
    Verify/repair the startup disk (not just permissions), as described here:
    The Repair functions of Disk Utility: what's it all about?
    After having fixed all the filesystem issues, if any, and ensuring that there’s enough space available on the startup disk (a few GB, plus the space needed to make a backup copy of the Mail folder), try this:
    1. Quit Mail if it’s running.
    2. In the Finder, go to ~/Library/Mail/. Make a backup copy of this folder, just in case something goes wrong, e.g. by dragging it to the Desktop while holding the Option (Alt) key down. This is where all your mail is locally stored.
    3. Locate Envelope Index and move it to the Trash. If you see any other “Envelope Index”-named file there, delete it as well.
    4. Open Mail. It will tell you that your mail needs to be “imported”. Click Continue and Mail will proceed to re-create Envelope Index — Mail says it’s “importing”, but it just re-creates the index if the mailboxes are already in Mail 2.x format.
    Note: For those not familiarized with the ~/ notation, it refers to the user’s home folder. That is, ~/Library is the Library folder within the user’s home folder, i.e. /Users/username/Library.

Maybe you are looking for