Mail sending in table format

Hi Experts,
I have a requirement to send mail to Managers with the Employee details who will report to the manager.
Selection screen will have Sender mail address, Manager E-mail Subject line and Manager E-mail text line.
The e-mail subject line should contain the value of Manager E-mail Subject line and the text of the e-mail should contain the value of the Manager E-mail text line. The E-mail should be addressed from the Sender Mail address. In addition, the value of the Manager E-mail text line, the following information should  be appended to the email.
Employee No     Employee Name        Notice level
00000001           Brown, Michael          1st Notice
00000002           Doe, jane L                4th Notice
The above details should have horizontal lines seperating the rows and vertical lines seperating the columns (like a table in word).
I am using 'SO_DOCUMENT_SEND_API1' to send the mail.  I am able to send the mail but how to format the above details in table format. My mail will look like this with e-mail text and table
This is first line of the e-mail
Employee No
Employee Name
Notice level
00000001
Brown, Michael
1st Notice
00000002
Doe, jane L
4th Notice
When displaying the details i am using SY-ULING and SY-VLINE to get the Horizantal and Vertical line respectively. But it is giving spaces in between that should not happen. The details should be placed in exact tabular format.
It is very urgent requirement. Points will be awarded for the useful answers. Requesting to give the code example...
Regards,
Yellappa.

hi,
you can embed HTML into the body of your email to get it acc to ur requirement.
Here is a very basic example of embedding HTML into the body of your email.
[nobr]report zrich_0002.
data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.
start-of-selection.
  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.
  perform build_text_message.
  perform build_receivers.
  perform send_mail_nodialog..
     Form  BUILD_TEXT_MESSAGE
form build_text_message.
  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.
  mailtxt  = '<html>'.
  append mailtxt.
  mailtxt  = '<head>'.
  append mailtxt.
  mailtxt  = '<title>Untitled Document</title>'.
  append mailtxt.
  mailtxt  = '<meta http-equiv="Content-Type"
  Content="text/html;'.
  append mailtxt.
  mailtxt  = 'charset=iso-8859-1">'.
  append mailtxt.
  mailtxt  = '</head>'.
  append mailtxt.
  mailtxt  = '<body>'.
  append mailtxt.
  mailtxt  = '<div align="center"><em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif">THIS'.
  append mailtxt.
  mailtxt  = '  IS A TEST </font></em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif"></font>'.
  append mailtxt.
  mailtxt  = '</div>'.
  append mailtxt.
  mailtxt  = '</body>'.
  append mailtxt.
  mailtxt  = '</html>'.
  append mailtxt.
endform.
     Form  BUILD_RECEIVERS
form build_receivers.
  mailrec-receiver = '[email protected]'.
  mailrec-rec_type  = 'U'.
  append mailrec.
endform.
     Form  SEND_MAIL_NODIALOG
*********************************************************form send_mail_nodialog.
  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.
endform.[/nobr]
Regards,
Gaurav
<b>Reward points if helpful</b>

Similar Messages

  • How to fire a Alert Message in a table format

    Hi friends,
    Currently im performing an Alert. My requirement is i need to display the alert message to the user in the mail in a table format.
    But i couldnt perform that, as the alert is not displaying in a properly aligned table format.
    Can you friends propose me a right way to bring the alert in a table format with two columns.
    Thanks in Advance..
    Regards,
    Saro

    I agree w 936671, do this in PL/SQL. Much, much easier.
    However, I will recommend a different approach using PL/SQL.
    1) Create a package to send the emails. Sample code:
    create or replace package cust_fnd_utilities as
    procedure send_email(     p_sender     in     varchar2,
                   p_recipient      in      varchar2,
                   p_subject     in     varchar2,
                   p_message     in     varchar2);
    end cust_fnd_utilities;
    create or replace package body cust_fnd_utilities as
    procedure send_email(     p_sender     in     varchar2,
                   p_recipient      in      varchar2,
                   p_subject     in     varchar2,
                   p_message     in     varchar2)
    is
    v_mail_host     varchar2(30);
    v_crlf      constant varchar2(2):= chr(13)||chr(10);
    v_message     varchar2(10000);
    v_mail_conn     utl_smtp.connection;
    begin
    v_mail_host := 'localhost';
    v_mail_conn := utl_smtp.open_connection(v_mail_host, 25);
    v_message :=      'Date: ' ||
         to_char(sysdate, 'dd Mon yy hh24:mi:ss') || v_crlf ||
         'From: <'|| p_sender ||'>' || v_crlf ||
         'Subject: '|| p_subject || v_crlf ||
         'To: '||p_recipient || v_crlf || '' || v_crlf || p_message;
    utl_smtp.ehlo(v_mail_conn, v_mail_host);
    utl_smtp.mail(v_mail_conn, p_sender);
    utl_smtp.rcpt(v_mail_conn, p_recipient);
    utl_smtp.data(v_mail_conn, v_message);
    utl_smtp.quit(v_mail_conn);
    exception
    when others then
         utl_smtp.close_connection(v_mail_conn);
    end send_email;
    end cust_fnd_utilities;
    2) Build the email, then call the package from step #1. Sample code:
    create or replace package cust_fnd_monitoring as
    procedure profile_options_build_email (     p_errbuf     out     varchar2,
                             p_retcode     out     varchar2,
                             p_sender     in     varchar2,
                             p_recipient     in     varchar2);                         
    end cust_fnd_monitoring;
    create or replace package body cust_fnd_monitoring as
    procedure profile_options_build_email (     p_errbuf     out     varchar2,
                             p_retcode     out     varchar2,
                             p_sender     in     varchar2,
                             p_recipient     in     varchar2)
    is
    v_subject          varchar2(100) := 'erpgamd1 - Recent Profile Option Changes';
    v_mime_type          varchar2(100) := 'Content-Type: text/html';
    v_body               varchar2(10000);
    v_line_feed          varchar2(1):=chr(10);
    cursor profile_cur is
    select     p.user_profile_option_name,
         u.user_name,
         u.description,
         r.responsibility_name,
         v.last_update_date
    from     fnd_profile_option_values v,
         fnd_profile_options_vl p,
         fnd_user u,
         fnd_responsibility_vl r
    where     p.application_id = v.application_id
    and     p.profile_option_id = v.profile_option_id
    and     v.last_updated_by = u.user_id
    and     v.level_id = 10003
    and     v.level_value = r.responsibility_id
    and      v.level_value_application_id = r.application_id
    and     r.creation_date <= '01-NOV-2010'
    and     v.last_update_date >= sysdate-7
    and     u.user_name != '204020779'
    union all
    select     p.user_profile_option_name,
         u.user_name,
         u.description,
         'Site' responsibility_name,
         v.last_update_date
    from     fnd_profile_option_values v,
         fnd_profile_options_vl p,
         fnd_user u
    where     p.application_id = v.application_id
    and     p.profile_option_id = v.profile_option_id
    and     v.last_updated_by = u.user_id
    and     v.level_id = 10001
    and     v.last_update_date >= sysdate-7
    and     u.user_name != '204020779'
    order by 5 desc,4;
    profile_rec     profile_cur%rowtype;
    begin
    open profile_cur;
    <<profile_loop>>
    loop
         fetch profile_cur into profile_rec;
         exit when profile_cur%notfound;
         if profile_cur%rowcount = 1 then
         -- We need to confirm that we fetch at least one row. Once we have confirmed, we want to generate
         -- the email body heading only during the first pass through the loop.
              v_body := '<html>' || v_line_feed;
              v_body := v_body || '<body style="font-family:arial;font-size:10pt">' || v_line_feed || v_line_feed;
              v_body := v_body || '<table cellspacing="5">' || v_line_feed;
              -- table heading
              v_body := v_body || '<tr>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>profile option name</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>responsibility name</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>last update date</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>SSO #</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>user name</u></td>' || v_line_feed;
              v_body := v_body || '</tr>' || v_line_feed;
         end if;
         -- table detail
         v_body := v_body || '<tr>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.user_profile_option_name      || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.responsibility_name          || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.last_update_date          || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.user_name                || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.description               || '</td>' || v_line_feed;
         v_body := v_body || '</tr>'|| v_line_feed;
    end loop profile_loop;
    if profile_cur%rowcount =0 then
         -- The cursor fetched no rows.
         -- send email using utl_smtp
         cust_fnd_utilities.send_email(p_sender,p_recipient,v_subject || '. No exceptions found.','No exceptions found.');
    else
         -- Generate the end of the email body if we fetched at least one row.
         v_body := v_body || '<table>' || v_line_feed || v_line_feed;
         v_body := v_body || v_line_feed || '</body>' || v_line_feed;
         v_body := v_body || '</html>' || v_line_feed;
         -- send email using utl_smtp
         cust_fnd_utilities.send_email(p_sender,p_recipient,v_subject || v_line_feed || v_mime_type,v_body);
    end if;
    close profile_cur;
    end profile_options_build_email;
    end cust_fnd_monitoring;
    3) In your alert, do not use an email action. Rather, your action should be a SQL*Plus script that calls the package from step #2.

  • Formatting of utl_mail in Table Format

    Hi ,
    Can any one please help me in formatting the mail content in table format .
    Kindly look at the code given below .
    Please do the needful.
    PROCEDURE SEND_MAIL_update IS
    vSubject Varchar2(200);
    vMsg_BODY Varchar2(2000);
    vPm_login Varchar2(200);
    vSQA_login Varchar2(200);
    vSQA_Mgr_login Varchar2(200);
    vACT_NAME Varchar2(200);
    vPLAN_DT Date;
    vTo_login Varchar2(100);
    vRole Varchar2(100);
    vStatus Varchar2(200);
    vfdback Varchar2(200);
    Cursor C_plan_dtl is select
    * from SQA_PLAN_DETAIL
    where Plan_ID_FK_=:Parameter.Plan_ID
    and PLANNED_DATE is not null;
    Begin
         vSQA_Mgr_login:=null;
         vPm_login :=null;
         vTo_login :=NULL;
         vSQA_login :=null;
    For i in C_plan_dtl loop
    select name into vACT_NAME
    From SQA_activity_master
    Where id =i.ACTIVITY_ID;
    vMsg_BODY :=vMsg_BODY||vACT_NAME||' '||to_char(i.PLANNED_DATE,'DD-Mon-YYYY')||' '||i.REMARKS||chr(10)||chr(10);
    END LOOP;     
    Begin     
    select
    feedback into vfdback from SQA_PLAN_MASTER
    where ID=:Parameter.Plan_ID;
    end;
    begin
    Begin     
    Select login||'@softsolindia.com'
    into vsqA_mgr_login
    from orzmembers_vu
    where id=(select sqa_mgr_id
    from assign_sqa
    Where id=:Parameter.Project_ID
    and rownum=1);
    Exception
         When others then
         dsp.msg('SQA Manager Mail Id Not Found'||sqlerrm);
    End;
    Begin
         Select login||'@softsolindia.com'
    into vSQA_login
    from orzmembers_vu
    where id=(select sqa_id
    from assign_sqa
    Where id=:Parameter.Project_ID
    and rownum=1);
    Exception
         When others then
         dsp.msg('SQA Mail Id Not Found'||sqlerrm);
         end;
    Begin
    Select login||'@softsolindia.com'
    into vpm_login
    from orzmembers_vu
    where id=(select manager_id
    from sqa_project_master
    Where id=:Parameter.Project_ID
    and rownum=1);
    Exception
         When others then
         dsp.msg('Project Manager Mail Id Not Found'||sqlerrm);
    End;
    * if :PARAMETER.PRS_STAT='R' and :parameter.prv_stat='N' THEN
         vStatus:='Below planned activities are reviewed'||chr(10)||chr(10)||'Activity Name Planned Date Remarks'||chr(10);
    elsif :PARAMETER.PRS_STAT='A' and :parameter.prv_stat='R' THEN     
    vStatus:='Below planned activities are approved'||chr(10)||chr(10)||'Activity Name Planned Date Remarks'||chr(10);
    else          
         vStatus:='Below is the schedule planned(Updated) for the sqa activities.'||chr(10)||'Request you to review and provide approval/feedback'||chr(10)||chr(10)||'Activity Name Planned Date Remarks'||chr(10);
         end if;               
    vRole:=fn_user_role;
    -- vSubject:='SQA Plan For Month -'||substr(:Parameter.Plan_ID,-7)||' - '||:Parameter.Plan_ID;
    vSubject:=:parameter.plan_id;
    vMsg_body:=
    --'Dear '||vTo_login||chr(10)||chr(10)||
    --'Following activities are rescheduled for the Month of - '||Substr(:Parameter.Plan_ID,-7)
    vStatus||chr(10)||chr(10)||
    vMsg_body||chr(10)||chr(10)||'Regards '||chr(10)||:Parameter.Username||chr(10)||vRole; *
    If      vsqA_mgr_login is not null and vRole = 'SQA MANAGER' and :PARAMETER.PRS_STAT='R' then
              utl_mail.send(
                   sender=>:Parameter.uid||'@softsolindia.com',
                   recipients=>vpm_login,
                   cc=>:Parameter.uid||'@softsolindia.com'||','||vsqA_login,
                   --bcc=>'[email protected]',
                   subject=>vSubject,
                   message=>vMsg_body);
                   dsp.msg('Mail Sent Successfully ');
         ElsIf      vsqA_mgr_login is not null and vRole = 'SQA MANAGER'and :parameter.ch_fdback = 'true' then
              utl_mail.send(
                   sender=>:Parameter.uid||'@softsolindia.com',
                   recipients=>vsqA_login,
                   cc=>:Parameter.uid||'@softsolindia.com'||','||vpm_login,
                   --bcc=>'[email protected]',
                   subject=>vSubject,
                   message=>vMsg_body);
                   dsp.msg('Mail Sent Successfully ');
                   :parameter.ch_fdback :='false';
    End if;
         if     vSQA_login is not null and vRole = 'SQA' then
              utl_mail.send(
    sender=>:Parameter.uid||'@softsolindia.com',
    recipients=>vsqA_mgr_login,
    cc=>:Parameter.uid||'@softsolindia.com'||','||vpm_login,
    --bcc=>'[email protected]',
    subject=>vSubject,
    message=>vMsg_body);
    dsp.msg('Mail Sent Successfully ');
         end if;
    if vpm_login is not null and vRole='PM' and :PARAMETER.PRS_STAT='A' and vfdback is not null then
              utl_mail.send(
              sender=>:Parameter.uid||'@softsolindia.com',
              recipients=>vsqA_mgr_login||','||vsqa_login,
              cc=>:Parameter.uid||'@softsolindia.com',
              --bcc=>'[email protected]',
              subject=>vSubject,
              message=>vMsg_body);
              dsp.msg('Mail Sent Successfully ');
    ELSif vpm_login is not null and vRole='PM' and :parameter.ch_fdback = 'true' then
              utl_mail.send(
              sender=>:Parameter.uid||'@softsolindia.com',
              recipients=>vsqa_login,
              cc=>:Parameter.uid||'@softsolindia.com'||','||vsqA_mgr_login,
              --bcc=>'[email protected]',
              subject=>vSubject,
              message=>vMsg_body);
              dsp.msg('Mail Sent Successfully ');
              :parameter.ch_fdback :='false';
    End if;
    Exception
         When Others then
         dsp.msg(' Unable To Send The Mail '||sqlerrm);
    end;
    :PARAMETER.Aqe := ' ';
    END;

    Hi ,
    You can use QA33 transaction for having all the information related to the inspection lot.
    Cheers,
    Tushar

  • Get-rid of the format we get using Get-ADuser in a CSV. Send CSV data in an email in table format

    Hi,
    I am using get-ADuser in order to extract a few AD attributes of some users. I export the users and their respective attributes to a CSV. However, the output in CSV i get has the following format in each cell for its AD attribute. 
    @{description=<Value>} or @ { info=<Value>}
    I have tried to use Expandproperty switch in order to get rid of it but it does not accept null values and hence if a user has no value for a said attribute, the previous value is copied for that user too. However, without expand property it gives me the
    above format in the output.
    $Desc = Get-ADUser $Username -Properties description | select description
    I would like the cells to contain only values and not this format along.
    Also, once I have the CSV with values I would also like to copy the values from CSV in an email in the form of a TABLE. I have been able to copy the content in an email using the following however, this in not in a table format. 
    $mail = Import-Csv $newlogonfile | Out-String
    Please HELP!

    Yes I am already using Export-Csv but still getting the same kind of format in output :-
    $Username = $Event.Properties[5].Value
                $Title_var = get-aduser $Username -properties Title | select Title
           $Ofc_phone = get-aduser $Username -Properties OfficePhone | select OfficePhone
           $Info_var = get-aduser $Username -properties info | select info
           $Display_Name = get-aduser $Username -properties DisplayName | select DisplayName
                $Mail = Get-ADUser $Username -Properties Mail | select Mail
           $Desc = Get-ADUser $Username -Properties description | select description
            $Props = @{ 
                    User = $Event.Properties[5].Value;
                    TimeCreated = $Event.TimeCreated;
                    LogonType = $Event.Properties[8].Value;
                    DCName = $Event.MachineName;
    Workstation_address = $Event.Properties[18].Value;
    Title = $Title_var;
    OfficePhone = $Ofc_phone;
    Info = $Info_var;
    DisplayName = $Display_Name;
            Description = $Desc;
           EMail = $Mail
                $LogonRecord = New-Object -TypeName psobject -Property $Props
                $Result += $LogonRecord
    $Result | Export-Csv -Path $logFile -append -UseCulture -NoTypeInformation # Log it to CSV
    OUTPUT has values in this format in the CSV :-
    @{info=} @{description=abc} @{DisplayName=} @{Officephone=}
    @{Mail=[email protected]}

  • Sending Email with Query Result (Table Format)

    Hi,
    I have a query result from ExecuteSQL task e.g.:
    ID Product
    1     Pencil
    2     Crayon
    3     Eraser
    I want to send an email with the above query result and I want it to be in Table format (such as in Microsoft Word with rows and column lines) to allow better readability to the receiver.
    Is it possible in SSIS?
    cherriesh

    It has to be HTML format . Read Tony's article
    http://sqlblogcasts.com/blogs/tonyrogerson/archive/2008/03/28/send-table-or-view-as-embedded-html-lt-table-gt-in-an-email-stored-procedure.aspx
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Word 2010 Send As Attachment does not send a HTML formatted mail

    Hi!
    I'm using Word 2010 to send a document by clicking File->Save & Send->Send Using E-mail->Send as Attachment.
    In the Outlook 2010  new message window I click the ribbon tab Format Text and then I select HTML as the message format.
    I continue to happily compose the HTML body and send it. On the recipient side (also Outlook 2010) the message body comes in Plain text format even tough the source email in the Sent folder is in HTML format.
    Is this a bug or am I missing something obvious?

    Hi,
    It's not a bug as I can tell, the recipient may have configured Outlook to Read all standard mail in plain text, please let the recipient check the following setting:
    Start Outlook 2010.
    Click the File tab in the Ribbon, and then click Options on the menu.
    Click Trust Center on the Options menu.
    Click the Trust Center Settings tab.
    Click E-mail Security.
    Under Read as Plain Text, check if the check box of Read all standard mail in plain text has been selected, untick it and click
    OK to save the setting.
    Send the email again to test, hopefully the recipient can receive the email as the original format.
    Good luck.
    Regards,
    Melon Chen
    TechNet Community Support

  • Send Internal table to mail with Colman name

    Hi,
    how can i send the content of internal table to mail ,
    i try to convert to HTML and send it but the problem is that i don't get the column name ,
    there is another way to send the IT with the column name ?
    any e.g will help i am stuck ....
    Regards

    you can use upto here..and then you can send html table as attachement in  the mail
    DATA:
    t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
    " Html Table
    *- Declare Internal table and Fieldcatalog
    it_fcat TYPE lvc_t_fcat WITH HEADER LINE." Fieldcatalog
    DATA: i_table TYPE REF TO data,
    wa_line TYPE REF TO data.
    FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE,
    <fs_wa> TYPE ANY.
    DATA:
    v_lines TYPE i,
    v_field(40).
    *-Fieldsymbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    PARAMETERS: p_table(30) TYPE c.
    * S T A R T - O F - S E L E C T I O N
    START-OF-SELECTION.
    *-Populate the Fieldcatalog
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    i_structure_name = p_table
    CHANGING
    ct_fieldcat = it_fcat[]
    EXCEPTIONS
    inconsistent_interface = 1
    program_error = 2.
    * Create dynamic internal table and assign to FS
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog = it_fcat[]
      IMPORTING
        ep_table = i_table.
    ASSIGN i_table->* TO <fs_tab>.
    * Create dynamic work area and assign to FS
    CREATE DATA wa_line LIKE LINE OF <fs_tab>.
    ASSIGN wa_line->* TO <fs_wa>.
    SELECT *
    FROM (p_table)
    INTO TABLE <fs_tab>
    UP TO 20 ROWS.
    * E N D - O F - S E L E C T I O N
    END-OF-SELECTION.
    *-Fill the Column headings and cell properties
    DELETE it_fcat WHERE fieldname = 'MANDT'.
    t_html-line = '<html>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '<thead>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '<tr>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '<td><h1>DB Details</h1></td>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '</tr>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '</thead>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '<table border = "1">'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '<tr>'.
    APPEND t_html.
    CLEAR t_html.
    *-Populate HTML columns from Filedcatalog
    LOOP AT it_fcat.
    CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
    it_fcat-scrtext_l
    '</th>' INTO t_html-line.
    APPEND t_html.
    CLEAR t_html.
    ENDLOOP.
    t_html-line = '</tr>'.
    APPEND t_html.
    CLEAR t_html.
    DESCRIBE TABLE it_fcat LINES v_lines.
    *-Populate HTML table from Internal table data
    LOOP AT <fs_tab> ASSIGNING <fs_wa>.
    t_html-line = '<tr>'.
    APPEND t_html.
    CLEAR t_html.
    *-Populate entire row of HTML table
    DO v_lines TIMES.
    READ TABLE it_fcat INDEX sy-index.
    CONCATENATE '<FS_WA>-' it_fcat-fieldname INTO v_field.
    ASSIGN (v_field) TO <fs>.
    t_html-line = '<td>'.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = <fs>.
    APPEND t_html.
    CLEAR t_html.
    t_html-line = '</td>'.
    APPEND t_html.
    CLEAR t_html.
    CLEAR v_field.
    UNASSIGN <fs>.
    ENDDO.
    t_html-line = '</tr>'.
    APPEND t_html.
    CLEAR t_html.
    ENDLOOP.
    t_html-line = '</table>'.
    APPEND t_html.
    CLEAR t_html.

  • Report In Table Format in Email

    Dear sir,
    i want to send mail to user in format of report of issues in table Format in Body of mail.
    Actully i want to send mail daily to user with Pending Issues of user.
    HOD allote issue to user with Close target Date .Mail would be fire till tagget date >sysdate .
    There can be Multiple issue with user.
    so i want to create a list of All pending issue in report in table which are not Closed .
    Report should be display with that column
    eg. User 0010 has 3 Pending Issue
    Issue No-----subject-----Create On-----Target Date
    001---------ABC-------27-Mar-2011-------30-Jnn-2011
    002--------BHN-------23-Jun-2011---------06-July-2011
    003--------JHN--------05-Jun-2011---------02-July-2011
    That Report Should be sent to User in mail.
    My Code is
    DECLARE
    l_id number;
    to_add varchar2(1000);
    to_sub_by varchar2(1000);
    from_add varchar2(1000);
    l_body varchar2(4000):=:P33_DESCRIPTION;
    l_sub varchar2(1000):=:P33_SUBJECT;
    I_case varchar2(10):=:P33_CASE_ID;
    I_isue_dte date:=:P33_SUBMITTED_ON;
    l_regd    varchar(100);
    CURSOR C1 IS SELECT EMAIL_ID,(SELECT EMAIL_ID FROM USER_MAS WHERE USER_ID =:P33_SUBMITTED_BY_ID) AS D FROM USER_MAS WHERE USER_GR_ID=:P33_ASSIGNED_TO_GROUP_ID AND USER_ID NOT IN(:APP_USER);
    BEGIN
    if :P33_ASSIGNED_TO_GROUP_ID is not null then
    open C1;
    LOOP
    FETCH C1 INTO to_add,to_sub_by;
    EXIT WHEN C1%NOTFOUND;
    select email_id,user_name into from_add,l_regd from user_mas where user_id=:app_user;
    l_id:=APEX_MAIL.SEND(
            p_to        => to_add, -- change to your email address
            P_cc        => to_sub_by,
            p_from      => from_add,
            p_body      => 'Issue Information'||''||chr(13)||chr(10)||chr(13)||chr(10)||
                           'www.farhorizonindia.net:7777/crm'||''||chr(13)||
                           'Issue Title'||':'||l_sub||CHR(13)||chr(10)||
                           'Issue Number'||':'||I_case||CHR(13)||
                           'Issue Open Date'||':'||I_isue_dte||''||chr(13)||chr(10)||CHR(13)||chr(10)||
                           'Most Recent Comment'||':'||''||chr(13)||chr(10)||
                           l_body||chr(13)||chr(10)||''||CHR(13)||chr(10)||'Regards'||chr(13)||chr(10)||''||l_regd||CHR(13)||chr(10)||CHR(13)||chr(10)||'Please do not reply to this email.If you wish to update the call.please login to the issue Management.',
      P_subj      => I_case ||' Issue '||l_sub);
    end loop;
    close C1;
    end if;
    COMMIT;
    apex_mail.push_queue(
    P_SMTP_HOSTNAME => '102.111.0.9',
    P_SMTP_PORTNO => 25);
    commit;
    END;How can i create that format in Body Of sending Email.
    Thanks
    Vedant
    Edited by: Vedant on Jun 30, 2011 3:44 AM
    Edited by: Vedant on Jul 5, 2011 9:17 PM

    Look at using an interactive reports and subscription routine..: http://st-curriculum.oracle.com/obe/db/apex/r40/apexirr/apexirrdev/apexirrdev_ll.htm
    Death called while you were out, so I gave him your cell number.
    Thank you,
    Tony Miller
    Webster, TX

  • Mail Send Functionality using SO_NEW_DOCUMENT_ATT_SEND_API1

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

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

  • Mail sending using sender importing parameter using so_object_send function

    Hi all,
            I using so_object_send function module to send mail. My requirement is with respect to any user 
            logged in the sender mail address should be taken by V_SENDER parameter in exporting
            parameter.
    <code>
    CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                folder_id                  = wa_folder_id
                forwarder                  = w_forwarder
                object_fl_change           = wa_object_fl_change
                object_hd_change           = wa_object_hd_change
                object_id                  = wa_object_id
                object_type                = w_object_type
                outbox_flag                = w_outbox_flag
                owner                      = w_owner
                store_flag                 = w_store_flag
           IMPORTING
                object_id_new              = wa_object_id_new
                sent_to_all                = w_sent_to_all
                sender                     =  v_sender
           TABLES
                objcont                    = i_objcont
                objhead                    = i_objhead
                objpara                    = i_objpara
                objparb                    = i_objparb
                receivers                  = i_receivers
           EXCEPTIONS
                active_user_not_exist      = 1
                communication_failure      = 2
                component_not_available    = 3
                folder_not_exist           = 4
                folder_no_authorization    = 5
                forwarder_not_exist        = 6
                note_not_exist             = 7
                object_not_exist           = 8
                object_not_sent            = 9
                object_no_authorization    = 10
                object_type_not_exist      = 11
                operation_no_authorization = 12
                owner_not_exist            = 13
                parameter_error            = 14
                substitute_not_active      = 15
                substitute_not_defined     = 16
                system_failure             = 17
                too_much_receivers         = 18
                user_not_exist             = 19
                originator_not_exist       = 20
                x_error                    = 21
                OTHERS                     = 22.
      IF sy-subrc  0.
      ENDIF.
    </code>    
    My Requirement is V_SENDER can be any user of that SAP system,noot particularly logged in user.
    I tried using this functionality my sy-subrc is zero. but i am not able to get any mails with that user name in V_SENDER.
    Do i need to do any further settings or any more code is required.
    Even i tired giving SUBMIT rsconn01 .
    still its not working.
    Please suggest any solutions if we have.
    Thanks,
    satish

    Hi,
    to send mails check this:
    FORM docu_send_email USING pv_otfdata TYPE tsfotf
    pv_emailid TYPE any
    pv_formname TYPE any.
    DATA: lv_filesize TYPE i,
    lv_buffer TYPE string,
    lv_attachment TYPE i,
    lv_testo TYPE i.
    DATA: li_pdfdata TYPE STANDARD TABLE OF tline,
    li_mess_att TYPE STANDARD TABLE OF solisti1,
    li_mtab_pdf TYPE STANDARD TABLE OF tline,
    li_objpack TYPE STANDARD TABLE OF sopcklsti1,
    li_objtxt TYPE STANDARD TABLE OF solisti1,
    li_objbin TYPE STANDARD TABLE OF solisti1,
    li_reclist TYPE STANDARD TABLE OF somlreci1,
    li_objhead TYPE soli_tab.
    DATA: lwa_pdfdata TYPE tline,
    lwa_objpack TYPE sopcklsti1,
    lwa_mess_att TYPE solisti1,
    lwa_objtxt TYPE solisti1,
    lwa_objbin TYPE solisti1,
    lwa_reclist TYPE somlreci1,
    lwa_doc_chng TYPE sodocchgi1.
    CONSTANTS: lc_u TYPE char1 VALUE 'U',
    lc_0 TYPE char1 VALUE '0',
    lc_1 TYPE char1 VALUE '1',
    lc_pdf TYPE char3 VALUE 'PDF',
    lc_raw TYPE char3 VALUE 'RAW',
    lc_ordform TYPE char15 VALUE 'ZORDCONFIRM_01',
    lc_attachment TYPE char10 VALUE 'ATTACHMENT'.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = lc_pdf
    max_linewidth = 132
    IMPORTING
    bin_filesize = lv_filesize
    TABLES
    otf = pv_otfdata
    lines = li_pdfdata
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    err_bad_otf = 4
    OTHERS = 5.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT li_pdfdata INTO lwa_pdfdata.
    TRANSLATE lwa_pdfdata USING ' ~'.
    CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.
    CLEAR lwa_pdfdata.
    ENDLOOP.
    TRANSLATE lv_buffer USING '~ '.
    DO.
    lwa_mess_att = lv_buffer.
    APPEND lwa_mess_att TO li_mess_att.
    CLEAR lwa_mess_att.
    SHIFT lv_buffer LEFT BY 255 PLACES.
    IF lv_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Object with PDF.
    REFRESH li_objbin.
    li_objbin] = li_mess_att[.
    DESCRIBE TABLE li_objbin LINES lv_attachment.
    Object with main text of the mail.
    lwa_objtxt = space.
    APPEND lwa_objtxt TO li_objtxt.
    CLEAR lwa_objtxt.
    DESCRIBE TABLE li_objtxt LINES lv_testo.
    Create the document which is to be sent
    lwa_doc_chng-obj_name = text-008.
    lwa_doc_chng-obj_descr = text-008.
    lwa_doc_chng-sensitivty = lc_0.
    lwa_doc_chng-obj_prio = lc_1.
    lwa_doc_chng-doc_size = lv_testo * 225.
    Pack to main body.
    CLEAR lwa_objpack-transf_bin.
    header
    lwa_objpack-head_start = 1.
    The document needs no header (head_num = 0)
    lwa_objpack-head_num = 0.
    body
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = lv_testo.
    lwa_objpack-doc_type = lc_raw.
    APPEND lwa_objpack TO li_objpack.
    CLEAR lwa_objpack.
    Create the attachment.
    Fill the fields of the packing_list for the attachment:
    lwa_objpack-transf_bin = gc_x .
    header
    lwa_objpack-head_start = 1.
    lwa_objpack-head_num = 1.
    body
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = lv_attachment.
    lwa_objpack-doc_type = lc_pdf.
    lwa_objpack-obj_name = lc_attachment.
    lwa_objpack-obj_descr = text-008.
    lwa_objpack-doc_size = lv_attachment * 255.
    APPEND lwa_objpack TO li_objpack.
    CLEAR lwa_objpack.
    lwa_reclist-receiver = pv_emailid.
    lwa_reclist-rec_type = lc_u.
    lwa_reclist-notif_del = gc_x.
    lwa_reclist-notif_ndel = gc_x.
    APPEND lwa_reclist TO li_reclist.
    IF li_reclist IS NOT INITIAL.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = gc_x
    TABLES
    packing_list = li_objpack
    object_header = li_objhead
    contents_bin = li_objbin
    contents_txt = li_objtxt
    receivers = li_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 sy-msgid TYPE 'I' NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDFORM. " DOCU_SEND_EMAIL

  • PO e-mail sending in 4.0B

    Hi experts, help needed:
    I configured the automatic e-mail sending for PO in two diferent environments: ECC and 4.0B.
    The only diference between the configurations is the medim, in ECC I used the medium 5 and Comunication Strategy CS01, and in 4.0B the medium 7 (the medium 5 and CS01doesn't exist in this version).
    In the ECC the automatic sending works, but in the 4.0B doesn't work, when I create the PO and enter in the "Messages" option, the system show the message:
    Error when changing mail data
         Message no. VN 362
    Diagnosis
         During the changing of the mail data, an error occured.
         o  a) when changing the template MESSAGE object during the maintenance of
            the condition record with key
         o  b) when changing the MESSAGE object to be sent during output
            processing
    Procedure
         o  a) Delete the condition record with key  and create it again.
         o  b) You cannot display or change the attributes for mail dispatch. The
            MESSAGE object can only be sent with unchanged attributes.
    I found the SAP Note 357137 (bellow) but seems the error is not related to error. Some one can help me?
    SAP Note 357137
    External e-mails from message control
    Symptom - You want to send a message to an external e-mail address. You want to format the message via a SAPscript form.
    As of Release 4.5, this function is available with the 'External send' medium (5) using a communication strategy.
    Prior to Release 4.5, the problem stems from the fact that the e-mail address of the partner was not yet stored in a uniform manner. An individual solution is therefore required.
    Cause and prerequisites Solution -
    Create a copy of the print processing program used.
    In order to be able to access BOR macros later, include Include <CNTN01> in the processing program.
    It is important that the e-mail address of the partner is obtained. You can define this address in an otherwise unused field of the partner master data, for example.
    You can use the attached report ZMAILTEST as a reference for generating the receiver and sender objects.
    It must be possible to read the e-mail address in the processing program. This procedure depends on the specific application.
    Then create a RECIPIENT object with this address. This object is used as a receiver.
    You can use the current user for the sender. A RECIPIENT object is also created from him or her.
    Enter both these objects in the parameters MAIL_RECIPIENT and MAIL_SENDER of module OPEN_FORM.
    So that OPEN_FORM sends a mail, you must also set parameter DEVICE to the value 'MAIL'.
    You can enter a specific title for the mail in parameter OPTIONS-TDTITLE.
    You can include this solution in medium 8 in the table of the processing programs. The form is specified and formatted as usual. The only difference is that calling module OPEN_FORM is modified.
    Edited by: Rafael Rossi on Jan 17, 2010 11:39 PM
    Edited by: Rafael Rossi on Jan 17, 2010 11:43 PM

    cancelled

  • Output in a Table format

    Hi,
    In PL/SQL,I am having a requirement send a mail.
    That mail has the message in table format.
    How to have output in table format.
    Please help me out.

    Create the html mail body using HTML tags. There are numerous posts on internet, try searching. Basic is you create the HTML body using HTML syntax and the mail shoudl support HTML format.
    v_htmlbody VARCHAR2(32767);
    -- Header and Body
    v_htmlbody := '<HTML> <BODY>'
    -- Prepare HTML Table Header
    v_htmlbody := v_htmlbody  || '<table border="1" cellpadding="1">';
    v_htmlbody := v_htmlbody|| '<tr>'
                                                    || '<th>' || 'Company'      || '</th>'
                                                    || '<th>' || 'Name'           || '</th>'
                                                    || '<th>' ||'Amount'          || '</th>'
                                              || '</tr>' ;
    -- Prepare HTML Table Body
    FOR rec in <cursor> LOOP
    v_htmlbody := v_htmlbody|| '<tr>'
                                                    || '<td">' || rec.company     || '</th>'
                                                    || '<td>' ||  rec.name          || '</th>'
                                                    || '<td>' ||  rec.amount       || '</th>'
                                              || '</tr>' ;
    END LOOP;
    -- End HTML Table
    v_htmlbody := v_htmlbody|| '</table>'
    -- End Header
    v_htmlbody :=v_htmlbody ||  '</BODY> </HTML>'
    -- Finally sent the v_htmlbody using mail
    {code}
    Edited by: Himanshu Binjola on Apr 25, 2012 11:27 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Mail Sending from a method

    Hi All,
    I kept  mail sending functionality in a bady.
    I kept the code in a method and i am using the Function module "SO_NEW_DOCUMENT_SEND_API1" to send the Email.But Suprig this function module returnd SY_SUBRC = 0 but when i checked in the SCOT its not showing the LOG and the mail is not going.I copied the  same code and i kept in a Report and tried but here  the Mail is sending.
    Please help how to resolve this .
    Regards
    Krishna

    Hi.
    Try using COMMIT WORK statement after the call to the FM.
    Also Check the below code.
    PARAMETERS: p_mail TYPE ad_smtpadr OBLIGATORY.
    DATA: i_mara TYPE STANDARD TABLE OF mara,  " MARA Entries
          i_marc TYPE STANDARD TABLE OF marc.  " MARC Entries
    DATA: l_text TYPE char255.  " Text
    DATA: l_lines TYPE i,
          l_size            TYPE           sood-objlen.
    " Size of Attachment
    * Mail related
    DATA: i_content         TYPE   soli_tab, " Mail content
          i_attach          TYPE   soli_tab, " Attachment
          i_attach1         TYPE   soli_tab. " Attachment
    DATA: l_send_request    TYPE REF TO    cl_bcs,
                                                " E-Mail Send Request
          l_document        TYPE REF TO    cl_document_bcs,
                                                " E-Mail Attachment
          l_recipient       TYPE REF TO    if_recipient_bcs,
                                                " Distribution List
          l_sender          TYPE REF TO    if_sender_bcs,
                                                " Address of Sender
          l_uname           TYPE           salrtdrcpt,
                                                " Sender Name(SY-UNAME)
          l_bcs_exception   TYPE REF TO    cx_document_bcs,
                                                " BCS Exception
          l_addr_exception  TYPE REF TO    cx_address_bcs,
                                                " Address Exception
          l_send_exception  TYPE REF TO    cx_send_req_bcs.
    " E-Mail sending Exception
    *Constants------------------------------------------------------------*
    CONSTANTS: c_tab(1) TYPE c VALUE
                   cl_abap_char_utilities=>horizontal_tab,
                                         " Tab Character
               c_cr(1)  TYPE c VALUE cl_abap_char_utilities=>cr_lf,
                                         " Line Feed for End-Of_line
               c_ext    TYPE soodk-objtp VALUE 'XLS'. " XLS Extension
    START-OF-SELECTION.
      SELECT * FROM mara INTO TABLE i_mara UP TO 20 ROWS.
      SELECT * FROM marc INTO TABLE i_marc UP TO 20 ROWS.
    * Preparing body of the Mail
      MOVE 'Mail Body' TO l_text.
      APPEND l_text TO i_content.
    * Creates persistent send request
      TRY.
          l_send_request = cl_bcs=>create_persistent( ).
    * Creating Document
          l_document = cl_document_bcs=>create_document(
                                        i_type  = 'RAW'
                                        i_text  = i_content[]
                                        i_subject = 'Material Details' ).
    * Preparing contents of attachment with Change Log
      PERFORM prepare_attachment.
      DESCRIBE TABLE i_mara LINES l_lines.
    * Size to multiplied by 2 for UNICODE enabled systems
          l_size = l_lines * 2 * 255.
    * Adding Attachment
          CALL METHOD l_document->add_attachment
            EXPORTING
              i_attachment_type    = c_ext
              i_attachment_size    = l_size
              i_attachment_subject = 'Material Details'
              i_att_content_text   = i_attach[].
      DESCRIBE TABLE i_marc LINES l_lines.
    * Size to multiplied by 2 for UNICODE enabled systems
          l_size = l_lines * 2 * 255.
    * Adding Attachment
          CALL METHOD l_document->add_attachment
            EXPORTING
              i_attachment_type    = c_ext
              i_attachment_size    = l_size
              i_attachment_subject = 'Material Plant Details'
              i_att_content_text   = i_attach1[].
    * Add document to send request
          CALL METHOD l_send_request->set_document( l_document ).
    * Get Sender Object
          l_uname = sy-uname.
          l_sender = cl_sapuser_bcs=>create( l_uname ).
           CALL METHOD l_send_request->set_sender
            EXPORTING
              i_sender = l_sender.
    * E-Mail
          TRANSLATE p_mail TO LOWER CASE.
        l_recipient = cl_cam_address_bcs=>create_internet_address( p_mail )
           CALL METHOD l_send_request->add_recipient
            EXPORTING
              i_recipient  = l_recipient
              i_express    = 'U'
              i_copy       = ' '
              i_blind_copy = ' '
              i_no_forward = ' '.
    *Trigger E-Mail immediately
          l_send_request->set_send_immediately( 'X' ).
          CALL METHOD l_send_request->send( ).
          COMMIT WORK.
        CATCH cx_document_bcs INTO l_bcs_exception.
        CATCH cx_send_req_bcs INTO l_send_exception.
        CATCH cx_address_bcs  INTO l_addr_exception.
       ENDTRY.
    *&      Form  PREPARE_ATTACHMENT
    FORM prepare_attachment.
      FIELD-SYMBOLS: <lfs_table>,    " Internal table structure
                     <lfs_con>.      " Field Content
      DATA: l_text TYPE char1024.     " Text content for mail attachment
      DATA: l_con(50) TYPE c.        " Field Content in character format
    * Columns to be tab delimeted
      LOOP AT i_mara ASSIGNING <lfs_table>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
                 TO <lfs_con>.
          IF sy-subrc NE 0.
            CONCATENATE c_cr l_text INTO l_text.
            APPEND l_text TO i_attach.
            EXIT.
          ELSE.
            CLEAR: l_con.
            MOVE <lfs_con> TO l_con.
            CONDENSE l_con.
            IF sy-index = 1.
              CLEAR: l_text.
              MOVE l_con TO l_text.
            ELSE.
              CONCATENATE l_text l_con INTO l_text
                 SEPARATED BY c_tab.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
      LOOP AT i_marc ASSIGNING <lfs_table>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
                 TO <lfs_con>.
          IF sy-subrc NE 0.
            CONCATENATE c_cr l_text INTO l_text.
            APPEND l_text TO i_attach1.
            EXIT.
          ELSE.
            CLEAR: l_con.
            MOVE <lfs_con> TO l_con.
            CONDENSE l_con.
            IF sy-index = 1.
              CLEAR: l_text.
              MOVE l_con TO l_text.
            ELSE.
              CONCATENATE l_text l_con INTO l_text
                 SEPARATED BY c_tab.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    ENDFORM.                    " PREPARE_ATTACHMENT
    Please treat above code just as reference...
    Hope this helps.
    Thanks,
    Balaji

  • Mail Sending issue to Outlook - Mail Request not Showing in SOST

    Hi,
    Im using mail sending logic for sending a mail to Creator of Billing. i have one itab which is having two Users with two different mail IDs. i need to send a mail to those user mail ids to Outlook
    user  Mail id
    12           XXX
    12           XXX
    13           YYY
    13           YYY
    at end of User i need to send a mail..
    loop at itab.
    at end of user.
    here sending a mail...for the first user it is sending mail perfectly..and mail request is available in SOST . once its comes to second user sending a mail getting sy-subc = 0 after SO_NEW_DOCUMENT_ATT_SEND_API1 FM..and mail request Not coming for second mail id in SOST both mails also available in Sap out box.
    endat.
    endloop.
    Kindly Help me out..
    Regards
    Dileep

    Hi,
    to send mails use this:
    FORM docu_send_email USING pv_otfdata TYPE tsfotf
    pv_emailid TYPE any
    pv_formname TYPE any.
    DATA: lv_filesize TYPE i,
    lv_buffer TYPE string,
    lv_attachment TYPE i,
    lv_testo TYPE i.
    DATA: li_pdfdata TYPE STANDARD TABLE OF tline,
    li_mess_att TYPE STANDARD TABLE OF solisti1,
    li_mtab_pdf TYPE STANDARD TABLE OF tline,
    li_objpack TYPE STANDARD TABLE OF sopcklsti1,
    li_objtxt TYPE STANDARD TABLE OF solisti1,
    li_objbin TYPE STANDARD TABLE OF solisti1,
    li_reclist TYPE STANDARD TABLE OF somlreci1,
    li_objhead TYPE soli_tab.
    DATA: lwa_pdfdata TYPE tline,
    lwa_objpack TYPE sopcklsti1,
    lwa_mess_att TYPE solisti1,
    lwa_objtxt TYPE solisti1,
    lwa_objbin TYPE solisti1,
    lwa_reclist TYPE somlreci1,
    lwa_doc_chng TYPE sodocchgi1.
    CONSTANTS: lc_u TYPE char1 VALUE 'U',
    lc_0 TYPE char1 VALUE '0',
    lc_1 TYPE char1 VALUE '1',
    lc_pdf TYPE char3 VALUE 'PDF',
    lc_raw TYPE char3 VALUE 'RAW',
    lc_ordform TYPE char15 VALUE 'ZORDCONFIRM_01',
    lc_attachment TYPE char10 VALUE 'ATTACHMENT'.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = lc_pdf
    max_linewidth = 132
    IMPORTING
    bin_filesize = lv_filesize
    TABLES
    otf = pv_otfdata
    lines = li_pdfdata
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    err_bad_otf = 4
    OTHERS = 5.
    IF sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT li_pdfdata INTO lwa_pdfdata.
    TRANSLATE lwa_pdfdata USING ' ~'.
    CONCATENATE lv_buffer lwa_pdfdata INTO lv_buffer.
    CLEAR lwa_pdfdata.
    ENDLOOP.
    TRANSLATE lv_buffer USING '~ '.
    DO.
    lwa_mess_att = lv_buffer.
    APPEND lwa_mess_att TO li_mess_att.
    CLEAR lwa_mess_att.
    SHIFT lv_buffer LEFT BY 255 PLACES.
    IF lv_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Object with PDF.
    REFRESH li_objbin.
    li_objbin] = li_mess_att[.
    DESCRIBE TABLE li_objbin LINES lv_attachment.
    Object with main text of the mail.
    lwa_objtxt = space.
    APPEND lwa_objtxt TO li_objtxt.
    CLEAR lwa_objtxt.
    DESCRIBE TABLE li_objtxt LINES lv_testo.
    Create the document which is to be sent
    lwa_doc_chng-obj_name = text-008.
    lwa_doc_chng-obj_descr = text-008.
    lwa_doc_chng-sensitivty = lc_0.
    lwa_doc_chng-obj_prio = lc_1.
    lwa_doc_chng-doc_size = lv_testo * 225.
    Pack to main body.
    CLEAR lwa_objpack-transf_bin.
    header
    lwa_objpack-head_start = 1.
    The document needs no header (head_num = 0)
    lwa_objpack-head_num = 0.
    body
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = lv_testo.
    lwa_objpack-doc_type = lc_raw.
    APPEND lwa_objpack TO li_objpack.
    CLEAR lwa_objpack.
    Create the attachment.
    Fill the fields of the packing_list for the attachment:
    lwa_objpack-transf_bin = gc_x .
    header
    lwa_objpack-head_start = 1.
    lwa_objpack-head_num = 1.
    body
    lwa_objpack-body_start = 1.
    lwa_objpack-body_num = lv_attachment.
    lwa_objpack-doc_type = lc_pdf.
    lwa_objpack-obj_name = lc_attachment.
    lwa_objpack-obj_descr = text-008.
    lwa_objpack-doc_size = lv_attachment * 255.
    APPEND lwa_objpack TO li_objpack.
    CLEAR lwa_objpack.
    lwa_reclist-receiver = pv_emailid.
    lwa_reclist-rec_type = lc_u.
    lwa_reclist-notif_del = gc_x.
    lwa_reclist-notif_ndel = gc_x.
    APPEND lwa_reclist TO li_reclist.
    IF li_reclist IS NOT INITIAL.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = gc_x
    TABLES
    packing_list = li_objpack
    object_header = li_objhead
    contents_bin = li_objbin
    contents_txt = li_objtxt
    receivers = li_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 sy-msgid TYPE 'I' NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDFORM. " DOCU_SEND_EMAIL

  • Multiple table format through email using powershell

    Hi All,
    I have a powershell script which executes a SQL Query on three SQL instances and provides the result in table format through email. The output email contains all the result of the query in a single output itself. Please help me, I have provided the code
    which I am using
    Sample output format which I am getting: 
    ServerInstance
    Databasename EnabledStatus
    Instance1 Database1
    Enable
    Instance1 Database2
    Enable
    Instance1 Database3
    Enable
    Instance2 Database1
    Enable
    Instance2 Database2
    Enable
    My requirement is I should get two table formatted email like below:
    Database status of Instance 1
    ServerInstance
    Databasename EnabledStatus
    Instance1 Database1
    Enable
    Instance1 Database2
    Enable
    Instance1 Database3
    Enable
    Database status of Instance 2
    ServerInstance
    Databasename EnabledStatus
    Instance2 Database1
    Enable
    Instance2 Database2 Enable
    #This PowerShell Scrip is well-suited with PowerShell V3.0
    #import SQL Server module
    #Import-Module SQLPS -DisableNameChecking
    #get all the instances and temporarily store them in a variable
    $ServerInstances = Get-Content "C:\SQL_Servers.txt"
    $scriptFile = "C:\restoredetails_mountdrive.sql"
    $a = "Hi All, <BR> <BR>"
    $a = $a + "Below is the TESTING Environment. This is an auto-generated mail.<BR><BR>"
    $a = $a + "<style>"
    $a = $a + "BODY{background-color:white;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 0px;width:150%;cellspacing=0 ;padding: 10px;border-style: solid;border-color: black;background-color:#43B2B2;font-family: Verdana;font-size:13 }"
    $a = $a + "TD{border-width: 0px;width:150%;cellspacing=3 ;padding: 10px;border-style: solid;border-color: black;text-align: left;background-color:white;font-family: Verdana;font-size:11}"
    $a = $a + "</style>"
    #he database we want to execute it against, regardless of the instance
    $DBName = "master"
    #iterating through all instances.
    $ServerInstances |
    ForEach-Object {
    #For each instance, we create a new SMO server object
    $ServerObject = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $_
    #use the Invoke-Sqlcmd cmdlet to execute the query
    #we are passing in the pipeline is the instance name, which is $_
    $refresh_output1 = $refresh_output1 + (Invoke-Sqlcmd `
    -ServerInstance $_ `
    -Database $DBName `
    -InputFile $scriptFile
    #-Query $SQLQuery
    [string]$tst = $refresh_output1 |convertTo-Html -Head $a -property InstanceName, DatabaseName,OverallStatus | Out-String
    write-output " "
    [System.Net.Mail.MailMessage]$message = New-Object System.Net.Mail.MailMessage("emailid.com", "toemailid.com", "Subject", $tst )
    [System.Net.Mail.SmtpClient]$client = New-Object System.Net.Mail.SmtpClient("smtpserver",25)
    $Message.IsBodyHtml = $true
    $client.Timeout = 100
    $client.Send($message)

    Generally it's best to post in the Hey Scripting Guy forum, they are scarily good in there. Someday i hope to give an answer so perfect that not even jrv can improve on it.
    Your approach might be possible but it's not the way i'd do it. The ConvertTo-HTML is pretty clever, it works well with arrays of objects. If you were to load each result into a custom PSObject then add that to an array of them for later processing you can
    get the table formatting almost for free.
    I haven't worked with SQL queries in a bit but this might work, it seems ok when i put token results in for the SQL result.
    #This PowerShell Scrip is well-suited with PowerShell V3.0
    #import SQL Server module
    #Import-Module SQLPS -DisableNameChecking
    #get all the instances and temporarily store them in a variable
    $ServerInstances = Get-Content "C:\SQL_Servers.txt"
    $scriptFile = "C:\restoredetails_mountdrive.sql"
    $a = "Hi All, <BR> <BR>"
    $a = $a + "Below is the TESTING Environment. This is an auto-generated mail.<BR><BR>"
    $a = $a + "<style>"
    $a = $a + "BODY{background-color:white;}"
    $a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
    $a = $a + "TH{border-width: 0px;width:150%;cellspacing=0 ;padding: 10px;border-style: solid;border-color: black;background-color:#43B2B2;font-family: Verdana;font-size:13 }"
    $a = $a + "TD{border-width: 0px;width:150%;cellspacing=3 ;padding: 10px;border-style: solid;border-color: black;text-align: left;background-color:white;font-family: Verdana;font-size:11}"
    $a = $a + "</style>"
    #he database we want to execute it against, regardless of the instance
    $DBName = "master"
    #Create an empty object collection
    $objectCollection = @()
    #iterating through all instances.
    $ServerInstances |
    ForEach-Object {
    #For each instance, we create a new SMO server object
    $ServerObject = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $_
    #use the Invoke-Sqlcmd cmdlet to execute the query
    #we are passing in the pipeline is the instance name, which is $_
    $SQLResult = (Invoke-Sqlcmd `
    -ServerInstance $_ `
    -Database $DBName `
    -InputFile $scriptFile
    #-Query $SQLQuery
    $objectCollection += New-Object -TypeName PSObject -Property @{
    "InstanceName" = $_ ;
    "DatabaseName" = $DBName ;
    "OverallStatus" = $SQLResult["OverallStatus"];
    $objectCollection | ConvertTo-Html -Fragment
    [System.Net.Mail.MailMessage]$message = New-Object System.Net.Mail.MailMessage("emailid.com", "toemailid.com", "Subject", $objectCollection)
    [System.Net.Mail.SmtpClient]$client = New-Object System.Net.Mail.SmtpClient("smtpserver",25)
    $Message.IsBodyHtml = $true
    $client.Timeout = 100
    $client.Send($message)

Maybe you are looking for

  • Error loading from database

    I have a .wft file and two databases: Deploy and Production. If I save the .wft file to Production it works fine but if I save it to Deploy I get when Uploading from database: 1300: Could not load. 1114: Could not load from database. 1115: Could not

  • Missing Datamarts in the Infosource Screen

    Hi, I needed to experiment loading from an infocube to another infocube for some re-modeling to be done at the clients side. The problem I am facing is none of the datamart datasources are showing up on the infosources tab. They appear under the BWSy

  • Flash policy problem?

    Anybody know what that means, or how to fix it? IRC windows fails.

  • Triggers in a database

    Hi, How to find what are all the user defined triggers present in a database? Thanks Aravindh

  • The Last resort for my Ipod Nano

    I have 4 mb Ipod nano that dosent respond. I've tried the 5R's, when connecting it to my PC, ituens dosen't recognise it, and its dosen't charge when connecting to the mains. It's less than 6 months old so it should'nt be a battery problem! if it is