How to send email with attachment

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

Re: sending fax

Similar Messages

  • Sharepoint Online - Send email with attachment

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

    Why hasn't this been answered?
    Sam Ogle

  • How i can send email with attachment ?

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

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

  • BPEL send email with attachment

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

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

  • Send Email with Attachment Callable Object

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

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

  • Send Email with Attachment in BSP?

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

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

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

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

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

  • Sending email with attachment from iCloud

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

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

  • Send Email with attachment further .

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

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

  • How to send emails with attachments??

    Hi all,
    I am search for how to send an email with attachment. I can send a simple email using mailto and as far as my knowledge goes it do not have a support for sending an attachment.

    Hi all,
    I am search for how to send an email with attachment. I can send a simple email using mailto and as far as my knowledge goes it do not have a support for sending an attachment.

  • How to send Email with attachments

    Hi im Trying to send a file as attachment using EMail Activity operator.
    Can we do it using Email activity? If yes, then how can we do it? If no, then please tell me about any other method using which i can send a email with attachments.
    Regards
    Vibhuti

    Better late than never, a comprehensive demo on the topic:
    REM
    REM maildemo.sql - A PL/SQL package to demonstrate how to use the UTL_SMTP
    REM package to send emails in ASCII and non-ASCII character sets, emails
    REM with text or binary attachments.
    REM
    REM Note: this package relies on the UTL_ENCODE PL/SQL package in Oracle 9i.
    CREATE OR REPLACE PACKAGE demo_mail IS
      ----------------------- Customizable Section -----------------------
      -- Customize the SMTP host, port and your domain name below.
      smtp_host   VARCHAR2(256) := 'smtp-server.some-company.com';
      smtp_port   PLS_INTEGER   := 25;
      smtp_domain VARCHAR2(256) := 'some-company.com';
      -- Customize the signature that will appear in the email's MIME header.
      -- Useful for versioning.
      MAILER_ID   CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
      --------------------- End Customizable Section ---------------------
      -- A unique string that demarcates boundaries of parts in a multi-part email
      -- The string should not appear inside the body of any part of the email.
      -- Customize this if needed or generate this randomly dynamically.
      BOUNDARY        CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
      FIRST_BOUNDARY  CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
      LAST_BOUNDARY   CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
                                                  utl_tcp.CRLF;
      -- A MIME type that denotes multi-part email (MIME) messages.
      MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
                                                      BOUNDARY || '"';
      MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER   := 76 / 4 * 3;
      -- A simple email API for sending email in plain text in a single call.
      -- The format of an email address is one of these:
      --   someone@some-domain
      --   "Someone at some domain" <someone@some-domain>
      --   Someone at some domain <someone@some-domain>
      -- The recipients is a list of email addresses  separated by
      -- either a "," or a ";"
      PROCEDURE mail(sender     IN VARCHAR2,
               recipients IN VARCHAR2,
               subject    IN VARCHAR2,
               message    IN VARCHAR2);
      -- Extended email API to send email in HTML or plain text with no size limit.
      -- First, begin the email by begin_mail(). Then, call write_text() repeatedly
      -- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
      -- email in non-ASCII or multi-byte character set. End the email with
      -- end_mail().
      FUNCTION begin_mail(sender     IN VARCHAR2,
                    recipients IN VARCHAR2,
                    subject    IN VARCHAR2,
                    mime_type  IN VARCHAR2    DEFAULT 'text/plain',
                    priority   IN PLS_INTEGER DEFAULT NULL)
                    RETURN utl_smtp.connection;
      -- Write email body in ASCII
      PROCEDURE write_text(conn    IN OUT NOCOPY utl_smtp.connection,
                     message IN VARCHAR2);
      -- Write email body in non-ASCII (including multi-byte). The email body
      -- will be sent in the database character set.
      PROCEDURE write_mb_text(conn    IN OUT NOCOPY utl_smtp.connection,
                     message IN            VARCHAR2);
      -- Write email body in binary
      PROCEDURE write_raw(conn    IN OUT NOCOPY utl_smtp.connection,
                    message IN RAW);
      -- APIs to send email with attachments. Attachments are sent by sending
      -- emails in "multipart/mixed" MIME format. Specify that MIME format when
      -- beginning an email with begin_mail().
      -- Send a single text attachment.
      PROCEDURE attach_text(conn         IN OUT NOCOPY utl_smtp.connection,
                   data         IN VARCHAR2,
                   mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                   inline       IN BOOLEAN  DEFAULT TRUE,
                   filename     IN VARCHAR2 DEFAULT NULL,
                      last         IN BOOLEAN  DEFAULT FALSE);
      -- Send a binary attachment. The attachment will be encoded in Base-64
      -- encoding format.
      PROCEDURE attach_base64(conn         IN OUT NOCOPY utl_smtp.connection,
                     data         IN RAW,
                     mime_type    IN VARCHAR2 DEFAULT 'application/octet',
                     inline       IN BOOLEAN  DEFAULT TRUE,
                     filename     IN VARCHAR2 DEFAULT NULL,
                     last         IN BOOLEAN  DEFAULT FALSE);
      -- Send an attachment with no size limit. First, begin the attachment
      -- with begin_attachment(). Then, call write_text repeatedly to send
      -- the attachment piece-by-piece. If the attachment is text-based but
      -- in non-ASCII or multi-byte character set, use write_mb_text() instead.
      -- To send binary attachment, the binary content should first be
      -- encoded in Base-64 encoding format using the demo package for 8i,
      -- or the native one in 9i. End the attachment with end_attachment.
      PROCEDURE begin_attachment(conn         IN OUT NOCOPY utl_smtp.connection,
                        mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                        inline       IN BOOLEAN  DEFAULT TRUE,
                        filename     IN VARCHAR2 DEFAULT NULL,
                        transfer_enc IN VARCHAR2 DEFAULT NULL);
      -- End the attachment.
      PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                      last IN BOOLEAN DEFAULT FALSE);
      -- End the email.
      PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
      -- Extended email API to send multiple emails in a session for better
      -- performance. First, begin an email session with begin_session.
      -- Then, begin each email with a session by calling begin_mail_in_session
      -- instead of begin_mail. End the email with end_mail_in_session instead
      -- of end_mail. End the email session by end_session.
      FUNCTION begin_session RETURN utl_smtp.connection;
      -- Begin an email in a session.
      PROCEDURE begin_mail_in_session(conn       IN OUT NOCOPY utl_smtp.connection,
                          sender     IN VARCHAR2,
                          recipients IN VARCHAR2,
                          subject    IN VARCHAR2,
                          mime_type  IN VARCHAR2  DEFAULT 'text/plain',
                          priority   IN PLS_INTEGER DEFAULT NULL);
      -- End an email in a session.
      PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
      -- End an email session.
      PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
    END;
    CREATE OR REPLACE PACKAGE BODY demo_mail IS
      -- Return the next email address in the list of email addresses, separated
      -- by either a "," or a ";".  The format of mailbox may be in one of these:
      --   someone@some-domain
      --   "Someone at some domain" <someone@some-domain>
      --   Someone at some domain <someone@some-domain>
      FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
        addr VARCHAR2(256);
        i    pls_integer;
        FUNCTION lookup_unquoted_char(str  IN VARCHAR2,
                          chrs IN VARCHAR2) RETURN pls_integer AS
          c            VARCHAR2(5);
          i            pls_integer;
          len          pls_integer;
          inside_quote BOOLEAN;
        BEGIN
           inside_quote := false;
           i := 1;
           len := length(str);
           WHILE (i <= len) LOOP
          c := substr(str, i, 1);
          IF (inside_quote) THEN
            IF (c = '"') THEN
              inside_quote := false;
            ELSIF (c = '\') THEN
              i := i + 1; -- Skip the quote character
            END IF;
            GOTO next_char;
          END IF;
          IF (c = '"') THEN
            inside_quote := true;
            GOTO next_char;
          END IF;
          IF (instr(chrs, c) >= 1) THEN
             RETURN i;
          END IF;
          <<next_char>>
          i := i + 1;
           END LOOP;
           RETURN 0;
        END;
      BEGIN
        addr_list := ltrim(addr_list);
        i := lookup_unquoted_char(addr_list, ',;');
        IF (i >= 1) THEN
          addr      := substr(addr_list, 1, i - 1);
          addr_list := substr(addr_list, i + 1);
        ELSE
          addr := addr_list;
          addr_list := '';
        END IF;
        i := lookup_unquoted_char(addr, '<');
        IF (i >= 1) THEN
          addr := substr(addr, i + 1);
          i := instr(addr, '>');
          IF (i >= 1) THEN
         addr := substr(addr, 1, i - 1);
          END IF;
        END IF;
        RETURN addr;
      END;
      -- Write a MIME header
      PROCEDURE write_mime_header(conn  IN OUT NOCOPY utl_smtp.connection,
                         name  IN VARCHAR2,
                         value IN VARCHAR2) IS
      BEGIN
        utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
      END;
      -- Mark a message-part boundary.  Set <last> to TRUE for the last boundary.
      PROCEDURE write_boundary(conn  IN OUT NOCOPY utl_smtp.connection,
                      last  IN            BOOLEAN DEFAULT FALSE) AS
      BEGIN
        IF (last) THEN
          utl_smtp.write_data(conn, LAST_BOUNDARY);
        ELSE
          utl_smtp.write_data(conn, FIRST_BOUNDARY);
        END IF;
      END;
      PROCEDURE mail(sender     IN VARCHAR2,
               recipients IN VARCHAR2,
               subject    IN VARCHAR2,
               message    IN VARCHAR2) IS
        conn utl_smtp.connection;
      BEGIN
        conn := begin_mail(sender, recipients, subject);
        write_text(conn, message);
        end_mail(conn);
      END;
      FUNCTION begin_mail(sender     IN VARCHAR2,
                    recipients IN VARCHAR2,
                    subject    IN VARCHAR2,
                    mime_type  IN VARCHAR2    DEFAULT 'text/plain',
                    priority   IN PLS_INTEGER DEFAULT NULL)
                    RETURN utl_smtp.connection IS
        conn utl_smtp.connection;
      BEGIN
        conn := begin_session;
        begin_mail_in_session(conn, sender, recipients, subject, mime_type,
          priority);
        RETURN conn;
      END;
      PROCEDURE write_text(conn    IN OUT NOCOPY utl_smtp.connection,
                     message IN VARCHAR2) IS
      BEGIN
        utl_smtp.write_data(conn, message);
      END;
      PROCEDURE write_mb_text(conn    IN OUT NOCOPY utl_smtp.connection,
                     message IN            VARCHAR2) IS
      BEGIN
        utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
      END;
      PROCEDURE write_raw(conn    IN OUT NOCOPY utl_smtp.connection,
                    message IN RAW) IS
      BEGIN
        utl_smtp.write_raw_data(conn, message);
      END;
      PROCEDURE attach_text(conn         IN OUT NOCOPY utl_smtp.connection,
                   data         IN VARCHAR2,
                   mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                   inline       IN BOOLEAN  DEFAULT TRUE,
                   filename     IN VARCHAR2 DEFAULT NULL,
                      last         IN BOOLEAN  DEFAULT FALSE) IS
      BEGIN
        begin_attachment(conn, mime_type, inline, filename);
        write_text(conn, data);
        end_attachment(conn, last);
      END;
      PROCEDURE attach_base64(conn         IN OUT NOCOPY utl_smtp.connection,
                     data         IN RAW,
                     mime_type    IN VARCHAR2 DEFAULT 'application/octet',
                     inline       IN BOOLEAN  DEFAULT TRUE,
                     filename     IN VARCHAR2 DEFAULT NULL,
                     last         IN BOOLEAN  DEFAULT FALSE) IS
        i   PLS_INTEGER;
        len PLS_INTEGER;
      BEGIN
        begin_attachment(conn, mime_type, inline, filename, 'base64');
        -- Split the Base64-encoded attachment into multiple lines
        i   := 1;
        len := utl_raw.length(data);
        WHILE (i < len) LOOP
           IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
          utl_smtp.write_raw_data(conn,
             utl_encode.base64_encode(utl_raw.substr(data, i,
             MAX_BASE64_LINE_WIDTH)));
           ELSE
          utl_smtp.write_raw_data(conn,
            utl_encode.base64_encode(utl_raw.substr(data, i)));
           END IF;
           utl_smtp.write_data(conn, utl_tcp.CRLF);
           i := i + MAX_BASE64_LINE_WIDTH;
        END LOOP;
        end_attachment(conn, last);
      END;
      PROCEDURE begin_attachment(conn         IN OUT NOCOPY utl_smtp.connection,
                        mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                        inline       IN BOOLEAN  DEFAULT TRUE,
                        filename     IN VARCHAR2 DEFAULT NULL,
                        transfer_enc IN VARCHAR2 DEFAULT NULL) IS
      BEGIN
        write_boundary(conn);
        write_mime_header(conn, 'Content-Type', mime_type);
        IF (filename IS NOT NULL) THEN
           IF (inline) THEN
           write_mime_header(conn, 'Content-Disposition',
             'inline; filename="'||filename||'"');
           ELSE
           write_mime_header(conn, 'Content-Disposition',
             'attachment; filename="'||filename||'"');
           END IF;
        END IF;
        IF (transfer_enc IS NOT NULL) THEN
          write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
        END IF;
        utl_smtp.write_data(conn, utl_tcp.CRLF);
      END;
      PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                      last IN BOOLEAN DEFAULT FALSE) IS
      BEGIN
        utl_smtp.write_data(conn, utl_tcp.CRLF);
        IF (last) THEN
          write_boundary(conn, last);
        END IF;
      END;
      PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
      BEGIN
        end_mail_in_session(conn);
        end_session(conn);
      END;
      FUNCTION begin_session RETURN utl_smtp.connection IS
        conn utl_smtp.connection;
      BEGIN
        -- open SMTP connection
        conn := utl_smtp.open_connection(smtp_host, smtp_port);
        utl_smtp.helo(conn, smtp_domain);
        RETURN conn;
      END;
      PROCEDURE begin_mail_in_session(conn       IN OUT NOCOPY utl_smtp.connection,
                          sender     IN VARCHAR2,
                          recipients IN VARCHAR2,
                          subject    IN VARCHAR2,
                          mime_type  IN VARCHAR2  DEFAULT 'text/plain',
                          priority   IN PLS_INTEGER DEFAULT NULL) IS
        my_recipients VARCHAR2(32767) := recipients;
        my_sender     VARCHAR2(32767) := sender;
      BEGIN
        -- Specify sender's address (our server allows bogus address
        -- as long as it is a full email address ([email protected]).
        utl_smtp.mail(conn, get_address(my_sender));
        -- Specify recipient(s) of the email.
        WHILE (my_recipients IS NOT NULL) LOOP
          utl_smtp.rcpt(conn, get_address(my_recipients));
        END LOOP;
        -- Start body of email
        utl_smtp.open_data(conn);
        -- Set "From" MIME header
        write_mime_header(conn, 'From', sender);
        -- Set "To" MIME header
        write_mime_header(conn, 'To', recipients);
        -- Set "Subject" MIME header
        write_mime_header(conn, 'Subject', subject);
        -- Set "Content-Type" MIME header
        write_mime_header(conn, 'Content-Type', mime_type);
        -- Set "X-Mailer" MIME header
        write_mime_header(conn, 'X-Mailer', MAILER_ID);
        -- Set priority:
        --   High      Normal       Low
        --   1     2     3     4     5
        IF (priority IS NOT NULL) THEN
          write_mime_header(conn, 'X-Priority', priority);
        END IF;
        -- Send an empty line to denotes end of MIME headers and
        -- beginning of message body.
        utl_smtp.write_data(conn, utl_tcp.CRLF);
        IF (mime_type LIKE 'multipart/mixed%') THEN
          write_text(conn, 'This is a multi-part message in MIME format.' ||
         utl_tcp.crlf);
        END IF;
      END;
      PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
      BEGIN
        utl_smtp.close_data(conn);
      END;
      PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
      BEGIN
        utl_smtp.quit(conn);
      END;
    END;
    /

  • Sending email with attachment (image)

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

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

  • Send email with attachment via XI

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

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

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

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

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

  • How to send mail with attachment

    Hi,
    How to send mail with word document as attachment in oracle pl/sql.
    kindly help me .
    thank you
    regards
    P Prakash

    create or replace procedure pdf_mail(
        p_sender     varchar2, -- sender, example: 'Me <[email protected]>'
        p_recipients varchar2, -- recipients, example: 'Someone <[email protected]>'
        p_subject    varchar2, -- subject
    p_text   varchar2, -- text
    p_filename  varchar2, -- name of pdf file
    p_blob   blob     -- pdf file
    ) is
      conn      utl_smtp.connection;
      i number;
      len number;
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => p_sender,
        recipients => p_recipients,
        subject    => p_subject,
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'application/pdf',
        inline       => TRUE,
        filename     => p_filename,
        transfer_enc => 'base64');
        -- split the Base64 encoded attachment into multiple lines
       i   := 1;
       len := DBMS_LOB.getLength(p_blob);
       WHILE (i < len) LOOP
          IF(i + demo_mail.MAX_BASE64_LINE_WIDTH < len)THEN
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, demo_mail.MAX_BASE64_LINE_WIDTH, i)));
          ELSE
             UTL_SMTP.Write_Raw_Data (conn
                                    , UTL_ENCODE.Base64_Encode(
                                            DBMS_LOB.Substr(p_blob, (len - i)+1,  i)));
          END IF;
          UTL_SMTP.Write_Data(conn, UTL_TCP.CRLF);
          i := i + demo_mail.MAX_BASE64_LINE_WIDTH;
       END LOOP;
      demo_mail.end_attachment(conn => conn);
      demo_mail.attach_text(
        conn      => conn,
        data      => p_text,
        mime_type => 'text/html');
      demo_mail.end_mail( conn => conn );
    END;
    ref:
    http://www.plpdf.com/23-1725.html
    Edited by: Mahanam on Jan 9, 2011 10:32 PM

Maybe you are looking for

  • How to clear grey loading screen and animated gif (Dynamic Action with "Show Processing" on submit)

    APEX V4.2.3 DB 11.2 I have a classic report on page 1.  I have a region button called "Export" (defined by a submit dynamic action with "show processing=Yes") that submits the page and then via a branch directs me to page 2 which has a slightly diffe

  • Seeing Reminders in iCal iOS7?

    for some reason i am not finding any documentation on reminders and clicking "Reminders Help" pulls up a nothing available page. does anyone know if it is possible to see Reminders that i have assigned a "reminder" date and time to in iCal? this woul

  • Airport Update question

    I have Airport ver. 9.52 on my iBook. When I check for updates it says that there is an update available called: *Airport Extreme Driver Update 2005-001* (Version 1.0) +"This update resolves AirPort compatibility issues with certain third party 802.1

  • How to hide tooltips on user action

    Generally Tooltips will be displayed for the pre-defined time interval. But is there any way to hide the tooltips when the user performs some action. Please help me.

  • Get ClientContext from Full sharepoint url?

    I am receiving a full sharepoint url like 'http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx' I know the following code will not work as the url does not directly reference a site. using (var context = new ClientContext(http://TestServ