Attachment sent thru mail in PL/SQL code.

Hi.
I have a requirement..
I have to send bunch of an error description thru mail along with attachment says xls.All error should be club in xls and should be sent these attachement thru EMAIL.
Please provide a sample code for the same.
I have a code that mail can be send with the help of oracle supplied package UTL_SMTP.But how can I send the attachement thru mail.
Please provide a sample code.
Thanks

Hi!
Check this sample code - i don't know whether that satisfy ur requirement or not ------
CREATE OR REPLACE PROCEDURE CALL_SEND_MAIL
                         (p_sender varchar2,
                         p_recipients varchar2,
                         p_subject varchar2,
                         p_mailbody varchar2,
                         p_attachment varchar2 ) IS
v_recipients VARCHAR2(1000):=null;
flag          number:=0;
fil BFILE;
file_len PLS_INTEGER;
MAX_LINE_WIDTH PLS_INTEGER := 54;
buf RAW(2100);
amt BINARY_INTEGER := 2000;
pos PLS_INTEGER := 1; /* pointer for each piece */
filepos PLS_INTEGER := 1; /* pointer for the file */
v_file_name VARCHAR2(100) ; /* ascii file attachment */
v_file_handle UTL_FILE.FILE_TYPE;
v_directory_name VARCHAR2(100) := '/utlpath';
v_line VARCHAR2(1000);
conn UTL_SMTP.CONNECTION;
mesg VARCHAR2(32767);
mesg_len NUMBER;
crlf VARCHAR2(2) := chr(13) || chr(10);
data RAW(2100);
chunks PLS_INTEGER;
len PLS_INTEGER;
modulo PLS_INTEGER;
pieces PLS_INTEGER;
err_num NUMBER;
err_msg VARCHAR2(100);
v_subject     VARCHAR2(200);
v_mailbody varchar2(1000);
CURSOR C1 (p_proc_code varchar2) IS
select mail_id
from mat.mmat_mail
where mail_proc_code=p_proc_code
and mail_active='Y';
BEGIN
v_file_name := p_attachment;
if p_subject is null then
BEGIN
SELECT mail_subject
INTO v_subject
FROM mat.mmat_mail
WHERE mail_proc_code='VENDEXCH'
AND mail_subject is not null
AND rownum < 2;
EXCEPTION
WHEN no_data_found then
v_subject:=null;
END;
else
v_subject:=p_subject;
end if;
if p_mailbody is null then
BEGIN
SELECT mail_message
INTO v_mailbody
FROM mat.mmat_mail
WHERE mail_proc_code='VENDEXCH'
AND mail_message is not null
AND rownum < 2;
EXCEPTION
WHEN no_data_found then
v_mailbody:=null;
END;
else
v_mailbody:=p_mailbody;
end if;
if instr(p_recipients,'@') = 0 then
for vc1 in c1(p_recipients) loop
     flag:=flag+1;
     if flag=1 then
          v_recipients:=vc1.mail_id;
     else
          v_recipients:=v_recipients||', '||vc1.mail_id;
     end if;
     end loop;
else
v_recipients:=p_recipients;
end if;
BEGIN
conn := mat.send_mail.begin_mail(
sender => p_sender,
recipients => v_recipients,
subject => v_subject,
mime_type => mat.send_mail.MULTIPART_MIME_TYPE);
END begin_mail;
BEGIN
mat.send_mail.attach_text(
conn => conn,
data => v_mailbody,
mime_type => 'text/html');
END attach_text;
if v_file_name is not null then
BEGIN
mat.send_mail.begin_attachment(
conn => conn,
mime_type => 'text/plain',
inline => TRUE,
filename => v_file_name,
transfer_enc => '7 bit');
begin
v_file_handle := utl_file.fopen(v_directory_name, v_file_name, 'r');
loop
utl_file.get_line(v_file_handle, v_line);
mesg := v_line || crlf;
mat.send_mail.write_text(conn => conn, message => mesg);
end loop;
exception
when others then
null;
end;
utl_file.fclose(v_file_handle);
mat.send_mail.end_attachment(conn => conn );
END begin_attachment;
end if;
mat.send_mail.end_mail(conn => conn);
exception
when no_data_found then
mat.send_mail.end_attachment( conn => conn );
dbms_lob.fileclose(fil);
when others then
mat.send_mail.end_attachment( conn => conn );
err_num := SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 100);
dbms_output.put_line('Error number is ' || err_num);
dbms_output.put_line('Error message is ' || err_msg);
dbms_lob.fileclose(fil);
END;
Regards.
Satyaki De.

Similar Messages

  • Error in opening pdf file from mail attachment sent thru MII

    Hi,
    I am using MII 12.1.4 build(36).
    I have created a pdf file from BLS using PDF actions block and saving the file in web location as mentioned below:
    WEB://<ProjectFolder>/<subfolder>/Report.pdf
    I'm using the same file as attachment in my m a i l action block with attachment content type "application/pdf" and AttachmentContent "ImageSaver.EncodedImage" or "PDFDoc.Output".
    When i check the mail,i can see the attachment with some size of 8kb,but when I open the file i will get below error:
    "Adobe Reader could not open Report.pdf because it is either not supported file type or because the file has been damaged(for example,it was sent as an m a i l attachment and wasn't correctly decoded)"
    If I try to open the same file by exporting fit to my desktop,it opened properly.
    Anything I'm missing here?
    Thanks in Advane,
    Suresh

    Hi,
    According to below mentioned thread,this problem is fixed in 12.1.5 and above.
    Re: Attachment Content When sending PDF attachment in Send Mail Step
    Then I deployed the new patch ie SP07.
    Here there is one problem,ie in Menu page I can see the 12.1.7(Build40),when I open the workbech,it shows the previous patch 12.1.4(Build 36).Why is it so?
    All of my transactions running fine except the one which I have mentioned in my previous post.
    When I run the transaction mentioned in my previous post,it threw an excption for PDF Table Action block and the error mentioned below:
    [ERROR] Error found trying to execute action 'PDF_Table_0' Exception: [null]
    [ERROR] [PDF_Table_0] Action: Runtime threw an exception. Exception: [java.lang.StackOverflowError]
    When I can check the m a i l, I'm able to open the attached PDF file without error but without data.Is it because of the above mentioned error?
    Plz help me.
    -Suresh

  • Error while opening PDF attachment sent via mail

    Hi,
    I am attaching PDF file to PO in me22n and sending the same file as attachment in the mail to the vendor using class CL_BCS.
    The mail is sent to the vendor successfully and they are able to successfully open the PDF attachment. But in some cases the mail is successfully received but while opening the attachment it is giving the error as file is corrupted.
    Please help me to resolve this issue.
    Thanks and regards,
    Jayashree

    Hi,
    I would like to know what font type, you are using in the forms.
    Ideally it should be HELVETICA .
    If you are using any other font in your style/form,try changing it to HELVETICA & Test.
    Also Check the OTF data at the call of gen. FM,before converting it to PDF.
    Regds,
    AS
    Edited by: abheesawant on Oct 12, 2011 7:48 AM

  • Error while openeing PDF attachment sent thru smartform

    Hi,
    I have tried all the options and also gone thru all the quries and replies in SDN but could not find answer for this.
    I have developed a smart from with some table fetch data from PAYR. Now i have written an ABAP code to sent the output of a smartform as PDF in the email.
    Im getting an error "There was an error openeing htis doc and file is damaged and coul dnot be repaired".
    Here is my code.
    CLEAR WA_BUFFER.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    CLEAR: I_RECORD. REFRESH: I_RECORD.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    I_OBJBIN] = I_RECORD[.
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 1.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-DOC_SIZE = ( v_lines_bin - 1 ) * 255 + strlen( i_objbin ).
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    I_RECLIST-RECEIVER = 'ABC.gmail.com'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_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.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    Pls help me in sloving out this.
    Thanks.

    Sounds familiar but not sure. Have you tried using OTF format in stead of PDF and in the file name use document.pdf??

  • Password Protect Attachment file thru Mail from BO

    I am generating WebI report and this report (in the format of excel/pdf) will be send to the list of users through mail.
    When the user open the attachment, it should prompt for password and open the same once password match.

    >
    Sonal Jain wrote:
    But how can i convert the PDF to folder and than how can i zip that folder with password protection.
    Not folder but file (I do hope you understand the difference). Have you tried to search SDN at all? I don't have much time, but before replying initially I did just a quick search and it brought several posts mentioning the archiving functionality. And I'm sure 'Smartform to PDF' will bring up gozillion posts. Also I find the Google search with addition 'site:sap.com' to be quite helpful.
    However, I would still recommend to review the requirements. Why exactly do you need this password protection? If there is a fear that someone other than a recipient might get access to the email account then there is really a bigger security issue in the organization and it should be resolved by some other means. As I have mentioned, password does not really add much protection.
    Out of curiosity I briefly looked at the IRM description on the Microsoft's web site and it doesn't seem to be very helpful. First of all, it's the MS software and has to be installed on the user's PC and configured (how do we know the emai recipients are even on Windows?). Also it does say "Prevent an unauthorized recipient from accessing e-mail content", but I didn't quite get how exactly. Is there a retinal scan that comes with it? And the list of things it does not do gives you the whole another perspective on the email security.

  • SO_NEW_DOCUMENT_ATT_SEND_API1 pdf attachment sending thru mail ecc 6.0

    Hi All,
    I'm using ECC 6.0 version, I'm trying to attach a pdf file to a mail using the function module SO_NEW_DOCUMENT_ATT_SEND_API1. But gtting error as "wasn't decoded correctly", but the same coding is working fine in 4.6 version. What changes i should do while using this function module in ECC 6.0 to get it corrected.
    Thanks & Regards,
    Sabu.

    Hi ,
    I tried with SBWP, I'm able to see the pdf file attached while sending from SBWP.
    Please see the below coding
          FORM make_the_message                                         *
    FORM make_the_message.
    Create Message Body
    Title and Description
      CLEAR : docdata,
              objtxt[],
              objpack[],
              objbin[].
      docdata-obj_name  = sy-repid.
      docdata-obj_descr = p_subj.
    Main Text
      LOOP AT gt_text INTO objtxt.
        APPEND objtxt.
      ENDLOOP.
    Write Packing List (Main)
      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.
    Sabu
      objpack-doc_type   = 'RAW'.
    objpack-doc_type   = 'PDF'.
    End Sabu
      APPEND objpack.
    *Start of Upgrade ECC 6.0
      Data: l_mi_bytecount TYPE i.
    *End of Upgrade ECC 6.0
    Create Message Attachment (As read earlier from frontend)
    Write Packing List (Attachment)
    Handle the attached file.
      objbin[] = gt_pdffile[].
      att_type = 'PDF'.
      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.
    *****Sabu 8496
    objpack-head_num   = 0.
      objpack-head_num   = 1.
    End Sabu
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
    *Start of Upgrade ECC 6.0
      objpack-doc_type   = att_type.
      objpack-obj_name   = 'ATTACHMENT.pdf'.
      objpack-obj_descr  = 'Attached Document'.
    *End of Upgrade ECC 6.0
      APPEND objpack.
    Create receiver list
    Generate ALV list for either Customers/Vendors/Contact persons etc.
    ENDFORM.                    "make_the_message
          FORM fill_the_distribution_list                               *
    FORM fill_the_distribution_list USING i_test
                                          i_fax
                                          i_faxcntry
                                          i_email.
    Just as a test...
      CLEAR: reclist, reclist[].
      IF i_test EQ 'X'.
        CASE 'X'.
          WHEN p_sndfax.
          By Fax
            rec_fax-rec_fax   = i_fax.
            rec_fax-rec_state = i_faxcntry.
    Start of Changes 07/09/2008
           reclist-receiver  = rec_fax.
            ASSIGN reclist-receiver TO <fs_reclist> CASTING.
            <fs_reclist> = rec_fax.
           rec_fax = <fs_reclist>.
    End of Changes 07/09/2008
            reclist-rec_type  = 'F'.
            APPEND reclist.
          WHEN p_sndint.
          By Email
            reclist-receiver = i_email.
            reclist-rec_type = 'U'.
            reclist-BLIND_COPY = 'X'.
            APPEND reclist.
        ENDCASE.
      ELSE.
      This is not a test....
        LOOP AT gt_detail INTO gs_detail.
          CHECK gs_detail-flag EQ icon_green_light.
          CASE 'X'.
            WHEN p_sndfax.
            By Fax
              rec_fax-rec_fax   = gs_detail-faxnr.
              rec_fax-rec_state = gs_detail-land1.
    Start of Changes 07/09/2008
              ASSIGN reclist-receiver TO <fs_reclist> CASTING.
              <fs_reclist> = rec_fax.
              rec_fax = <fs_reclist>.
             reclist-receiver  = rec_fax
    End of Changes 07/09/2008
              reclist-rec_type  = 'F'.
              APPEND reclist.
            WHEN p_sndint.
            By Email
              reclist-receiver = gs_detail-email.
              reclist-rec_type = 'U'.
              reclist-BLIND_COPY = 'X'.
              APPEND reclist.
          ENDCASE.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    "fill_the_distribution_list
          FORM send_the_messages                                        *
    FORM send_the_messages.
    Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
              document_data                    = docdata
              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
            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.
      ELSE.
        PERFORM popup.
      ENDIF.
    ENDFORM.                    "send_the_messages
    Thanks & Regards,
    Sabu

  • Mail sent thru background job doesnt have all pages in attachment

    Hi Experts,
    We developed a program where the output is triggered by calling a smart form. We schedule a background job and we updated the mail address in Spool list recipent. After succesfull execution of job we checked the spool it is around 30 pages but the attachement in the mail has only 3 pages. we are not sure where the exact problem is. Can any one help us in this regard so that we can able to check and fix this issue. Thanks.

    Hi
    To check whether mail is generated you can create dynamic break-point with SAAB transaction.
    Using this transaction you create a memory area for your jobs where you can load any data value of your report..
    Probably something goes wrong with COMMIT of Mail Function module system.
    Hope to help..

  • How to send an attachment thru mail in SAP?

    Hi all,
    I have an file which has been sent by the customer. The file type may vary each & every week (sometimes XLS, sometimes CSV & sometimes notepad). This file has to be sent to another person thru mail as an attachment.
    Is it possible to send thru the fun mod 'SO_SEND_NEW_*'.
    If so how to send as attachment. If not thru this fun mod, how to send?
    Thanks,
    Vijay.

    I am enclosing the sample code to trigger an email, The logic for this is in comments, check this I am shure yuor problem will be solved.
    *& Report ZGBL_SLA_PER
    REPORT zgbl_sla_per NO STANDARD PAGE HEADING LINE-COUNT 26(3) MESSAGE-ID
    zmsg2.
    DECLARATION OF DB TABLES
    TABLES: zncrfid, zrule_id.
    DECLARATION OF INTERNAL TABLES
    DATA: BEGIN OF ncrf OCCURS 0,
    zncrf_id(15) TYPE c,
    zncrf_l4_name(60) TYPE c,
    z9gl_sla_flag(1) TYPE c,
    zowners(30) TYPE c,
    zowners_value(30) TYPE c,
    zdate_changed(8) TYPE n,
    ztime_changed(6) TYPE n,
    END OF ncrf.
    *DATA: NCRF LIKE ZNCRFID OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF it_ruleid OCCURS 0,
    zrule_id(10) TYPE c,
    zowners(30) TYPE c,
    zowners_value(30) TYPE c,
    END OF it_ruleid.
    *data: wa like ncrf occurs 0 with header line.
    DATA: BEGIN OF itab OCCURS 0,
    zncrf_id(15) TYPE c,
    zncrf_l4_name(60) TYPE c,
    z9gl_sla_flag(1) TYPE c,
    zowners(30) TYPE c,
    zowners_value(30) TYPE c,
    zdate_changed(8) TYPE n,
    ztime_changed(6) TYPE n,
    END OF itab.
    data: file(10) type c,
    dates type date.
    EMAIL DECLARATION
    *CONSTANTS: c_subject LIKE sodocchgi1-obj_descr VALUE 'Subject',
    *c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
    *DATA: g_time TYPE char8,
    *g_email(40) TYPE c,
    *g_sent_all(1) TYPE c,
    *g_doc_data LIKE sodocchgi1,
    *g_error TYPE sy-subrc.
    *DATA: i_message LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    *i_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    *i_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
    *DATA: BEGIN OF mailid OCCURS 0,
    zemail_id TYPE zrule_id-zemail_id,
    END OF mailid.
    *data: mailid like zrule_id occurs 0 with header line.
    UPLOADING FLAT FILE TO INTERNAL TABLE NCRF
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'C:\VAMSY\file.txt'
    filetype = 'ASC'
    has_field_separator = 'X'
    HEADER_LENGTH = 0
    READ_BY_LINE = 'X'
    DAT_MODE = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    CHECK_BOM = ' '
    IMPORTING
    FILELENGTH =
    HEADER =
    TABLES
    data_tab = ncrf[]
    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
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ELSE.
    IF sy-subrc EQ 0.
    Checking internal table ncrf is empty then
    *delete records from TABLE ZNCRF_ID ******************************
    IF ncrf[] IS INITIAL.
    MESSAGE i003(ZMSG2).
    ELSE.
    DELETE FROM zncrfid.
    ENDIF.
    *****Values are read from rule table and checking owner and owner_value
    *from zrule_id table and inserted into ZNCRFID **************
    SELECT * FROM zrule_id INTO CORRESPONDING FIELDS OF TABLE it_ruleid
    WHERE zrule_id IN ('OWNER1', 'OWNER2').
    append IT_RULEID.
    LOOP AT ncrf WHERE z9gl_sla_flag EQ 'Y'.
    READ TABLE it_ruleid WITH KEY zowners = ncrf-zowners
    zowners_value = ncrf-zowners_value.
    IF ncrf-zowners = it_ruleid-zowners AND ncrf-zowners_value =
    it_ruleid-zowners_value AND ncrf-z9gl_sla_flag ='Y'.
    itab-zncrf_id = ncrf-zncrf_id.
    itab-zncrf_l4_name = ncrf-zncrf_l4_name.
    itab-z9gl_sla_flag = ncrf-z9gl_sla_flag.
    itab-zdate_changed = sy-datum.
    itab-ztime_changed = sy-uzeit.
    itab-zowners = it_ruleid-zowners.
    itab-zowners_value = it_ruleid-zowners_value.
    APPEND itab.
    ENDIF.
    ENDLOOP.
    modify database table zncrfid FROM ITAB
    LOOP AT itab.
    WRITE:/ itab-zncrf_id, itab-zncrf_l4_name, itab-z9gl_sla_flag,
    itab-zowners, itab-zowners_value, itab-zdate_changed,
    itab-ztime_changed.
    zncrfid-zncrf_id = itab-zncrf_id.
    zncrfid-zncrf_l4_name = itab-zncrf_l4_name.
    zncrfid-z9gl_sla_flag = itab-z9gl_sla_flag.
    zncrfid-zowners = itab-zowners.
    zncrfid-zowners_value = itab-zowners_value.
    zncrfid-zdate_changed = itab-zdate_changed.
    zncrfid-ztime_changed = itab-ztime_changed.
    INSERT INTO zncrfid VALUES zncrfid.
    ENDLOOP.
    ENDIF.
    ENDIF.
    *CALL FUNCTION 'DATE_TO_DAY'
    EXPORTING
    DATE = sy-datum
    IMPORTING
    WEEKDAY = file.
    **CHECKING FOR THE FIRST MONDAY OF THE MONTH.
    dates = sy-datum.
    shift dates by 6 places left.
    if file CO 'monday' and dates < 7 and dates >= 1.
    else.
    message e004(zmsg2).
    endif.
    EMAIL SEND TO OWNERS LIST
    **Fill the mail body in i_message.
    get email id's from database into internal table et_mailid
    Fill the document data.
    *g_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
    *g_doc_data-obj_langu = sy-langu.
    *g_doc_data-obj_name = 'SAPRPT'.
    *g_doc_data-obj_descr = c_subject .
    *g_doc_data-sensitivty = 'F'.
    Describe the body of the message
    Information about structure of data tables
    *CLEAR i_packing_list.
    *REFRESH i_packing_list.
    *i_packing_list-transf_bin = space.
    *i_packing_list-head_start = 1.
    *i_packing_list-head_num = 0.
    *i_packing_list-body_start = 1.
    *DESCRIBE TABLE i_message LINES i_packing_list-body_num.
    *i_packing_list-doc_type = 'RAW'.
    *APPEND i_packing_list.
    Add the recipients email address
    *LOOP AT mailid.
    *CLEAR i_receivers.
    *i_receivers-receiver = mailid-zemail_id.
    *i_receivers-rec_type = 'U'.
    *i_receivers-com_type = 'INT'.
    *i_receivers-notif_del = 'X'.
    *i_receivers-notif_ndel = 'X'.
    *APPEND i_receivers.
    *ENDLOOP.
    Call the FM to post the message to SAPMAIL
    *CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    *EXPORTING
    *document_data = g_doc_data
    *put_in_outbox = 'X'
    *commit_work = 'X'
    *IMPORTING
    *sent_to_all = g_sent_all
    *TABLES
    *packing_list = i_packing_list
    *contents_txt = i_message
    *receivers = i_receivers
    *EXCEPTIONS
    *too_many_receivers = 1
    *document_not_sent = 2
    *document_type_not_exist = 3
    *operation_no_authorization = 4
    *parameter_error = 5
    *x_error = 6
    *enqueue_error = 7
    *OTHERS = 8.
    Store function module return code
    *g_error = sy-subrc.
    Get i_receivers return code
    *LOOP AT i_receivers.
    *ENDLOOP.
    **Instructs mail send program for SAPCONNECT to send email(rsconn01)
    *WAIT UP TO 2 SECONDS.
    *IF g_error EQ 0.
    *SUBMIT zgbl_sla_per WITH mode = 'INT'
    *WITH output = 'X'
    *AND RETURN.
    REWARD IF FOUND USEFULL,
    Cheers,

  • Sent a mail with an attachment

    Hi,
    I already create a package to sent a mail.
    to run the package I create this code:
    begin
    Gen_Ces_Mail.email_files( '[email protected]' -- from adress
    , '[email protected]' --to adress
    , 'test mail' -- objective
    , 'message: test message' --message
    end;
    But can any one help me to mail also pdf files in this code?
    regards,
    Kasban.Ernesto

    see this link send mail with UTL_SMTP - with attachements for some sample code

  • How do I change the phone number attached to my Icloud? All the codes and stuff are being sent to my old number.

    How do I change the phone number attached to my Icloud? All the codes and stuff are being sent to my old number.

    Hello Babyygrl23,
    Welcome to the Apple Support Communities!
    It sounds like your iCloud Apple ID has a phone number associated with it that you would like to update. If this is the case, after signing in to the linked website below, you will see a section on the left side of the screen labeled Phone Numbers. You can edit the phone number associated with that account from there. 
    Apple - My Apple ID
    Cheers,
    Joe

  • How to send other language data into excel file in attachment thru mail

    Hi - ,
    I have to send other language data (russian) into excel file and send as an attachment through e-mail.
    I had used F.M SO_NEW_DOCUMENT_ATT_SEND_API1 to send email.
    In internal table , it is in correct format, but when using SO_NEW_DOCUMENT_ATT_SEND_API1, the excel file sent has junk characters in it.
    Can u please help me on this?
    Thanks,
    Gyanaraj

    Hi ,
    Can anyone help me on this.
    Thanks,
    Gyanaraj

  • ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION

    HOW TO ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION (CREATE CONTACT PERSON) IN SRM PORTAL..

    HOW TO ADD ATTACHMENT TO AUTO MAIL SENT DURING BIDDER CREATION (CREATE CONTACT PERSON) IN SRM PORTAL..

  • Mail Corrupts Files Sent Thru .Mac

    My girlfriend uses .Mac as her mail service. She uses Apple Mail as her mail client, I use Google/Safari. I continually get files from her that wind up in the Google inbox as NONAME, with the file extension stripped off, and/or the resource fork separated from the file. In nearly all cases these files are unusable, although I sometimes can force NONAME files that came from Word to open with MacLink Plus. Others are so corrupt it's impossible to get them open.
    I did some experimentation and found that files sent using the web-based .Mac mail via Safari do not have this problem. The exact same file from the same machine sent through .Mac using Mail has the problem described above. I know Google has issues with Mac files. What I don't understand is why a file sent thru the .Mac web interface is okay but files sent thru .Mac using the Mail client are not. Have tried "Windows-Friendly Attachments" on and off and it makes no difference in either case.
    I've seen lots of other posts about similar issues but no solutions. Anyone have any ideas?
    JapanGuy

    Some email servers corrupt PDF files because they use the wrong encoding for them. Try zipping them up before sending them.

  • Send mail from PL/SQL with an attachment

    Hi,
    Can any body help me on how to send a mail from PL/SQL with an attachment which is located on a unix system path.
    This is an urgent requirement in my current project. Any quick reply would be greatly appreciated.
    Thanks
    Kumar.

    Quick reply (too bad you didn't mention your DB-version):
    Check the docs @ http://tahiti.oracle.com regarding packages UTL_SMTP and UTL_MAIL
    Check http://asktom.oracle.com/pls/asktom/asktom.search?p_string=%22mail+attachment%22
    Check http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    Check http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#UTL_MAIL

  • Capture mail with Attachment from POP server using PL/SQL

    Hey guys,
    With the help of this forum and Billy I am able to capture the email from POP3 server and display it to the user. But my query is how can I get an Attachment from the email using PL/SQL's UTL-TCP method ? Right now it displays some encrypted code.
    Thanks.

    Hey guys,
    With the help of this forum and Billy I am able to capture the email from POP3 server and display it to the user. But my query is how can I get an Attachment from the email using PL/SQL's UTL-TCP method ? Right now it displays some encrypted code.
    Thanks.

Maybe you are looking for