Mail not loading email with attachment

I work with many computers running OS X 10.5.8 and Mail 3.6. One of them loads most plain text emails just fine, but when I try to load a message with a reasonable (1MB) attachment, it shows "Loading" (with a spinning logo) but does not load the message. I've left this process running for over an hour, but it does not seem to get anywhere. I checked the activity window during this loading screen and something appears quickly immediately after I click on the message, but then it is empty.
It is not a server issue or an issue with the settings, as tens of other computers with identical settings and on the same servers perform perfectly, and are able to download much larger attachments and emails.
Additional Info: I have tried rebuilding the mailbox and having Mail generate a new Envelope Index file, but the problem persists.
Any help or ideas would be greatly appreciated!

Hi Again,
The index probably needs to be repaired again. Try again removing the Envelope Index to force reindexing of all mailboxes, but again read:
http://docs.info.apple.com/article.html?path=Mail/3.0/en/14019.html
With IMAP or Exchange accounts, note their special treatment requiring removal of the account folders. Have you ever removed the Envelope Index without removing the account folders, by any chance?
After you do this, you should again test.
Ernie

Similar Messages

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

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

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

  • Mail not showing emails with attachments

    Mail doesn't show/download emails with pdf attachments, although I can see the emails and attachments on my iphone no problem. The whole email is missing, not just the attachment.
    Please help as this means I sometimes miss important emails, and well as the inconvenience of only being able to access the email and attachment from my phone

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click the line below to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Quit and relaunch Mail, and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard (command-C). In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • Mail not receiving emails with attachments

    Hi
    I'd appreciate any suggestions in relation to the following.
    My wife and I both run computers from the one account, Mail on her PowerBook logging in through my name and password. Until recently, we have had no problems at all. However, it has come to light that my wife has not been receiving emails with attachments for some time. To test this, my wife sent an email with an attachment to her home email address from work, and copied it to me. I received the email and the attachment on my PC; my wife's Mac did not receive the email. I then forwarded the email with the attachment to her computer; this was successful. This would suggest some problem with her Mail account on the Mac. However, the configuration has not been changed. Is it possible for it just to stop working for some reason?

    I'm using a PC for my email at the moment. I'm not sure if all my wife's emails have been downloaded. However, Mail has made a Home/Mail/MessageUidsAlreadyDowloaded file. This was created when I sent an email to test what happened. I was unable to make Mail download all her emails, so I guess they must have gone from the server. She has a different email address to mine, but it's run from the same ISP account; as I said, she logs in, automatically, through Mail to her email. I have contacted the ISP about it, but they are unable to see any trace of emails that colleagues have sent my wife and which she sends home to herself. All of these files happen to have attachments, but I cannot see any setting of Mail which would account for them being rejected. Also, I can't be entiurely sure that only emails with attachments don't get through; there may be others, 'unattached'.
    Thanks for your continued assistance.

  • Mail not receiving emails with word attachments

    I have a 27" imac
    when people send me emails with microsoft word attachments I do not get them in my inbox
    please help

    I'm using a PC for my email at the moment. I'm not sure if all my wife's emails have been downloaded. However, Mail has made a Home/Mail/MessageUidsAlreadyDowloaded file. This was created when I sent an email to test what happened. I was unable to make Mail download all her emails, so I guess they must have gone from the server. She has a different email address to mine, but it's run from the same ISP account; as I said, she logs in, automatically, through Mail to her email. I have contacted the ISP about it, but they are unable to see any trace of emails that colleagues have sent my wife and which she sends home to herself. All of these files happen to have attachments, but I cannot see any setting of Mail which would account for them being rejected. Also, I can't be entiurely sure that only emails with attachments don't get through; there may be others, 'unattached'.
    Thanks for your continued assistance.

  • Mail.app - Moving email with attachment to a subfolder causes the email to convert to text format and lose the attachment

    I am Lion on Mac Book pro.
    When I move a mail with attachement to a folder, sometimes, it loses its mime-type and becomes a text formatted message. Hence the contents of the attachments are added as text to the mail and I cannot download the attachments then.
    This does not happen always, but almost 3/10 times.
    Thanks.
    Regards,
    Viraj

    What type of mail account is this (POP, IMAP, .Mac)? If IMAP or .Mac, what are your Preferences > Accounts > Mailbox Behaviors > Drafts settings?
    Go to Apple Menu > System Preferences > Network, choose Network Port Configurations from the Show popup menu, and make sure that the configuration used to connect to Internet appears at the top of the list. Turn OFF all the port configurations except the one needed to connect to Internet and see whether that helps — if it doesn’t, turn ON again the ones you want enabled.
    Open Keychain Access > Keychain First Aid and verify/repair the keychain.
    Try also turning OFF the Search For Certificates options in Keychain Access > Preferences if any of them is ON — take a look at the following articles for more information on this particular issue:
    http://www.hawkwings.net/2006/07/18/apple-mail-phones-home-too/
    http://www.macgeekery.com/tips/mailapp_doesnt_phone_homeeither/

  • Mail not sending email with digital signature

    Hello helpers,
    What's the deal with Mail and digital signatures? I could never get the application to work with my Versign class 1 digital signature in Tiger and now in Leopard. Keep getting error 1035. That's what led mr to Thunderbird and I got Leopard hoping to resolve this issue. Keychain seems as if it's a weirdo in its simplicity and where I believe the problem lies. my digital certificate resides on the system but is not in the my certificate category. However, when I select it in system, afterwards it shows up in my certificate category. If I close Keychain and reopen it, my certificate is empty.
    I like Mail. However, it's important to me to use my digital certificate in signing my email. I believe I must have done something wrong in the installation of the certificate and I can't imaging what. Why can't Mail accept digital certificate directly like other email application rather than go through a third party...Keychain. Mail help did not help. Any workable solution would be appreciated. Thanks
    Ralston

    Just discovered that I have an icloud account and a .me account in my accounts inbox. Do I have a problem with migration to icloud?

  • Os x lion mail does not save icloud sent email with attachment

    os x lion mail does not save icloud sent email with attachment... are there people who experience the same problem? i was with Apple Support via chat and he could not resolve the problem. I was given a phone number to call, i assume it's tech support for OS X or Mail but I did not have time to be on the phone for a long time... thank you

    I finally fixed it! I verified and repaired disk permissions on my Mac... how come the Apple Tech Guy didn't know that???!!!! Shocking

  • Symantec Mail Security with Exchange 2007 (Emails with Attachment missing)

    HI, i need help here
    I have Win 2008 with Exchange 2007 and Symantec Mail Security. Symantec was working fine until the license expired but it was still fine until yesterday, we realize that we cannot receive email with attachment. after stopping the symantec services, mail
    flow went back to normal. We then remove the program from the control panel.
    Then i found that i cant retrieve or find those emails that was sent to us during a period of ard 6 hours. i tried looking the the Symantec quarantine folder but it is not there.
    Can someone point to me where should i look for the missing mails? When i do a mail flow troubleshoot i can see the logs that it is sent to the mailbox, but from users's outlook inbox, there is no email ??
    Much Appreciated

    Symantec's support group should be able to tell you what happened.
    --- Rich Matheisen MCSE&I, Exchange MVP

  • Friends on Android galaxy do not receive my emails with attached photos sent from my iPhone.  Why

    I have an iPhone 4 running 6.1 OS.  Several times I have taken photos with my iPhone and then tried to email them from my iPhone to friends using Android Galaxy.  They never receive the emails. When I select the photo to be emailed from "Camera Roll", several options appear  (Mail, Message, Photo Stream, Twitter, Facebook etc).  I select "Mail", then select an email address from my contact list, add some text to the message, select the size of photo and send.  The email with attached photo is never received.  Any idea why?

    Well, your response about MMS is beyond my understanding unfortunately.   Don't understand too well this issue of MMS and IMessage. I checked my settings and "Send as MMS" was OFF.  I have turned it ON and tried to re-send the photos.  No word yet if it was received..  Also, the "send and receive" addresses in the "Messages" setting only included my "@me" email address, and not my Yahoo address, which I am trying to add.  It doesn't seem to be able to complete the verification process for that Yahoo address (it remains in a perpetual state of "verifying"), although it did add an "icloud" address, and my cell phone number.   I have my "cellular data" turned OFF because I am in the States (I am Canadaian) and wish to restrict roaming charges.  So are you saying that I cannot send photo attachments in emails from my iPhone, while connected to the in-house internet modem/router - ie., that I can do so only if my "cellular data" setting is ON?  Then why do the messages still appear in the SENT folder?  Do the settings on the recipient phone have an impact?  It doesn't seem so because they were able to receive the messages from the PC/Hotmail source.

  • In my Mac Mail Version 4.5, I am not received email pdf attachement. It is shown in some html like form in message content. Please help

    In my Mac Mail Version 4.5, I am not received email pdf attachement. It is shown in some html like form in message content. Please help

    Erdygirl please be aware you are posting to a public forum.  I have removed your personal information from your previous post.
    Please check your account at http://www.adobe.com/ to locate your serial number.  You can find more information on how to locate your serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.

  • HT1338 has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    has anyone else had problems with their mail not loading properly and the multi gestures stopped working on their mac pro after new updates?

    Have you tried calling Apple tech support?
    http://www.apple.com/contact/

  • New email with attachment filename as Mail Subject

    Does anyone know how to make an OSX Service, much like "New Email with Attachment" where the attachment's filename is automatically copied into the subject field of the email?
    Can this be done in Automator, or does a script have to be written from scratch?
    Thanks in advance

    As I said, it is now under Share>Email.
    Also, you can do the same thing just dragging an item to the Mail icon in the dock.

  • Problem by  Sending an Email with attached Adobe Interactive Form (Code)

    Thanks. I have written Programm, but it does not work as i want it to do. I will send an Email with attached Adobe Interactive Firm to [email protected]. I tried it with "*lo_recipient = cl_sapuser_bcs=>create( sy-uname )" at the marked(bold, fat) position. It worked but the Email was send to my SAP-Account, but i want to send to [email protected], so I tried this (see at code in bold, fat):
    lo_rec TYPE adr6-smtp_addr VALUE '[email protected]'. " Empfänger Receiver
    lo_recipient = cl_cam_address_bcs=>create_internet_address( lo_rec ).
    But it doens`t send the email.
    Can anybody help me please???
    Kevin
    Here my Code:
    Report FP_EXAMPLE_01
    Printing of documents using PDF based forms
    REPORT z_example_02.
    Data declaration
    DATA: carr_id TYPE sbook-carrid,
    customer TYPE scustom,
    bookings TYPE ty_bookings,
    connections TYPE ty_connections,
    fm_name TYPE rs38l_fnam,
    fp_docparams TYPE sfpdocparams,
    fp_outputparams TYPE sfpoutputparams,
    error_string TYPE string,
    l_booking TYPE sbook,
    t_sums TYPE TABLE OF sbook,
    l_sums LIKE LINE OF t_sums,
    fp_formoutput TYPE fpformoutput.
    PARAMETER: p_custid TYPE scustom-id DEFAULT 38.
    SELECT-OPTIONS: s_carrid FOR carr_id DEFAULT 'AA' TO 'ZZ'.
    PARAMETER: p_form TYPE tdsfname DEFAULT 'FP_EXAMPLE_01'.
    PARAMETER: language TYPE sfpdocparams-langu DEFAULT 'E'.
    PARAMETER: country TYPE sfpdocparams-country DEFAULT 'US'.
    Get data from the following tables: scustom(Flight customer)
    sbook (Single flight reservation)
    spfli (Flight plan)
    SELECT SINGLE * FROM scustom INTO customer WHERE id = p_custid.
    CHECK sy-subrc = 0.
    SELECT * FROM sbook INTO TABLE bookings
    WHERE customid = p_custid
    AND carrid IN s_carrid
    ORDER BY PRIMARY KEY.
    SELECT * FROM spfli INTO TABLE connections
    FOR ALL ENTRIES IN bookings
    WHERE carrid = bookings-carrid
    AND connid = bookings-connid
    ORDER BY PRIMARY KEY.
    Print data:
    First get name of the generated function module
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
    EXPORTING
    i_name = p_form
    IMPORTING
    e_funcname = fm_name.
    IF sy-subrc <> 0.
    MESSAGE e001(fp_example).
    ENDIF.
    Set output parameters and open spool job
    fp_outputparams-nodialog = 'X'. " suppress printer dialog popup
    fp_outputparams-getpdf = 'X'. " launch print preview
    CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
    ie_outputparams = fp_outputparams
    EXCEPTIONS
    cancel = 1
    usage_error = 2
    system_error = 3
    internal_error = 4
    OTHERS = 5.
    Set form language and country (->form locale)
    fp_docparams-langu = language.
    fp_docparams-country = country.
    *fp_docparams-fillable = 'X'.
    *fp_docparams-langu = 'E'. "wird jetzt automatisch gesetzt, bzw. kann dynamisch verändert werden
    *fp_docparams-country = 'GB'. "wird jetzt automatisch gesetzt, bzw. kann dynamisch verändert werden
    currency key dependant summing
    LOOP AT bookings INTO l_booking.
    l_sums-forcuram = l_booking-forcuram.
    l_sums-forcurkey = l_booking-forcurkey.
    COLLECT l_sums INTO t_sums.
    ENDLOOP.
    Now call the generated function module
    CALL FUNCTION fm_name
    EXPORTING
    /1bcdwb/docparams = fp_docparams
    customer = customer
    bookings = bookings
    connections = connections
    t_sums = t_sums
    IMPORTING
    /1bcdwb/formoutput = fp_formoutput
    EXCEPTIONS
    usage_error = 1
    system_error = 2
    internal_error = 3
    OTHERS = 4.
    IF sy-subrc <> 0.
    CALL FUNCTION 'FP_GET_LAST_ADS_ERRSTR'
    IMPORTING
    e_adserrstr = error_string.
    IF NOT error_string IS INITIAL.
    we received a detailed error description
    WRITE:/ error_string.
    EXIT.
    ELSE.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    Close spool job
    CALL FUNCTION 'FP_JOB_CLOSE'
    EXCEPTIONS
    usage_error = 1
    system_error = 2
    internal_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.
    *********************Send the form*******************
    *********************to the Customer*****************
    *********************via Email***********************
    *IF i_down = abap_true.
    DATA: filename TYPE string,
    path TYPE string,
    fullpath TYPE string,
    default_extension TYPE string VALUE 'PDF'.
    Data:
    lt_att_content_hex TYPE solix_tab.
    *DATA: data_tab TYPE TABLE OF x255.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = fp_formoutput-pdf
    TABLES
    binary_tab = lt_att_content_hex.
    CLASS cl_bcs DEFINITION LOAD.
    DATA:
    lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    lo_send_request = cl_bcs=>create_persistent( ).
    DATA:
    lt_message_body TYPE bcsy_text VALUE IS INITIAL.
    DATA: 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 fill the attached form and send it back to us.'
    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 = 'Vendor Payment Form' ).
    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 = 'Vendor Payment Form'
    i_att_content_hex = lt_att_content_hex ).
    CATCH cx_document_bcs INTO lx_document_bcs.
    ENDTRY.
    lo_send_request->set_document( lo_document ).
    DATA:
    lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
    lo_send TYPE adr6-smtp_addr VALUE '[email protected]'. "Absender SENDER
    lo_sender = cl_cam_address_bcs=>create_internet_address( lo_send ).
    Set sender
    lo_send_request->set_sender(
    EXPORTING
    i_sender = lo_sender ).
    Create recipient
    DATA:
    lo_recipient type ref to if_recipient_bcs value is initial.
    Data:
    lo_rec TYPE adr6-smtp_addr VALUE '[email protected]'. " Empfänger Receiver
    lo_recipient = cl_cam_address_bcs=>create_internet_address( lo_rec ).
    *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.
    MESSAGE 'The payment form has been emailed to the Vendor' TYPE 'I'.

    Hi Kevin,
    Please try this code to send your mail, i wrote it and works well in many system.
    Take care if in your profile you got an e-mail adress define .
    Take care also of trnasaction SCOT customizing, are you able to send mail to e-mail adress ?
    Let me know if it's works.
    Best regards.
    <i>**----
    CLASS-DEFINITIONS
    DATA: send_request       TYPE REF TO cl_bcs.
    DATA: document           TYPE REF TO cl_document_bcs.
    DATA: sender             TYPE REF TO cl_sapuser_bcs.
    DATA: recipient          TYPE REF TO if_recipient_bcs.
    INTERNAL TABLES
    DATA: l_mailtext TYPE soli_tab.
    DATA: iaddsmtp   TYPE TABLE OF bapiadsmtp.
    DATA: ireturn    TYPE TABLE OF bapiret2.
    VARIABLES
    DATA: mail_line  LIKE LINE OF l_mailtext.
    DATA: bapiadsmtp         TYPE bapiadsmtp.
    DATA: subject    TYPE so_obj_des.
    DATA : att_subject TYPE so_obj_des.
    DATA : w_except TYPE REF TO cx_root .
    CONSTANTS : c_defmail TYPE ad_smtpadr VALUE
                     '[email protected]' .
    FIELD-SYMBOLS : <smtp> TYPE bapiadsmtp.
    *Convert the pdf given by function module into Binary .
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer     = output-pdf "PDF file from function module
      TABLES
        binary_tab = hexa.
    *Set subject of the mail
    subject = 'Exemple de PDF interactif'.
    Set text of the mail
    mail_line = 'Merci de remplir le formulaire et nous le retourner'.
    APPEND mail_line TO l_mailtext .
    Set the name of the attached document
    att_subject = 'Template du PDF'.
    TRY.
    Create persistent send request
        send_request = cl_bcs=>create_persistent( ).
    Get sender object
        sender = cl_sapuser_bcs=>create( sy-uname ).
    Add sender
        CALL METHOD send_request->set_sender
          EXPORTING
            i_sender = sender.
    Read the E-Mail address for the user
        CALL FUNCTION 'BAPI_USER_GET_DETAIL'
          EXPORTING
            username = sy-uname
          TABLES
            return   = ireturn
            addsmtp  = iaddsmtp.
        LOOP AT iaddsmtp ASSIGNING <smtp> WHERE std_no = 'X'.
          CLEAR bapiadsmtp.
          MOVE <smtp> TO bapiadsmtp.
        ENDLOOP.
        CASE bapiadsmtp-e_mail.
          WHEN space.
    No adress main for user, so send it to the default mail adress
            recipient =
         cl_cam_address_bcs=>create_internet_address( c_defmail ).
          WHEN OTHERS.
            recipient =
         cl_cam_address_bcs=>create_internet_address( bapiadsmtp-e_mail ).
        ENDCASE.
    Add recipient with its respective attributes to send request
        CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient  = recipient
            i_express    = 'X'
            i_copy       = space
            i_blind_copy = space
            i_no_forward = space.
    Set that you don't need a Return Status E-mail
        CALL METHOD send_request->set_status_attributes
          EXPORTING
            i_requested_status = 'E'
            i_status_mail      = 'E'.
    set send immediately flag
        send_request->set_send_immediately( 'X' ).
    *Build Document
        document = cl_document_bcs=>create_document(
                            i_type    = 'RAW'
                            i_text    = l_mailtext
                            i_subject = subject ).
        add attachment to document
        CALL METHOD document->add_attachment
          EXPORTING
            i_attachment_type    = 'PDF'
            i_attachment_subject = att_subject
            i_att_content_hex    = hexa.
    Add document to send request
        CALL METHOD send_request->set_document( document ).
    Send document
        CALL METHOD send_request->send( ).
        COMMIT WORK.
      CATCH cx_send_req_bcs INTO w_except.
      CATCH cx_address_bcs INTO w_except.
      CATCH cx_document_bcs INTO w_except.
    ENDTRY.</i>

  • Email with Attachment

    Hi All
    We are successfully able to send email with attachment on sql prompt. The problem is when we are trying to send the attachment through Application Express after submit process its showing the attached file but without its content.
    We hav created two such processes. Process one attachs the file as below
    declare
    file_id number;
    begin
    delete from dumy_file;
    select nvl(max(id),0)+1 into file_id from dumy_file;
    insert into dumy_file(id,name,file_obj_id,mime_type,blob_content)
    select file_id, filename, id ,mime_type,blob_content
    from htmldb_application_files where name = :P2_FILE;
    :P2_X := file_id;
    end;
    And process two send the email with attachment:
    declare
    file_name varchar2(100);
    mim_typ varchar2(50);
    begin
    select name into file_name from dumy_file where id = :P2_X;
    select MIME_TYPE into mim_typ from dumy_file where id = :P2_X;
    email_files(from_name => 'Aashu' ,
    to_names => :P2_EMAIL,
    subject => 'A test from APEX',
    message => 'A test message from APEX',
    html_message => 'A test message from APEX',
    filename1 => file_name,
    filetype1 => mim_typ);
    end;
    Here dumy_file is a custom table.
    Any help would be highly appreciated.
    Thanks
    saurabh

    [rem Purpose: Sends e-mail (text and/or html, either as a string or from a file)
    rem to one or more recipients (including cc and/or bcc recipients), along with
    rem up to 3 file attachments (text and/or binary; default is text/plain), using
    rem the UTL_SMTP package to send the e-mail, the DBMS_LOB package to read
    rem binary file attachments, and the UTL_ENCODE package to convert the binary
    rem attachments to BASE64 for character string (non-binary) transmission.
    rem BE AWARE THAT A COMMIT MAY BE DONE BY THIS ROUTINE (see HOWEVER... below).
    rem
    rem The complete parameter list for the email_files procedure is shown below:
    rem    from_name - name and e-mail address to put in the From field
    rem    to_names - names and e-mail addresses for the To field (separated by
    rem       commas or semicolons)
    rem    subject - text string for Subject field
    rem    message - text string or text file name for Message, if any
    rem    html_message - html string or html file name for Message, if any
    rem    cc_names - names and e-mail addresses for the Cc field, if any
    rem       (separated by commas or semicolons)
    rem    bcc_names - names and e-mail addresses for the Bcc field, if any
    rem       (separated by commas or semicolons)
    rem    filename1 - first file pathname to attach, if any
    rem    filetype1 - mime type of first file (defaults to 'text/plain')
    rem    filename2 - second file pathname to attach, if any
    rem    filetype2 - mime type of second file (defaults to 'text/plain')
    rem    filename3 - third file pathname to attach, if any
    rem    filetype3 - mime type of third file (defaults to 'text/plain')
    rem
    rem Sample names and e-mail addresses are: srea (attaches @<localhost> or
    rem @<mail domain>), [email protected], <[email protected]>, Steve Rea <[email protected]>,
    rem and "Steve Rea" <[email protected]> (e-mail addresses must be valid - validity
    rem checking is not done on them).
    rem
    rem A sample call in PL/SQL is shown below, which sends a text and html message,
    rem plus a text file and two binary files (note: the slash after "end;" must be
    rem the first character on it's line):
    rem
    rem    begin
    rem       email_files(from_name    => 'oracle' ,
    rem                   to_names     => '[email protected]',
    rem                   subject      => 'A test',
    rem                   message      => 'A test message',
    rem                   html_message => '<h2>A <u><i>test</i></u> message</h2>',
    rem                   filename1    => '/tmp/web_ptrbdca.txt',
    rem                   filename2    => '/tmp/password_standards.pdf',
    rem                   filetype2    => 'application/pdf',
    rem                   filename3    => '/tmp/wb703.jpg',
    rem                   filetype3    => 'image/jpeg');
    rem    end;
    rem    /
    rem
    rem If the message or html_message string has a file name in it (starting with
    rem a forward slash for unix or starting with '<drive letter>:\' or '\\' for
    rem Windows/DOS), the text or html file is copied into the e-mail as the message
    rem or html message; otherwise, the message or html_message is copied into the
    rem e-mail as-is.
    rem
    rem Attachment file types (mime types) that I've tested include:
    rem    text/plain, text/html, image/jpeg, image/gif, application/pdf,
    rem    application/msword
    rem A list of mime types can be seen at:
    rem    http://www.webmaster-toolkit.com/mime-types.shtml
    rem If the mime type does not begin with "text", it is assumed to be a binary
    rem file that will be encoded as base64 before transmission.
    rem
    rem This was derived from several sources, including:
    rem    Dave Wotton (Cambridge UK) - mail_files.sql at
    rem       http://home.clara.net/dwotton/dba/oracle_smtp.htm
    rem    Oracle Technology Network - maildemo.sql (demo_mail) at
    rem       http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    rem    Akadia's "Read a file word by word using DBMS_LOB" Tip at
    rem       http://www.akadia.com/services/read_file_with_dbms_lob.html
    rem    Tom Kyte of Oracle's AskTom site (http://AskTom.oracle.com) -
    rem       answer to "File Exists which is not a BFILE" and others.
    rem
    rem NOTE: The user running this must have "create any directory" and "drop any
    rem directory" privileges ("create directory" was introduced in Oracle 9iR2),
    rem which must be granted from a system or dba account, such as:
    rem    grant create any directory to scott;
    rem    grant drop any directory to scott;
    rem  then:
    rem    connect / as sysdba
    rem    grant select on dba_directories to scott;
    rem or, for everyone to have directory privileges:
    rem    grant create any directory to public;
    rem    grant drop any directory to public;
    rem  then:
    rem    connect / as sysdba
    rem    grant select on dba_directories to public;
    rem Any file in any directory accessible to the user can be attached (not just
    rem the directories listed for the utl_file_dir parameter in the init.ora file).
    rem HOWEVER, if you are using this to send e-mail's with attached files (or
    rem reading the message text or message html from a file) from a trigger or
    rem from some other SQL that you can't or don't want to have a commit done,
    rem you will first need to create an Oracle directory entry for the directory
    rem containing the attached files and grant read access to it to public, such
    rem as:
    rem    create directory CESDIR_COMMON as '/home/common';
    rem    grant read on directory CESDIR_COMMON to public;
    rem
    rem You may also want to create a public synonym for this procedure, from the
    rem procedure's owner:
    rem    create or replace public synonym email_files for email_files;
    rem    grant execute on email_files to public;
    rem
    rem FYI: I tried using the utl_file package to read binary files:
    rem    utl_file.get_raw(v_file_handle,data,57);
    rem but got "ORA-29284: file read error" on .pdf files, so, I switched to use
    rem the dbms_lob package to read binary files:
    rem    dbms_lob.read(v_bfile_handle,read_bytes,v_pos,data);
    rem
    rem Author: Stephen Rea <[email protected]>
    rem    University of Arkansas Cooperative Extension Service
    rem Initial release: 12/21/04
    rem
    rem Updates:
    rem 1/31/05 - Fixed for triggers and other SQL that can't have a commit by
    rem    checking for and using already-defined Oracle directories ("create
    rem    directory" is a DDL statement that does a commit).
    rem 9/23/05 - Put exception handler in to handle the SMTP server being
    rem    down or unavailable.  (Solution from Ed Siegle at Swarthmore.)
    rem 7/14/06 - Additional changes to detect and handle Windows/DOS file names
    rem    (second and third characters ':\' for paths with drive letters, or
    rem    first and second characters '\\' for UNC paths).
    rem 8/25/06 - Some SMTP interfaces may require angle brackets (<>) around the
    rem    e-mail addresses, so, add them before returning results from get_address.
    rem    Also, they may not attach the host if relayed through a non-localhost,
    rem    so, attach the mail domain part (last two components) of the relay host
    rem    to the address if the mail domain is not specified in the address.
    rem
    create or replace procedure email_files(from_name varchar2,
                          to_names varchar2,
                          subject varchar2,
                          message varchar2 default null,
                          html_message varchar2 default null,
                          cc_names varchar2 default null,
                          bcc_names varchar2 default null,
                          filename1 varchar2 default null,
                          filetype1 varchar2 default 'text/plain',
                          filename2 varchar2 default null,
                          filetype2 varchar2 default 'text/plain',
                          filename3 varchar2 default null,
                          filetype3 varchar2 default 'text/plain')
    is
       -- Change the SMTP host name and port number below to your own values,
       -- if not localhost on port 25:
       smtp_host          varchar2(256) := 'localhost';
       smtp_port          number := 25;
       -- Change the boundary string, if needed, which demarcates boundaries of
       -- parts in a multi-part email, and should not appear inside the body of
       -- any part of the e-mail:
       boundary           constant varchar2(256) := 'CES.Boundary.DACA587499938898';
       recipients         varchar2(32767);
       directory_path     varchar2(256);
       file_name          varchar2(256);
       crlf               varchar2(2):= chr(13) || chr(10);
       mesg               varchar2(32767);
       conn               UTL_SMTP.CONNECTION;
       type varchar2_table is table of varchar2(256) index by binary_integer;
       file_array         varchar2_table;
       type_array         varchar2_table;
       i                  binary_integer;
       my_code            number;
       my_errm            varchar2(32767);
       -- Function to return the next email address in the list of email addresses,
       -- separated by either a "," or a ";".  From Oracle's demo_mail.  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 IS
             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;
          i := lookup_unquoted_char(addr, '@');
          IF (i = 0 and smtp_host != 'localhost') THEN
             i := instr(smtp_host, '.', -1, 2);
             addr := addr || '@' || substr(smtp_host, i + 1);
          END IF;
          addr := '<' || addr || '>';
          RETURN addr;
       END;
       -- Procedure to split a file pathname into its directory path and file name
       -- components.
       PROCEDURE split_path_name(file_path IN VARCHAR2, directory_path OUT VARCHAR2,
          file_name OUT VARCHAR2) IS
          pos number;
       begin
          -- Separate the filename from the directory name
          pos := instr(file_path,'/',-1);
          if pos = 0 then
             pos := instr(file_path,'\',-1);
          end if;
          if pos = 0 then
             directory_path := null;
          else
             directory_path := substr(file_path,1,pos - 1);
          end if;
          file_name := substr(file_path,pos + 1);
       end;
       -- Procedure to append a file's contents to the e-mail
       PROCEDURE append_file(directory_path IN VARCHAR2, file_name IN VARCHAR2,
          file_type IN VARCHAR2, conn IN OUT UTL_SMTP.CONNECTION) IS
          generated_name  varchar2(30) := 'CESDIR' || to_char(sysdate,'HH24MISS');
          directory_name  varchar2(30);
          file_handle     utl_file.file_type;
          bfile_handle    bfile;
          bfile_len       number;
          pos             number;
          read_bytes      number;
          line            varchar2(1000);
          data            raw(200);
          my_code         number;
          my_errm         varchar2(32767);
       begin
          begin
             -- Grant access to the directory, unless already defined, and open
             -- the file (as a bfile for a binary file, otherwise as a text file).
             begin
                line := directory_path;
                select dd.directory_name into directory_name from dba_directories dd
                   where dd.directory_path = line and rownum = 1;
             exception
                when no_data_found then
                   directory_name := generated_name;
             end;
             if directory_name = generated_name then
                execute immediate 'create or replace directory ' || directory_name ||
                   ' as ''' || directory_path || '''';
                execute immediate 'grant read on directory ' || directory_name ||
                   ' to public';
             end if;
             if substr(file_type,1,4) != 'text' then
                bfile_handle := bfilename(directory_name,file_name);
                bfile_len := dbms_lob.getlength(bfile_handle);
                pos := 1;
                dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
             else
                file_handle := utl_file.fopen(directory_name,file_name,'r');
             end if;
             -- Append the file contents to the end of the message
             loop
                -- If it is a binary file, process it 57 bytes at a time,
                -- reading them in with a LOB read, encoding them in BASE64,
                -- and writing out the encoded binary string as raw data
                if substr(file_type,1,4) != 'text' then
                   if pos + 57 - 1 > bfile_len then
                      read_bytes := bfile_len - pos + 1;
                   else
                      read_bytes := 57;
                   end if;
                   dbms_lob.read(bfile_handle,read_bytes,pos,data);
                   utl_smtp.write_raw_data(conn,utl_encode.base64_encode(data));
                   pos := pos + 57;
                   if pos > bfile_len then
                      exit;
                   end if;
                -- If it is a text file, get the next line of text, append a
                -- carriage return / line feed to it, and write it out
                else
                   utl_file.get_line(file_handle,line);
                   utl_smtp.write_data(conn,line || crlf);
                end if;
             end loop;
          -- Output any errors, except at end when no more data is found
          exception
             when no_data_found then
                null;
             when others then
                my_code := SQLCODE;
                my_errm := SQLERRM;
                dbms_output.put_line('Error code ' || my_code || ': ' ||
                   my_errm);
          end;
          -- Close the file (binary or text)
          if substr(file_type,1,4) != 'text' then
             dbms_lob.close(bfile_handle);
          else
             utl_file.fclose(file_handle);
          end if;
          if directory_name = generated_name then
             execute immediate 'drop directory ' || directory_name;
          end if;
       end;
    begin
       -- Load the three filenames and file (mime) types into an array for
       -- easier handling later
       file_array(1) := filename1;
       file_array(2) := filename2;
       file_array(3) := filename3;
       type_array(1) := filetype1;
       type_array(2) := filetype2;
       type_array(3) := filetype3;
       -- Open the SMTP connection and set the From and To e-mail addresses
       conn := utl_smtp.open_connection(smtp_host,smtp_port);
       utl_smtp.helo(conn,smtp_host);
       recipients := from_name;
       utl_smtp.mail(conn,get_address(recipients));
       recipients := to_names;
       while recipients is not null loop
          utl_smtp.rcpt(conn,get_address(recipients));
       end loop;
       recipients := cc_names;
       while recipients is not null loop
          utl_smtp.rcpt(conn,get_address(recipients));
       end loop;
       recipients := bcc_names;
       while recipients is not null loop
          utl_smtp.rcpt(conn,get_address(recipients));
       end loop;
       utl_smtp.open_data(conn);
       -- Build the start of the mail message
       mesg := 'Date: ' || TO_CHAR(SYSDATE,'dd Mon yy hh24:mi:ss') || crlf ||
          'From: ' || from_name || crlf ||
          'Subject: ' || subject || crlf ||
          'To: ' || to_names || crlf;
       if cc_names is not null then
          mesg := mesg || 'Cc: ' || cc_names || crlf;
       end if;
       if bcc_names is not null then
          mesg := mesg || 'Bcc: ' || bcc_names || crlf;
       end if;
       mesg := mesg || 'Mime-Version: 1.0' || crlf ||
          'Content-Type: multipart/mixed; boundary="' || boundary || '"' ||
          crlf || crlf ||
          'This is a Mime message, which your current mail reader may not' || crlf ||
          'understand. Parts of the message will appear as text. If the remainder' || crlf ||
          'appears as random characters in the message body, instead of as' || crlf ||
          'attachments, then you''ll have to extract these parts and decode them' || crlf ||
          'manually.' || crlf || crlf;
       utl_smtp.write_data(conn,mesg);
       -- Write the text message or message file, if any
       if message is not null then
          mesg := '--' || boundary || crlf ||
             'Content-Type: text/plain; name="message.txt"; charset=US-ASCII' ||
              crlf ||
             'Content-Disposition: inline; filename="message.txt"' || crlf ||
             'Content-Transfer-Encoding: 7bit' || crlf || crlf;
          utl_smtp.write_data(conn,mesg);
          if instr(message,'/') = 1 or instr(message,':\') = 2 or
             instr(message,'\\') = 1 then
             split_path_name(message,directory_path,file_name);
             append_file(directory_path,file_name,'text',conn);
             utl_smtp.write_data(conn,crlf);
          else
             utl_smtp.write_data(conn,message || crlf);
          end if;
       end if;
       -- Write the HTML message or message file, if any
       if html_message is not null then
          mesg := '--' || boundary || crlf ||
             'Content-Type: text/html; name="message.html"; charset=US-ASCII' ||
             crlf ||
             'Content-Disposition: inline; filename="message.html"' || crlf ||
             'Content-Transfer-Encoding: 7bit' || crlf || crlf;
          utl_smtp.write_data(conn,mesg);
          if instr(html_message,'/') = 1 or instr(html_message,':\') = 2 or
             instr(html_message,'\\') = 1 then
             split_path_name(html_message,directory_path,file_name);
             append_file(directory_path,file_name,'text',conn);
             utl_smtp.write_data(conn,crlf);
          else
             utl_smtp.write_data(conn,html_message || crlf);
          end if;
       end if;
       -- Append the files
       for i in 1..3 loop
          -- If the filename has been supplied ...
          if file_array(i) is not null then
             split_path_name(file_array(i),directory_path,file_name);
             -- Generate the MIME boundary line according to the file (mime) type
             -- specified.
             mesg := crlf || '--' || boundary || crlf;
             if substr(type_array(i),1,4) != 'text' then
                mesg := mesg || 'Content-Type: ' || type_array(i) ||
                   '; name="' || file_name || '"' || crlf ||
                   'Content-Disposition: attachment; filename="' ||
                   file_name || '"' || crlf ||
                   'Content-Transfer-Encoding: base64' || crlf || crlf ;
             else
                mesg := mesg || 'Content-Type: application/octet-stream; name="' ||
                   file_name || '"' || crlf ||
                   'Content-Disposition: attachment; filename="' ||
                   file_name || '"' || crlf ||
                   'Content-Transfer-Encoding: 7bit' || crlf || crlf ;
             end if;
             utl_smtp.write_data(conn,mesg);
             -- Append the file contents to the end of the message
             append_file(directory_path,file_name,type_array(i),conn);
             utl_smtp.write_data(conn,crlf);
          end if;
       end loop;
       -- Append the final boundary line
       mesg := crlf || '--' || boundary || '--' || crlf;
       utl_smtp.write_data(conn,mesg);
       -- Close the SMTP connection
       utl_smtp.close_data(conn);
       utl_smtp.quit(conn);
    exception
       when utl_smtp.transient_error or utl_smtp.permanent_error then
          my_code := SQLCODE;
          my_errm := SQLERRM;
          begin
             utl_smtp.quit(conn);
          exception
             when utl_smtp.transient_error or utl_smtp.permanent_error then
                null;
          end;
          raise_application_error(-20000,
             'Failed to send mail - SMTP server down or unavailable: Error code ' ||
                my_code || ': ' || my_errm);
       when others then
          my_code := SQLCODE;
          my_errm := SQLERRM;
          raise_application_error(-20000,
             'Failed to send mail: Error code ' || my_code || ': ' || my_errm);
    end;
    Above is the code as required by you.In my original mail I have explained that how I'm calling this procedure.
    Thanks
    Saurabh

Maybe you are looking for

  • Position showing in PA30 not PPOME

    Hi, I am using ECC6 and we have a problem where some times when an action is run we can see the employee is linked to their position via their PA record , however in PPOME the employee is not showing as occupying the position. If I run RHINTE00 repor

  • TIFF Format Specification Question

    This isn't a Java-specific quesiton, but I was hoping someone here would be able to help as I have tried numerous other avenues already. I�m working with (TIFF) images that have multiple layers, and each layer can have different min/max values. I wan

  • Can't save webpage as text

    Why is it that for the last several versions of Firefox, if you try to save a webpage as a text file, it refuses to do so and defaults to htm? On the preceeding versions (24 and 25), you could click the drop down box, change the file type, then immed

  • Outline Hourglass structure

    I have a database that was created without following the usual standard outline order (not by me!!). This particular database sas Dense, Sparse, Dense, sparse, sparse,sparse, sparse. Now i have seen some strange behaviour on the database, for instanc

  • Canon 5d mk iii - no power

    my canon 5D Mk III will not power up. During a photo shoot my camera went dead and after changing the battery it never came back on (no power)