How to use UTL_SMTP to send email with existing file attachment

Hello! I am trying to create a pl/sql procedure that lets me send an email and include an existing file to a email address. So far, I found information on how to send a file and create an attachment with information I put in the procedure. This is NOT what I'm trying to do. I'm trying to send an email and include an attachment for a file that already exists. I need the pre-existing file to be sent to the email recipient.
This is how far I've gotten, but this only allows me to CREATE an attachment with the information I put in it from the procedure. I got it from the following site:
http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
DECLARE
   v_From       VARCHAR2(80) := '[email protected]';
   v_Recipient  VARCHAR2(80) := '[email protected]';
   v_Subject    VARCHAR2(80) := 'Weekly Invoice Report';
   v_Mail_Host  VARCHAR2(30) := 'mail.mycompany.com';
   v_Mail_Conn  utl_smtp.Connection;
   crlf         VARCHAR2(2)  := chr(13)||chr(10);
BEGIN
  v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
  utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
  utl_smtp.Mail(v_Mail_Conn, v_From);
  utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
  utl_smtp.Data(v_Mail_Conn,
    'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: '   || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: '     || v_Recipient || crlf ||
    'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'This is a test'|| crlf ||     -- Message body
    'of the email attachment'|| crlf ||
    crlf ||
    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    ' name="ap_inv_supplier_cc10.txt"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="ap_inv_supplier_cc10.txt"'|| crlf ||
    crlf ||
    'TXT,file,attachment'|| crlf ||     -- Content of attachment  (THIS IS MY PROBLEM!  I NEED TO BE ABLE TO ATTACH AN EXISTING FILE, NOT CREATE A NEW ONE)
    crlf ||
    '-------SECBOUND--'               -- End MIME mail
  utl_smtp.Quit(v_mail_conn);
EXCEPTION
  WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
    raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
END;
/

First, you must create a directory object
create directory ORALOAD as '/home/ldcgroup/ldccbc/'
/Study the Prerequisites in the link I posted above, or else you will not be able to read/write files from the above directory object
"fname" relates to the file name that you read from.
In the code below, it is also the name of the file that you are attaching.
Although they can be different!
l_Output is the contents of the file.
declare
vInHandle  utl_file.file_type;
flen       number;
bsize      number;
ex         boolean;
l_Output   raw(32767);
fname      varchar2(30) := 'ap_inv_supplier_cc10.txt';
vSender    varchar2(30) := '[email protected]';
vRecip     varchar2(30) := '[email protected]';
vSubj      varchar2(50) := 'Weekly Invoice Report';
vAttach    varchar2(50) := 'ap_inv_supplier_cc10.txt';
vMType     varchar2(30) := 'text/plain; charset=us-ascii';
begin
  utl_file.fgetattr('ORALOAD', fname, ex, flen, bsize);
  vInHandle := utl_file.fopen('ORALOAD', fname, 'R');
  utl_file.get_raw (vInHandle, l_Output);
  utl_file.fclose(vInHandle);
  utl_mail.send_attach_raw(sender       => vSender
                          ,recipients   => vRecip
                          ,subject      => vsubj
                          ,attachment   => l_Output
                          ,att_inline   => false
                          ,att_filename => fname);
end;
/

Similar Messages

  • How to use FM SO_DOCUMENT_REPOSITORY_MANAGER send mail with CC.

    Dear Experts:
    Please help me. How to use FM SO_DOCUMENT_REPOSITORY_MANAGER send mail with CC.
    My Program code is as follow:
    *Send the mail.
    tb_receipients-recnam = 'BAITZ'.
    tb_receipients-recesc = 'B'.
    tb_receipients-sndex = 'X'.
    tb_receipients-att_fix ='X' .
    APPEND  tb_receipients.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
      EXPORTING
        method       = wa_method1
        office_user  = wa_owner
        ref_document = wa_ref_document
        new_parent   = wa_new_parent
      IMPORTING
        authority    = wa_authority
      TABLES
        objcont      = tb_objcnt
        objhead      = tb_objhead
        objpara      = tb_objpara
        objparb      = tb_objparb
        recipients   = tb_receipients
        attachments  = tb_attachments
        references   = tb_references
        files        = tb_files
      CHANGING
        document     = wa_document
        header_data  = wa_header.
    endform.                    " send_mail
    By the why, tb_receipients-recnam = 'BAITZ'. What's the meaning of 'BAITZ'? Thanks!

    you can use FM SO_NEW_DOCUMENT_SEND_API1
    WA_RECV TYPE SOMLRECI1,
    IT_RECV TYPE STANDARD TABLE OF SOMLRECI1.
    wa_recv-receiver = 'TO email address'.
    wa_recv-rec_type = 'U'.
    wa_recv-com_type = 'INT'.
    APPEND wa_recv TO it_recv.
    CLEAR wa_recv."To Recipient
    wa_recv-receiver = 'CC email address'.
    wa_recv-rec_type = 'U'.
    wa_recv-com_type = 'INT'.
    wa_recv-copy = 'X'.
    APPEND wa_recv TO it_recv.
    CLEAR wa_recv. "CC Recipient
    wa_recv-receiver = 'BCC email address'.
    wa_recv-rec_type = 'U'.
    wa_recv-com_type = 'INT'.
    wa_recv-blind_copy = 'X'.
    APPEND wa_recv TO it_recv.
    CLEAR wa_recv. "BCC Recipient

  • Shell Script to send email with .txt file as attachment

    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!

    978334 wrote:
    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!http://bit.ly/XHfSCz
    https://forums.oracle.com/forums/search.jspa?threadID=&q=sendmail&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Sending mail with PDF file attachment ?

    Hi All,
    I have scenario File ---> Mail, monitoring FTP directory for PDF file and sending using mail attachment.
    At the moment i am using JAVA mapping to construct the mail package structure follow all the step in this blog : XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping
    it is working if i am using text file but then how to encode the pdf content so i can send throught the mail adapter. ?
    Thank you and Best Regards
    Fernand

    Hi,
    Actually, i am using this java code below :
    try {
        //     create XML structure of mail package
        String output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
               + "<ns:Mail xmlns:ns=\"http://sap.com/xi/XI/Mail/30\">"         
               + "<Subject>" + mailSubject     + "</Subject>"
               + "<From>" + mailSender     + "</From>"
               + "<To>" + mailReceiver     + "</To>"
               + "<Content_Type>multipart/mixed; boundary=\"" + boundary + "\"</Content_Type>"
               + "<Content>";
        out.write(output.getBytes());
        // create the declaration of the MIME parts
        //First part
        output = "--" + boundary + CRLF
               + "Content-Type: text/plain; charset=UTF-8" + CRLF
               //+ "Content-Transfer-Encoding: 8bit" + CRLF
               + "Content-Disposition: inline" + CRLF + CRLF
               + mailContent + CRLF
        //Second part
        + "--" + boundary + CRLF
        + "Content-Type: Application/pdf; name=" + attachmentName + CRLF  
        //+ "Content-Transfer-Encoding: base64" + CRLF
        + "Content-Disposition: attachment; filename=" + attachmentName + CRLF + CRLF;
        out.write(output.getBytes());
        //Source is taken as attachment
        copySource(in, out);
        out.write("</Content></ns:Mail>".getBytes());
      } catch (IOException e) {
        throw new StreamTransformationException(e.getMessage());
    protected static void copySource(InputStream in, OutputStream out)
         throws IOException {
        byte[] bbuf = new byte[in.available()];
        int bblen = in.read(bbuf);
        if (!(bblen < 0)) {
          //String sbuf = new String(bbuf);
          //String encoded = Base64.encode(sbuf);
          // replace all control characters with escape sequences
          //sbuf = sbuf.replaceAll("&", "&amp;");
          //sbuf = sbuf.replaceAll("\"", "&quot;");
          //sbuf = sbuf.replaceAll("'", "&apos;");
          //sbuf = sbuf.replaceAll("<", "&lt;");
          //sbuf = sbuf.replaceAll(">", "&gt;");
          out.write(bbuf);
    This code working fine with text file but not for pdf file. because i got error in mail adapter :
    Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: com.sap.aii.messaging.util.XMLScanException: java.lang.NullPointerException; nested exception caused by: com.sap.engine.lib.xml.parser.NestedSAXParserException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Unsupported character: 8f(:main:, row:11, col:4)(:main:, row=11, col=4) -> com.sap.engine.lib.xml.parser.ParserException: Unsupported character: 8f(:main:, row:11, col:4)
    I guest the problem because the mail adapter doen't accept pdf content insite the mail package.
    please advise me
    Best Regards
    Fernand

  • How to use java to send emails

    Hi,
    I am having problems trying to send an email using java. No idea what is going on because it looks fine. Can anyone give any insight?
    Cheers
    Robert
    import java.awt.event.*;
    import java.awt.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.*;
    * JEmail.java
    * @author Robert Venning 18/09/2005
    * @version 1.0
    public class JEmail extends JFrame implements ActionListener{
         private static final long serialVersionUID = 1L;
         final int SMTP_PORT = 25;
         JLabel fromLabel = new JLabel("From: ");
         JLabel toLabel = new JLabel("To: ");
         JLabel ccLabel = new JLabel("CC: ");
         JLabel subjectLabel = new JLabel("Subject: ");
         JTextField from = new JTextField(20);
         JTextField to = new JTextField(20);
         JTextField cc = new JTextField(20);
         JTextField subject = new JTextField(20);
         JTextArea message = new JTextArea(10,30);
         JScrollPane scrollPane = new JScrollPane(message);
         JButton send = new JButton("Send");
         public JEmail(){
              super("Email Program");
              JPanel mainPane = new JPanel();
              JPanel pane = new JPanel();
              JPanel fromPane = new JPanel();
              JPanel toPane = new JPanel();
              JPanel ccPane = new JPanel();
              JPanel subjectPane = new JPanel();
              mainPane.setLayout(new FlowLayout());
              pane.setLayout(new GridLayout(4,1));
              fromPane.add(fromLabel);
              fromPane.add(from);
              toPane.add(toLabel);
              toPane.add(to);
              ccPane.add(ccLabel);
              ccPane.add(cc);
              subjectPane.add(subjectLabel);
              subjectPane.add(subject);
              pane.add(fromPane);
              pane.add(toPane);
              pane.add(ccPane);
              pane.add(subjectPane);
              mainPane.add(pane);
              mainPane.add(scrollPane);
              mainPane.add(send);
              setContentPane(mainPane);
              send.addActionListener(this);
         public static void main(String[] args) {
              JFrame aFrame = new JEmail();
              aFrame.setSize(350, 400);
              aFrame.setVisible(true);
         public void actionPerformed(ActionEvent event){
              try{
                   PrintWriter writer = new PrintWriter(new FileWriter("log.txt"));
                   String input, output;
                   Socket s = new Socket("mail.tpg.com.au", SMTP_PORT);
                   BufferedReader in = new BufferedReader
                        (new InputStreamReader(s.getInputStream()));
                   BufferedWriter out = new BufferedWriter
              (new OutputStreamWriter(s.getOutputStream()));
                   output = "HELO theWorld" + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   input = in.readLine();
                   System.out.println(input);
         //          writer.println(input);
                   output = "MAIL FROM: <" + from.getText() + ">" + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   input = in.readLine();
                   System.out.println(input);
         //          writer.println(input);
                   output = "RCPT TO: <" + to.getText() + ">" + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   input = in.readLine();
                   System.out.println(input);
              //     writer.println(input);
                   output = "DATA" + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   input = in.readLine();
                   System.out.println(input);
              //     writer.println(input);
                   output = "Subject: " + subject.getText() + "\n";
                   out.write(output);
                   out.flush();
              System.out.print(output);
              writer.println(output);
              output = "From: Robert Venning <" + from.getText() + ">" + "\n";
                   out.write(output);
                   out.flush();
              System.out.print(output);
              writer.println(output);
                   // message body
              output = message.getText() + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   output = ".\n";
                   out.write(output);
                   out.flush();
                   System.out.println(output);
                   writer.println(output);
                   output = "QUIT" + "\n";
                   out.write(output);
                   out.flush();
                   System.out.print(output);
                   writer.println(output);
                   input = in.readLine();
                   System.out.println(input);
         //          writer.println(input);
                   writer.close();
                   s.close();
              catch(Exception exception){
                   exception.printStackTrace();
    }

    Hi, floppit. For sending emails, I used the JavaMail API. Here is some code I wrote where I used JavaMail. The most relevant lines are in bold.
    /*   File:  ListenNotifier.java
    * Author:  Fabricio Machado
    *          [email protected]
    * This utility is based on the "Listen.java" tool from the Tiny OS
    * java tools package, in /tinyos-1.x/tools/java/net/tinyos/tools/.
    * The original application has been extended to convert raw packet data into
    * a more meaningful representation of actual photo sensor readings in
    * lux.
    * The application checks the readings against a user-defined
    * threshold, and sends email notifications when readings break the
    * threshold, and also when readings dip back below the threshold.
    * Currently, the code is only fit to handle packets from the Tiny OS
    * nesc application OscilloscopeRF.nc.  The code gets the packet data
    * by connecting via TCP to a Tiny OS java tool called "Serial Forwarder."
    * "Serial Forwarder" takes packets from the base station, and forwards
    * them to TCP port 9001.
    * Below is UC Berkeley's copyright disclaimer regarding the original code.
    *                              |   |
    *                              |   |
    *                              |   |
    *                              |   |
    *                            __|   |__
    *                                v
    * "Copyright (c) 2000-2003 The Regents of the University  of California. 
    * All rights reserved.
    * Permission to use, copy, modify, and distribute this software and its
    * documentation for any purpose, without fee, and without written agreement is
    * hereby granted, provided that the above copyright notice, the following
    * two paragraphs and the author appear in all copies of this software.
    * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
    * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
    * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
    * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
    * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
    * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
    * Copyright (c) 2002-2003 Intel Corporation
    * All rights reserved.
    * This file is distributed under the terms in the attached INTEL-LICENSE    
    * file. If you do not find these files, copies can be found by writing to
    * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
    * 94704.  Attention:  Intel License Inquiry.
    import java.util.Properties;
    import java.io.*;
    import java.net.*;
    import net.tinyos.packet.*;
    import net.tinyos.util.*;
    import net.tinyos.message.*;
    import javax.mail.internet.*;
    import javax.mail.*;
    import java.util.*;
    public class ListenNotifier{
        public static void main(String args[]) throws IOException, MessagingException {
         int i;
         int j = 0;
         Integer threshold=0;
         String to="";
         String timeStamp;
         // Check to see if user is running the program correctly.
         // If -T option is not used, a default value of 250 lux is
            // set as threshold . . .
         switch (args.length){
         case 0:
               System.err.println("usage: java ListenNotifier < EmailAddress1 > <  EmailAddress2 > . . .  -T < Threshold >\n");
               System.exit(2);
               break;
         case 1:
             to = args[j];
             threshold = 250;
             break;
         default:
             if (args[args.length-2].equals("-T")){
              threshold = threshold.valueOf(args[args.length-1]);
              to = args[0];
              while(!args[j+1].equals("-T")){
                  to = to + " " + args[j+1];
                  j++;
              break;
             else{
              j = 0;
              threshold = 250;
              to = args[j];
              while((j + 1) < args.length){
                  to = to + " " + args[j+1];
                  j++;
              System.out.printf("Mailing list is: %s\n", to);
              break;
         // Connect to the Serial Forwarder on TCP port 9001 . . .
             PacketSource reader = BuildSource.makeSF("192.168.0.12",9001);
         // Check to see if connection to Serial Forwarder successful . . .
         if (reader == null) {
             System.err.println("Invalid packet source (check your MOTECOM environment variable)");
             System.exit(2);
         try {
             // Use JavaMail API methods to set up an
             // email session . . .
          Properties props = System.getProperties();
         Session session = Session.getInstance(props, null);
         javax.mail.Message message = new MimeMessage(session);
             // Open the packet source . . .
             reader.open(PrintStreamMessenger.err);
             // Set a threshold boolean to be used so
             // email is sent only once after threshold
             // is exceeded.
             Boolean limit = false;
             for (;;) {
              // The node ID field in the OscilloscopeRF packet
              // is 2 bytes long, but all byte pairs in the packet
              // are in little endian order.  Thus, the bytes must
              //  be re-ordered.  They are then converted to unsigned
              // integers and added together to obtain the node ID.
              byte[] packet = reader.readPacket();
              Integer nodeID = (( int ) packet[5] & 0xFF) + ((( int ) packet[6] & 0xFF)<<8);
              System.out.printf("Packet from node %d . . . \n", nodeID);
              // Begin extracting data payload of sensor readings,
                    // which are stored in the last 20 bytes of the packet . . .
             for (i = 0; i <= 9; i++){
              // Convert reading to integer, display on screen . . .
              Integer sensorData = (( int ) packet[(2*i)+11] & 0xFF) + ((( int ) packet[(2*i)+12] & 0xFF)<<8);
              System.out.printf("Sample %d reading at %d lux.\n", i+1, sensorData);
              // Is sensor reading  above limit?
              if(!limit && (sensorData >= threshold)){
                  limit = true;
                  System.out.printf("WARNING: SENSOR READING ABOVE THRESHOLD--SENDING NOTICE BY TEXT MESSAGE.\n");
                  // Compute a time stamp for when threshold was exceeded.
                  java.util.Locale locale = Locale.getDefault();
                  java.text.DateFormat dateFormat = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,
                                                                  java.text.DateFormat.LONG, locale);
                  timeStamp = dateFormat.format(new java.util.Date());
                  // Build message and send to recipients in mailing list . . .
                  message.setFrom();
              message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to, false));
              message.setSubject("WARNING: NODE " + nodeID.toString() + " SENSOR READING ABOVE THRESHOLD!");
              message.setText("Node " + nodeID.toString() + " sensed " + sensorData.toString() + " lux on " + timeStamp + "\n");
              Transport.send(message);
                  System.out.printf("%s\n",timeStamp);
              //  Has sensor reading now dropped from above threshold to below threshold?
              //  Same concept as before . . .
              if(limit && (sensorData < threshold)){
                  limit = false;
                  System.out.printf("READING BELOW THRESHOLD AGAIN . . . SENDING NOTICE BY TEXT MESSAGE.\n");
                  java.util.Locale locale = Locale.getDefault();
                  java.text.DateFormat dateFormat = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG,
                                                                  java.text.DateFormat.LONG, locale);
                  timeStamp = dateFormat.format(new java.util.Date());
                  message.setFrom();
              message.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to, false));
              message.setSubject("NODE " + nodeID.toString() + " READING BELOW THRESHOLD AGAIN.");
              message.setText("Node " + nodeID.toString() + " sensed " + sensorData.toString() + " lux on " + timeStamp + "\n");
              Transport.send(message);
                  System.out.printf("%s\n",timeStamp);
             System.out.println();
             System.out.flush();
         // Catch IOException from Tiny OS java method, and
         // MessagingException from setRecipients method in JavaMail API . . .
         catch (IOException e) {
             System.err.println("Error on " + reader.getName() + ": " + e);
         catch(MessagingException e){
         System.err.println("Error in javax.mail.message.setRecipients:\n" + to);
    }

  • SEND EMAIL WITH PO AND ATTACHMENT FILES

    Hi,
    I'm working with MySAP Enterprise 4.7 and I want to send the PO and its attachment vía e-mail, currently only the PO is being sent to the Vendor and the attachment only appears like texts into the "body" of PO. Is there some way to send e-mail with the PO and attachments at the same time??
    I attached the document via DMS at position level.
    Thanks in advanced for your answer and help!!
    Regards,
    Blanca Reyes

    hi
    Follow these steps
    Basically there are two mail types: Internet mail (external mail) and
    SAPOffice mail.
    Mail is sent via the output determination in both cases.
    If you use the external mail, the message for the purchasing document is
    converted into a corresponding text file which is sent to the vendor via
    the Internet.
    SAPOffice mail is sent only within the R/3 System and has mainly the
    function of providing information.
    In particular, it is not possible to attach a message (form) for a
    purchasing document to a SAPOffice mail.
    When using external mail, the following basic settings are required:
    1. You must maintain an e-mail address in the address in the vendor
    master.
    2. The same applies to your own user master. You also have to specify
    an e-mail address there in order to identify the sender.
    o Note that it is not possible to change the e-mail address of the endor
    o You can use a temporary email address in Transaction ME21N.
    3. For the output type for default values, a communication strategy
    needs to be maintained in the Customizing that supports the e-mail.
    You can find the definition of the communication strategy in the
    Customizing via the following path: (SPRO -> IMG -> SAP Web
    Application Server -> Basic Services -> Message Control -> Define
    Communication Strategy). As a default, communication strategy CS01
    is delivered. This already contains the necessary entry for the
    external communication. Bear in mind that without a suitable
    communication strategy it is not possible to communicate with a
    partner via Medium 5 (external sending).
    4. Use the standard SAP environment (program 'SAPFM06P', FORM routine
    'ENTRY_NEU' and form 'MEDRUCK') as the processing routines.
    5. In the condition records for the output type (for example,
    Transaction MN04), use medium '5' (External send).
    6. You can use Transaction SCOT to trigger the output manually. The
    prerequisite for a correct sending is that the node is set
    correctly. This is not described here, but it must have already been
    carried out.
    7. To be able to display, for example, the e-mail in Outlook, enter PDF
    as the format in the node.
    To use the SAPOffice mail, the following basic settings are required:
    1. For the output type for default values, a communication strategy
    needs to be maintained in the Customizing that supports the e-mail.
    You can branch to the maintenance of the communication strategy via
    the input help.
    2. Use the SAP standard environment (program "RSNASTSO" and FORM
    routine "SAPOFFICE_AUFRUF") as the processing routines.
    3. In the condition records for the output type (for example,
    Transaction MN04), use medium '7' (SAPOffice) and also partner role
    'MP' (mail partner).
    Additional settings:
    Problem:
    How can you both change the mail title and text for the sending of a
    mail message and maintain a replacement parameter, for example a
    document number.
    Solution:
    1. The replacement routine is maintained in the Customizing for the
    output type in the detail screen on the 'General data' tab under
    'Replacement of text symbols' (for Release < 4.6B, this can be found
    on the 'Mail' tab page).
    Program: SAPMM06E
    FORM routine: TEXT_SYMBOL_REPLACE
    2. Maintain mail title and text.
    o If you want to send a purchase order within an R/3 system using
    the SAP office, you can maintain both the mail title ('Re:') and
    also a mail text in the Customizing for the output type To do
    this, select the directory mail title and text for the
    corresponding message type.
    o If you want to send a purchase order as (external) mail, for
    example, to a vendor, you have to maintain the mail title in the
    condition record for the output type (for example in Transaction
    MN05) on the 'Communication method' tab page. Enter the mail
    title in the 'Text for cover page' field. You cannot maintain an
    additional mail text.
    o Note that the values from the mail title are used to create the
    description for the attachment.
    3. The replacement parameters must be enclosed by &. Example: You want
    to enter the title 'PO number '. For this you have to enter
    the following in the Document Title field (Message Customizing ->
    sub-option: Mail title and texts) 'PO number &EKKO-EBELN&'
    Reward points if helpful
    regards
    chetan

  • Sending email with report as attachment

    Dear folks,
    I'm using [this |http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html] package to send emails through database, and it works.
    My question is: how to attach report to email which is sent by this package?
    Any help on this would be highly appreciated.
    Regards,
    Adnan

    adnanBIH wrote:
    Dear folks,
    I'm using [this |http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html] package to send emails through database, and it works.
    My question is: how to attach report to email which is sent by this package?
    Any help on this would be highly appreciated.
    Regards,
    AdnanDear Adnan. I've written a blog post on this subject. You can view it from the following link:
    http://kamranagayev.wordpress.com/2009/02/23/using-oracle-utl_file-utl_smtp-packages-and-linux-shell-scripting-and-cron-utility-together-2/

  • Bug sending email with Excel file (immediate reply would he helpfull)

    Hi ,
       Below is have pasted a sample code where it will sends a email along with an attachtment (xls) .where the email is working perfectly but the xls file attachtment has a blank space in the first line .
    where iam facing the problem ,
    ie there should not be any blank lines at the top .
    Please run the code one i have pasted below .u can find the bug .
    can any one help me on this .
    please have ur mail id in ( reclist-receiver ) so that u can check for the output.
    This table requires information about how the data in the
    tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
    to be distributed to the documents and its attachments.
    DATA: objpack LIKE sopcklsti1 OCCURS  2 WITH HEADER LINE.
    This table must contain the summarized data dependent on each object type.
    SAPscript objects store information here about forms and styles,
    for example. Excel list viewer objects store the number of rows and columns
    amongst other things and PC objects store their original file name.
    DATA: objhead LIKE solisti1   OCCURS  1 WITH HEADER LINE.
    *CREATION OF INTERNAL TABLE
    DATA : BEGIN OF itobjbin OCCURS 10 ,
           vbeln type vbrp-vbeln,
           matnr type vbrp-matnr,
           werks type vbrp-werks,
           fktyp like vbrk-fktyp,
           END OF itobjbin .
    This table must contain the summarized content of the objects identified as binary objects.
    *DATA: OBJBIN  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
    DATA:   objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                   WITH HEADER LINE.
    DATA: wa_itobjbin LIKE itobjbin .
    This table must contain the summarized content of the objects identified as ASCII objects.
    DATA: objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
    This table must contain the document recipients.
    DATA: reclist LIKE somlreci1  OCCURS  5 WITH HEADER LINE.
    This structure must contain the attributes of the document to be sent.
    DATA: doc_chng LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    DATA : V_FKTYP LIKE VBRK-FKTYP.
    Creating the document to be sent
    doc_chng-obj_name = 'OFFER'.                      " input contains the attributes of the document to be sent
    doc_chng-obj_descr = 'EMAIL WITH EXCEL DOWNLOAD'.   "input contains title/subject of the document
    *BODY OF THE MAIL
    OBJTXT = 'Hi'.
    APPEND OBJTXT .
    OBJTXT = 'Test for excel download'.
    APPEND OBJTXT.
    OBJTXT = 'Below is the attachment with Billing Document Details'.
    APPEND OBJTXT.
    OBJTXT = 'Regards'.
    APPEND OBJTXT.
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    Creating 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.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    select vbeln matnr werks
            from vbrp into table itobjbin
            up to 10 rows
            where werks GE '1000'.
    loop at itobjbin.
    select single fktyp into  v_fktyp from vbrk where vbeln = itobjbin-vbeln.
    move v_fktyp to itobjbin-fktyp.
    modify itobjbin.
    endloop.
    PERFORM build_xls_data_table .
    DESCRIBE TABLE objbin LINES tab_lines.
    objhead = 'ABC.XLS'. APPEND objhead.
    Creating 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   = 'XLS'.
    objpack-obj_name   = 'ATTACHMENT'.
    objpack-obj_descr = 'XLS'.
    objpack-doc_size   = tab_lines * 255.
    APPEND objpack..
    Entering names in the distribution list
    reclist-receiver = ''.
    reclist-rec_type = 'U'.
    APPEND reclist.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              document_data = doc_chng
              put_in_outbox = 'X'
              commit_work   = 'X'
         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.
    CASE sy-subrc.
      WHEN 0.
        WRITE: / 'Result of the send process:'.
        LOOP AT reclist.
          WRITE: / reclist-receiver(48), ':'.
          IF reclist-retrn_code = 0.
            WRITE 'sent successfully'.
          ELSE.
            WRITE 'not sent'.
          ENDIF.
        ENDLOOP.
      WHEN 1.
        WRITE: / 'no authorization to send to the specified number of',  'recipients!'.
      WHEN 2.
        WRITE: / 'document could not be sent to any of the recipients!'.
      WHEN 4.
        WRITE: / 'no authorization to send !'.
      WHEN OTHERS.
        WRITE: / 'error occurred during sending !'.
    ENDCASE.
    *&      Form  build_xls_data_table
          text
    -->  p1        text
    <--  p2        text
    FORM build_xls_data_table .
    CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
               con_tab TYPE x VALUE '09'.   "OK for non Unicode
    CONCATENATE 'Billing Document' 'Material Number' 'Plant' 'Billing category' ' ' INTO objbin SEPARATED BY con_tab.
    CONCATENATE con_cret objbin  INTO objbin.
    APPEND  objbin.
    LOOP AT itobjbin  .
       CONCATENATE itobjbin-vbeln itobjbin-matnr itobjbin-werks itobjbin-fktyp' '
              INTO objbin SEPARATED BY con_tab.
       CONCATENATE con_cret objbin  INTO objbin.
       APPEND  objbin.
    ENDLOOP.
    thanks in advance,
    vinay .

    Hi ravi ,
         Thanks ,for your help .now xls is working fine .
    but now iam facing a problem with the same function module .for txt files .where all the records are formated in asingle line .
    can u provide a solution for this ,which would be very helpfull.
    below is have attached the sample code .
    Thanks,
    vinay.
    FUNCTION Z_KAILASH_ATTACHMENT1.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(EMAILID)
    *"     VALUE(SUBJECT)
    *"     VALUE(ATYPE)
    *"  TABLES
    *"      ATTACH_FILE STRUCTURE  SOLISTI1
    *"      BODY OPTIONAL
    This table requires information about how the data in the
    tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
    to be distributed to the documents and its attachments.
      DATA OBJPACK LIKE SOPCKLSTI1 OCCURS  2 WITH HEADER LINE.
    This table must contain the summarized data dependent on each object type.
    SAPscript objects store information here about forms and styles,
    for example. Excel list viewer objects store the number of rows and columns
    amongst other things and PC objects store their original file name.
      DATA OBJHEAD LIKE SOLISTI1   OCCURS  1 WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as binary objects.
      DATA   OBJBIN TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                     WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as ASCII objects.
      DATA OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
    This table must contain the document recipients.
      DATA  RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE .
    This structure must contain the attributes of the document to be sent.
      DATA: DOC_CHING LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
    Create the internal table for body , subject
      DATA: IT_BODY LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
               con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
    Move Body to Internal Table (body into it_body)
      LOOP AT BODY .
        MOVE BODY TO IT_BODY .
        APPEND IT_BODY .
      ENDLOOP.
      DOC_CHING-OBJ_DESCR = SUBJECT.   "Subject of the Email
    Move the Subject and Body to OBJTXT
      OBJTXT[] = IT_BODY[].
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHING-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    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.
    Convert IT to Excel format
    IF ATYPE = 'XLS' .
    *CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
              con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
      LOOP AT ATTACH_FILE .
        REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_cret. "  INTO objbin.
        CONCATENATE  ATTACH_FILE con_tab INTO objbin.
        APPEND  objbin.
      ENDLOOP.
    ELSEIF ATYPE = 'TXT' .
      LOOP AT ATTACH_FILE .
        REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_tab. "  INTO objbin.
        CONCATENATE ATTACH_FILE ' '  INTO OBJBIN .
        APPEND OBJBIN .
      ENDLOOP.
    ENDIF.
    ****End-Code Excel Format .
    DESCRIBE TABLE objbin LINES tab_lines.
    objhead = subject. APPEND objhead.
    Creating 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   = ATYPE.
    objpack-obj_name   = 'ATTACHMENT'.
    objpack-obj_descr = 'TEST'. "Attachment File Name
    objpack-doc_size   = TAB_LINES * 255.
    APPEND objpack..
    reclist-receiver = EMAILID.
    reclist-rec_type = 'U'.
    APPEND reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
       DOCUMENT_DATA                    = DOC_CHING
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                     =
      NEW_OBJECT_ID                   =
      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 .
    ENDFUNCTION.

  • Send email with txt file as attachment

    Hi ,
    can any one help me in download as txt file using the function module SO_OBJECT_SEND along with email .
    a sample code using this function module would be helpfull.
    Thanks,
    vinay .

    Hi vinay,
    Not only TXT file, u can send any
    other file like word,excel,pdf,exe, etc.
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    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
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • FDM Send Email with a Report attachment

    Hi All,
    I'm currently trying to roll out a form of "Lights - Off " automation in for HFM version 9.3.3 , by using the FDM Task Manager to schedule loading information from my organisation's source system JDE.
    The final element of that automation from our perspective is to have an alert email from FDM to certain users once the 4 - Fish process is complete.
    This has worked successfully using 'Send Mail' from Accelerators, however what would be even more useful is to be able to either attach Process/Check Reports.
    I am only a beginner in VB but am willing to take steps if someone can point me in the right direction of either adding the report in the body of the email or as an attachment. I saw a great example of an email alert from Tony Scalese on the attached link
    http://www.fdmguru.com/enabling-lights-out-automation/
    Any help would be much appreciated.
    Cheers
    Pip

    I assume your familiar with the 'Send Mail' Accelerator script so i won't go into that part of it.
    As mentioned previously I opted to attach the source file and save reports on a shared drive. Therefore from the selected script below you can modify to your needs.
    Firstly I published a report (using the Report Publishing accelerator) to a specific location with a variable name (as shown in my example below) or you can give it a specific name so each time it's run it will overwrite the previously run report.
    Publish Report*
    Dim objReport
    Dim lngReportID
    Dim lngPublishType
    Dim strPublishPath
    'Initialize Variables
    lngReportID = 87          'Check Report +(You need to check the report properties for this number)+
    lngPublishType = 31          'PDF
    strPublishPath = "C:\Temp\Validation Report_"&API.POVMgr.PPOVLocation&"_"& API.POVMgr.PPOVCategory &"_"& API.POVMgr.PPOVPeriod &"_"& FormatDateTime(Date,1)&"_"&retv&".pdf"
    'Create the Report object
    Set objReport = CreateObject("upsWReportingDM.clsReportPublisher")
    objReport.mInitialize API
    'Publish the Report
    objReport.mReportPublishToFile CLng(lngReportID), CStr(strPublishPath), CLng(lngPublishType)
    'Destroy the objects
    Set objReport = Nothing
    To attach this to your email :
    .AddAttachment strPublishPath
    This should get you on your way, let me know if you encounter any issues. Also as a newbie I'd appreciate it if you can tag if this message was correct or helpful.
    Cheers
    Pips

  • Send email with existing excel-file as attachment

    Is there a function to send an e-mail with an attachment which is an existing excel-file on my C:\-drive.
    I found lots of possibilities to send mail with internal tables as attachment but in my case the attachment is an existing excel-file (c:\test.xls)...
    thanx

    Hi,
    FOund these function modules
    Try this out.
    ISR_FI_SEND_EMAIL             
    ISR_FI_SEND_EMAIL_NEW_USER    
    SLS_CUST_SEND_EMAIL_TOOL      
    OR
    report y_cr17_mail.
    data method1 like sy-ucomm.
    data g_user like soudnamei1.
    data g_user_data like soudatai1.
    data g_owner like soud-usrnam.
    data g_receipients like soos1 occurs 0 with header line.
    data g_document like sood4 .
    data g_header like sood2.
    data g_folmam like sofm2.
    data g_objcnt like soli occurs 0 with header line.
    data g_objhead like soli occurs 0 with header line.
    data g_objpara  like selc occurs 0 with header line.
    data g_objparb  like soop1 occurs 0 with header line.
    data g_attachments like sood5 occurs 0 with header line.
    data g_references like soxrl occurs 0 with header line.
    data g_authority like sofa-usracc.
    data g_ref_document like sood4.
    data g_new_parent like soodk.
    data: begin of g_files occurs 10 ,
      text(4096) type c,
       end of g_files.
    data : fold_number(12) type c,
           fold_yr(2) type c,
           fold_type(3) type c.
    parameters ws_file(4096) type c default 'c:\debugger.txt'.
    Can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    call function 'SO_USER_READ_API1'
    exporting
       user                            = g_user
       PREPARE_FOR_FOLDER_ACCESS       = ' '
    importing
       user_data                       = g_user_data
    EXCEPTIONS
       USER_NOT_EXIST                  = 1
       PARAMETER_ERROR                 = 2
       X_ERROR                         = 3
       OTHERS                          = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    clear g_files.
    refresh : g_objcnt,
      g_objhead,
      g_objpara,
      g_objparb,
      g_receipients,
      g_attachments,
      g_references,
      g_files.
    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.
    g_header-objdes =  'sap-img.com testing by program'.
    g_header-file_ext = 'TXT'.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = sy-uname
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
      FOLMEM_DATA        =
      RECEIVE_DATA       =
    File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    append g_files.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
    method1 = 'SEND'.
    g_receipients-recnam = 'MK085'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    append  g_receipients.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header.
    *-- End of Program
    Thanks & Regards,
    Judith.

  • Email with Text File Attachement as Source

    Hi All,
           One of my interfaces needs to listen to incoming mails with an text file attachements.I wish to know how we can convert the text file contents into XML to further process it on the reciever side.

    Hi,
    To perform content conversion of a flat file, check these blogs,
    /people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    Also, to understand file content conversion better, you can check this link on SAP Help,
    http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm
    Regards,
    Bhavesh

  • How to use my non-iCloud email with iCloud calendar events

    Is there a way to use my regular email address (non iCloud) to receive iCloud invites?
    My contacts don't know my iCloud account, they only know my regular email address so they will send messages, calendar invites, etc to my regular email which is not my iCloud account.
    Although I can accept invites to any account, there isn't the same level of integration with iOS and OS X apps that you get when the invite is sent to an iCloud account. (i.e. they don't appear in Calendar, you have to accept them from an email and it sends you off to iCloud.com) or you have to download the .ics file to add it, etc.
    Is there a way to link that regular email address to my iCloud account so that invites and messages to that email are treated as though they were sent to my regular iCloud account and I can accept, reject directly from the calendar applications on either my iOS or OS X device?
    Thanks!

    You can sign in with your @me.com address in System Preferences>iCloud and check Mail in the checklist there - this will reactivate the address, though you will not be able to retrieve any data previously stored on MobileMe.

  • Sending email with an excel attachment

    Hi,
    I have designed one workflow for PO approval .For the release code 01 i am displaying the one custom report to the approver .
    Now the requirement is after release of the code 01 i have to download this custom  report into excel format and i have to send this excel sheet to the vendor email id through workflow .
    Please can any one give me how to achieve this functionality of downloading the report and sending this to vendor in background task.
    Regards
    Pavee

    You can make use of FM
    SO_NEW_DOCUMENT_ATT_SEND_API1
    For use of this FM try to search with this FM as keyword in ABAP Forum.
    Thanks
    Arghadip

  • Send email with microsoft word attachment

    Hi,
    I need to send the microsoft word as an attachment to external email.  When I send an email using transaction SBWP to external email, the recipient will receive the attachment in Microsoft word format.  But when I send the attachment to external email using my program,  the Microsoft word automatic change to pdf.  Kindly help.  Attach is my sample program.
    *&      Form  send_email
    FORM send_email .
      LOOP AT raw_tab.
        MOVE raw_tab-l TO it_attach-line.
        APPEND it_attach.
      ENDLOOP.
      WRITE 'Test' TO w_doc_data-OBJ_DESCR.
      perform get_packing.
      perform populate_email_message_body.
      perform receiver.
      lt_objhead = 'TEST'.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
        IMPORTING
          sent_to_all                = w_sent_all
        TABLES
          packing_list               = t_packing_list
          object_header              = lt_objhead
          contents_bin               = it_attach
          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.
      COMMIT WORK AND WAIT.
    ENDFORM.                    " send_email
    *&      Form  get_packing
    FORM get_packing .
    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-body_num = t_packing_list-body_num.
      t_packing_list-doc_type = 'TXT'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_attach LINES body_num2.
      t_packing_list-body_num = body_num2.
      t_packing_list-doc_type   =  'DOC'.
      t_packing_list-obj_descr  =  'TXT attachment'.
      t_packing_list-obj_name   =  'ATTACHMENT'.
      DOC_SIZE2 = ( ( body_num2 - 1 ) * 255 ) + STRLEN( it_message ).
      t_packing_list-doc_size   = doc_size2.
      APPEND t_packing_list.
    ENDFORM.                    " get_packing
    *&      Form  populate_email_message_body
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Testing program'.
      APPEND it_message.
    ENDFORM.                    " populate_email_message_body
    *&      Form  receiver
    FORM receiver .
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      t_receivers-receiver = [email protected]'.
      APPEND t_receivers. clear t_receivers.
    ENDFORM.                    " receiver

    just pass mail Id and the Pc file path of word doc in the selection screen of the below program ,it will send it as word attachment to the recepient.pls reward points if helpfull -
    REPORT  ZGILL_SENDMAIL_PDF                      .
    INCLUDE ZGILL_INCMAIL.  "SEE BELOW FOR INCLUDE PROGRAM CODE.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case DEFAULT '[email protected]'.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY DEFAULT 'C:\TEMP\SALARY_SLIP1.PDF'.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    *********************iNCLUDE pROGRAM********************************************
    *&  Include           ZGILL_INCMAIL                                    *
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    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
    IF sy-subrc <> 0.
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    **********************INCLUDE END********************************

Maybe you are looking for

  • Are we able to print weeks (rather than a whole month) in iCal?

    I would like to print weeks rather than months. Is it possible?

  • Error occurs in accessing producer content in federated portal network

    Hi I am trying to access my bi iViews in the enterprise portal using federated portal approach. we are having BI portal(Netweaver 2004s sp15) and Enterprise portal(Netweaver 2004s sp09).I am able to create iViews in BI portal using default system SAP

  • User Decision in Workflow

    Hi All, When I use the User Decision Step in Workflow, then If I mention two Outcome Text, then at runtime it shows three by adding Cancel and keep. Now, if I click on Cancel and Keep it in Inbox, then the execution go furthur. How to cancel the exec

  • UD for Good Issues

    Hello, I am an MM and need some helps for UD for GI, I know SAP standard doesn't recommend this however I have a requirement where if I have a PO against a cost center or an order and when I do the GR I wanted to have the stock posting tab in the man

  • Error: Multiple declaration

    Hi all, We have an issue occuring only in solaris-sparc platform(not on gcc/linux). In a source file(.cpp) we have many variables declared and defined, when try complile all of these variables give the following error: Error: Multiple declaration <va