Send pdf email attachment
Hi,
I m running the custom concurrent program through pl-sql code and sending the output of the same conc program on to the email id of vendor.
When i was tryng to send the output in text file it was allowing me to send the text message as well as attachment.
But with the same code I want to send the pdf output.
so earlier I was using the UTL_MAIL.send_attach_varchar2 .
And for pdf attachment I am using the UTL_MAIL.send_attach_raw.
So custom program is generating the output but
while sending an email, it is not attaching the output into the email.
What could be the problem.
Please help as I needed it urgently.
revert me if anyone has any query.
Thanks,
Bluetooth_25
No it's not generating the .pdf file.
It's only generating the .out file.
so is that the possibility that it is not attaching the pdf in email.
Here is my code:
/*Variable declaration*/
fhandle UTL_FILE.file_type;
flen NUMBER;
bsize NUMBER;
ex BOOLEAN;
vtextout RAW (32767);
UTL_FILE.fgetattr ('EMAIL_OUTPUT','o'||v_request_id ||'.out',ex,flen,bsize);
fhandle := UTL_FILE.fopen('EMAIL_OUTPUT','o'||v_request_id ||'.out', 'r');
LOOP
BEGIN
UTL_FILE.get_raw (fhandle,vtextout,flen);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
EXIT;
END;
END LOOP;
UTL_FILE.fCLOSE(fhandle);
FOR email_rec in c2_vendor_email_add(po_rec.po_header_id)
LOOP
UTL_MAIL.send_attach_raw
sender => '[email protected]',
recipients => email_rec.email_address,
subject => 'Testmail',
MESSAGE => 'This is test mail',
attachment => vtextout,
att_mime_type =>'application/pdf',
att_filename =>'o'||v_request_id ||'.out'
and i have one more question how to send an email to multiple recipients using utl_mail.send_attach_raw
Similar Messages
-
Hi Friends,
I need expertise help in pdf email attachment. I have data in internal table which has to be sent as pdf mail attachment. I need help in converting the data to pdf format. After conversion I can use SO_NEW_DOCUMENT_ATT_SEND_API1 to send the mail.
Expect earliest reply.
Thanks,
NidhyaDear Friends,
Thanks for your reply, but I need help in converting the data in internal table to pdf.
Pls find my code below: With this code, I get email send with PDF attach, but the data inside the file is not in correct format.
Pls help me to correct.
DATA : mailrec LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
mailbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailbin1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_otf LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_pdf LIKE solisti1 OCCURS 0 WITH HEADER LINE,
mailstruc LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
maildata LIKE sodocchgi1 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF i_sotf OCCURS 0.
INCLUDE STRUCTURE itcoo.
DATA : END OF i_sotf.
DATA : i_itcpo LIKE itcpo,
i_itcpp LIKE itcpp.
DATA : v_tlines TYPE i,
v_len_in LIKE sood-objlen,
v_len_out LIKE sood-objlen.
maildata-obj_name = 'Document'.
maildata-obj_descr = 'Transfer Details'.
maildata-obj_prio = 1.
maildata-doc_size = strlen( mailtxt ).
mailstruc-head_start = 1.
mailstruc-head_num = 0.
mailstruc-body_start = 1.
mailstruc-body_num = 1.
mailstruc-obj_name = 'transfer'.
mailstruc-doc_type = 'RAW'.
APPEND mailstruc.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
APPEND mailrec.
CLEAR i_itcpo.
i_itcpo-tdgetotf = 'X'.
REFRESH mailbin.CLEAR mailbin.
WRITE 'Report Title:' TO mailbin-line+3.
WRITE sy-repid TO mailbin-line+18.
APPEND mailbin. CLEAR mailbin.
WRITE 'User : ' TO mailbin-line.
WRITE sy-uname TO mailbin-line+11.
APPEND mailbin. CLEAR mailbin.
WRITE 'Date of Report : ' TO mailbin-line+3.
WRITE sy-datum USING EDIT MASK mask MM/DD/YYYY TO mailbin-line+21.
APPEND mailbin. CLEAR mailbin.
WRITE 'Time of Report : ' TO mailbin-line+3.
WRITE sy-uzeit TO mailbin-line+21.
APPEND mailbin. CLEAR mailbin.
APPEND mailbin.
WRITE 'Transfer ' to mailbin-line+3.
APPEND mailbin. CLEAR mailbin.
APPEND mailbin.
WRITE sy-uline TO mailbin-line+3.
APPEND mailbin. CLEAR mailbin.
LOOP AT i_disp.
SHIFT i_disp-index LEFT DELETING LEADING '0'.
WRITE i_disp-index TO mailbin+3.
WRITE i_disp-pernr TO mailbin+6.
WRITE i_disp-ename TO mailbin+16.
WRITE i_disp-persk TO mailbin+57.
WRITE i_disp-btrtl TO mailbin+60.
APPEND mailbin. CLEAR mailbin.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_SCR_OTF'
EXPORTING
FORMAT_SRC = 'RAW'
FORMAT_DST = 'OTF'
DEVTYPE = 'POSTSCPT'
FUNCPARA = ''
LEN_IN = v_len_in
IMPORTING
LEN_OUT = v_len_out
TABLES
CONTENT_IN = mailbin
CONTENT_OUT = mailbin1
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH mailbin.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
FORMAT_SRC = 'OTF'
FORMAT_DST = 'PDF'
DEVTYPE = 'POSTSCPT'
FUNCPARA =
LEN_IN = v_len_in
IMPORTING
LEN_OUT = v_len_out
TABLES
CONTENT_IN = mailbin1
CONTENT_OUT = mailbin
EXCEPTIONS
ERR_CONV_FAILED = 1
OTHERS = 2 .
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH mailbin1.
DESCRIBE TABLE mailbin LINES v_tlines.
mailstruc-head_start = 1.
mailstruc-head_num = 0.
mailstruc-body_start = 1.
mailstruc-body_num = v_tlines.
mailstruc-transf_bin = 'X'.
mailstruc-doc_type = 'PDF'.
mailstruc-obj_name = 'Mid-month transfer'.
mailstruc-doc_size = v_tlines * 255.
APPEND mailstruc.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = maildata
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = mailstruc
OBJECT_HEADER = mailhead
CONTENTS_BIN = mailbin
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.
But i dont get the result in expected format. I am not getting first 2 characers of the line. instead of report, date, time in separate line I get everything in a single line as follows :
Report Title: ZHRPY0003
er : VACNIDHYA Date of Report : 02.05.2007 Time of Report
: 10:31:27 Mid-month Inter-Company Transfer
--- 1 00002609 Carla Pineda FT
2010
- 1 - -
New document: How to avoid known PDF email attachment problems
Have you ever had problems with PDF attachments sent from Adobe Reader for iOS using Share > E-mail Document?
You may find this document useful to avoid the problems.
How to avoid known PDF email attachment problems
Please let us know if you have encountered different types of problems with PDF attachments. We can look for solutions or workarounds for you.Unfortunately, we (Adobe Reader mobile team) do not know if/when Apple will fix the attachment problems (software defects) in Apple Mail.
In particular, the attachment problem with Microsoft Outlook (See Problem #2 in How to avoid known PDF email attachment problems) appears to be a long-standing defect that has been known for years. However, Apple has not provided any fix for Apple Mail yet.
Adobe Reader for iOS merely launches Apple Mail (the default mail app on iOS) to send a PDF document as an attachment. Adobe Reader has no control over whether or not to embed a preview image of an attachment in the body of an email message, which is known to cause the problem with Microsoft Outlook (on the receiving side). The same problem happens when you send a single-page PDF document as an attachment along with an email signature from Apple iBooks on iOS.
For now, all iPad/iPhone users can do is to avoid the problems by using the workarounds that are described in How to avoid known PDF email attachment problems.
When new and different problems with PDF attachments are reported by Adobe Reader for iOS users, we will update the document above.
Sorry for the inconvenience. -
Error 829 in SOST tcode while sending an email attachment ??
Hi..
I am using the function module "SO_NEW_DOCUMENT_ATT_SEND_API1" to send an email attachment.
The program is getting executed successfully but when i see in SOST transaction, i am getting an error message.
Error number is 829 and it says " Internal error: SO_OBJECT_MIME_GET Exception: 2 "...
How do i resolve this error ....??Hi,
Please check this links will help you.
Error in SOST transaction for Mail Triggered from SAP
Re: need help in implementing a note -
Acrobat can not open pdf email attachment
Acrobat 8 Professional.<br /><br />A user gets this error message when he tries to open up a pdf email attachment:<br /><br />"Acrobat could not open <File Name> because it is either not a supported file type or because the file has been corrupted (for example, it was sent as an email attachment and wasn't correctly decoded)."<br /><br />I can open up the attachment without any issues.<br /><br />Anybody else have this issue?
Yes, Ron Green here at the NYS Insurance Department. I now have two clients and counting that have somewhat of an identical problem.
Client #1 has Adobe 8 Professional installed on his pc which is running Widnows XP Professsional. Files are scanned using a XEROX MFP network scanner and client is able to open those scanned documents within adobe and then saves them to a network share. Problem arises whenever he attempts to attach the saved document to another application. Once he attempts viewing the scanned document at that point Adobe blows up with the same error message stating the file is corrupt.
Client #2 has Adobe 9 Reader but is still able to follow the same network scanning scenario aforementioned but encounters the exact same problem when attempting to attach the scanned PDF documents.
Is there any type of fix out there for this??? -
Canu2019t view Chinese characters in a PDF email attachment sent via SAP.
Canu2019t view Chinese characters in a PDF email attachment sent via SAP.
When open the Chinese characters come out funny.
Note: The document looks okay when previewed in SAP.
Tried the following:
FM CONVERT_OTF_2_PDF
CNSONG is one of our u201CSystem fontsu201D
Attempted with both ZH(Chinese simplified) and ZF(Chinese traditional) languages
Tried using a printer that is set up as u201CDevice Typeu201D PDF1
Tried using a printer that is set up as u201CDevice Typeu201D ZHKPDF
Tried passing device type as u201CCNSAPWINu201D
The following ADODE software was loaded: Chinese simplified, Chinese traditional,
Korean and JapaneseHi,
As a try, can you check this.
SET COUNTRY 'CN'. China country code.
SET LOCALE LANGUAGE 'CN'.
Thanks,
Vinod. -
Want to send PDF as attachement using Java Mail
HI,
I am using Java mail API for sending PDF as attachment. Here is my sample code
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler("String data for PDF using iText", "text/plain" ));
I am generating String for PDF file using iTEXT but I am unable to find out mimetype for passing into DataHandler as second paramete.
Any idea?
Thanks
ShaileshDon't convert the data to String. It isn't text so
you'll damage the binary content by doing that. In
the "demos" directory of your JavaMail download
you'll find a ByteArrayDataSource class you can use
instead of a FileDataSource. Yes, this worked for me. I create the pdf in memory as as StringBuffer and I just changed the code from
messageBodyPart.setDataHandler(new DataHandler(pdf.toString(), "application/pdf"));
to
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(pdf.toString(), "application/pdf")));
and it worked.
Thanks a lot for your help,
Dennis -
The PDF is streamed from our webserver application to an IFRAME in Internet Explorer 9.
The headers Content-type (application/pdf), Content-disposition (random-unique-filename.pdf), Content-length are all set.
Acrobat Reader plugin opens up inside the IFRAME and presents the PDF without problems.
When our users try "Send file as email attachment" Outlook 2010 opens up and the file is attached - without the file extension.
The name of the attachment is the same name as the Java Servlet that delivered the streamed file.
If we save the streamed PDF to disc, open it in Acrobat and do the same maneuver - the file extension is added to the attached file name in Outlook.
Message was edited by: SolsonWe have the same problem !
Tested this today with adobe reader 9.5.x , file is attached as "filename.do.pdf"
If we use adobe reader 11.0.x file is attached as "filename.do"
If you use save file as , it does get the "pdf" extension automatically
Solution appreciated ! -
Convert spool to PDF and send as email attachment
When i try to convert SAP spool to PDF and send it as email attachment, size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
I am using following FMs.
CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
and
SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
Any idea on how to compress the PDF attchment??
ThanksHi Venkat,
Can you plesae assist me.
I have a requirement to convert spool to pdf
send an email to users
issue is that attachement is big cant go through
I have used compress, but when I open the pdf file error that file was not correclty decoded
please assist, anyone -
Not Able to send pdf as attachment through email
Hi,
I am trying to send the generated pdf as attachment throught email and for the same i am referring to this blog
http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID1409662650DB01562818410448928630End?blog=/pub/wlg/8551
but when i am trying to send the mail using the method given in this blog , i am getting this error
com.sap.tc.adobe.pdfobject.core.PDFObjectRuntimeException: Processing exception during a "MergeData" operation. Request start time: Fri Dec 11 18:05:24 IST 2009 com.adobe.ProcessingException: PDF is not interactive. Data can only be imported into interactive forms. Exception Stack Trace: com.adobe.ProcessingException: PDF is not interactive
and at the backend i am getting the error as
#com.sun.mail.smtp.SMTPSendFailedException: 501 Bad address syntax
Can any one please help me out with a solution ?? Any suggestions are welcomed
Thanks a lot in advanceHi,
Thanks for your reply , but i cannot set the enabled property of the form as true as we are not using the licensed version of the live cycle designer . But if i try the example step by step then even by setting the enabled property as false , the pdf is generated and sent through the email and when i am trying to do the same thing in one of my applications its not working . The pdf is generated but as soon as i click on the button send mail the above told error is displayed .
There needs to be some other explaination for the error -
Send as email attachment the billing document as pdf when created and saved
HI All,
I have already searched the forum but could not find a satisfying answer so i am posting this question,
The requirement is to send an email containing biiling document converted to pdf format when a billing document
is created and saved in VF01 transaction.
I have already converted the output to pdf format in my driver program and also know how to send an email containing the same ..but this works only when user prints using VF31 .
Kindly tell the configuration steps which are required...and hot to achieve the same.
Regards,
PrateekHi Prateek,
There is a blog on a similar topic which explains how to email purchase order in SAP to the vendor. The settings are required in Vendor Master, NACE and SCOT.
Following is the link to it.
http://architectsap.com/blog/sap/sap-mm-purchasing-send-purchase-order-by-mail-to-vendor-in-sap/
It has given steps to trigger the output.
Its not exactly what you require, but might be helpful.
Regards,
Abhijeet Kapgate -
Service command in Preview.app - Send PDF as attachment doesn't work
I have used the following workflow for month on all my three macs.
I open up a PDF file in Preview and select "eMail PDF as attachment" from the Edit menu at the top of the screen. This will attach the current viewed PDF file to a new mail message.
I guess after updating to 10.7.2 somehow it stopped working on MacBook Pro and iMac. My Mac mini is fine.
When I do use this command I get two error messages. Service not available. Can't attach PDF to mail. Import failed. Something like that.
Does anyone know how to fix that? I repaired permissions and did all that kind of stuff.
Thanks in advance!Would it be possible, please, for someone who has/had this issue to send me the com.apple.ServicesMenu.Services.plist files from ~/Library/Containers/com.apple.Preview/Data/Library/Preferences and from ~/Library/Preferences?
Thank you. -
URGENT -java MAil sending pdf as attachment
I have a small java program that sends the pdf as an attachment without using phisical pdf file.
but the problem is i am unable to open the pdf that comes as as attachment in mail.
error while opening pdf : " acrobat cannot open file bcos the file type is not supported or the file is curropted(for example it was sent as email attachment and was not properly decoded)"
here is the code :
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;
import java.util.*;
public class Mailer {
public static void main (String args[]) {
String host = "abc";
String from ="[email protected]";
String to = "[email protected]";
//String fileAttachment = args[0];
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session =
Session.getInstance(props, null);
// Define message
MimeMessage message = new MimeMessage(session);
message.setFrom( new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject("Hello JavaMail Attachment subject");
// create the message part
MimeBodyPart messageBodyPart = new MimeBodyPart();
//fill message
messageBodyPart.setText("Hi hello this is the msg in mail");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
String data_to_send = "This msg is sent as an attachment with out using physical file";
String att_type = "application/pdf";
messageBodyPart.setText(data_to_send);
messageBodyPart.setHeader("Content-Type", att_type);
messageBodyPart.setHeader("Content-Transfer-Encoding", "BASE64");
messageBodyPart.setFileName("attachment.pdf");
/* ByteArrayOutputStream byteStream=new ByteArrayOutputStream();
ObjectOutputStream objectStream=new ObjectOutputStream(byteStream);
objectStream.writeObject(data_to_send);
messageBodyPart.setDataHandler(new DataHandler( new ByteArrayDataSource( byteStream.toByteArray(), "application/pdf" )));
messageBodyPart.setFileName("attachment.pdf");
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send( message );
System.out.println("sent msg");
Thanks
SmiIt's "corrupted" because you are sending a text string and not a PDF document.
And that commented-out code that uses an ObjectOutputStream would have corrupted a PDF document anyway, if you had one.
I suggest if this problem is urgent then you hire professional programming help to get it done. You are a long way from a solution. -
Hi All,
I have a created a custom workflow which sends pdf files to the user.I created a document attribute and attached to the message.Im able to see the pdf file in the application notofiaction but not in the email as attachment.any clue why Im not seeing the attachment in my email?
Please help!
Thanks
ThomasREPORT ysam_im_test_wf.
INCLUDE <cntn01>.
TYPE-POOLS: swlc.
INCLUDE <symbol>.
DATA :
lv_header TYPE swr_att_header,
lv_objsofm TYPE swotobjid-objtype,
lv_objtkey TYPE swotobjid-objkey.
* ls_fitment TYPE r_fitment_mstr,
DATA : lv_xstring TYPE xstring,
att_id TYPE swr_att_id,
lv_return TYPE sy-subrc.
DATA : bo_sofm TYPE swc_object .
DATA: l_docwrapper1 TYPE xstring,
l_existence(1) TYPE c.
DATA: t_message_lines TYPE swr_messag OCCURS 0 WITH HEADER LINE.
PARAMETERS: p_wid TYPE swr_struct-workitemid.
START-OF-SELECTION .
CALL FUNCTION 'ZGEN_IMAGE_DATA_GET'
EXPORTING
i_zuonr = '100028'
IMPORTING
l_docwrapper1 = l_docwrapper1
existence = l_existence
EXCEPTIONS
service_call_error = 1
file_download_error = 2
browser_invoke_error = 3
OTHERS = 4.
lv_xstring = l_docwrapper1.
IF lv_xstring IS NOT INITIAL.
UPDATE tvarv SET low = 'XSTRING'
WHERE name = 'ZSAMTEST1'.
lv_header-file_type = 'B'.
lv_header-file_name = 'Invoice Attachment'.
lv_header-file_extension = 'PDF'.
lv_header-language = 'EN'.
CALL FUNCTION 'SAP_WAPI_ATTACHMENT_ADD'
EXPORTING
workitem_id = p_wid
att_header = lv_header
att_bin = lv_xstring
IMPORTING
return_code = lv_return
att_id = att_id
TABLES
message_lines = t_message_lines.
IF lv_return = 0.
lv_objtkey = att_id-doc_id.
lv_objsofm = 'SOFM'.
swc_create_object bo_sofm lv_objsofm lv_objtkey.
ENDIF. " IF lv_return = 0
ELSE.
att_id = 0.
lv_objtkey = att_id-doc_id.
swc_create_object bo_sofm lv_objsofm lv_objtkey.
ENDIF. -
Sending PDF as attachment using utl_smtp
Hi all,
I am encountering the following problem when i try to send the email using utl_smtp builtin,i receive the mail in my outlook,but not able to read the contents of the pdf file.
Oracle Version :- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
source code:-
CREATE OR REPLACE PROCEDURE "PROC_MAIL_ATTACH_PDFS" (
p_cust_nb IN cstm.cstm_cust_nb%TYPE,
from_name IN VARCHAR2,
to_name IN VARCHAR2,
subject IN VARCHAR2,
MESSAGE IN VARCHAR2,
p_binary_file IN VARCHAR2,
p_seq_id IN NUMBER,
p_ret_cd OUT NUMBER,
p_ret_desc OUT VARCHAR2
--ISO-8859-6
IS
v_smtp_server VARCHAR2 (100) := '172.20.204.17';
--change this to your mail server
v_smtp_server_port NUMBER := 25;
v_directory_name VARCHAR2 (100);
v_file_name VARCHAR2 (100);
v_line VARCHAR2 (1000);
crlf VARCHAR2 (2) := CHR (13)
|| CHR (10);
mesg VARCHAR2 (32767);
conn UTL_SMTP.connection;
v_slash_pos NUMBER;
v_file_handle UTL_FILE.file_type;
invalid_path EXCEPTION;
mesg_length_exceeded BOOLEAN := FALSE;
l_msg VARCHAR2 (32000);
l_tag_sep VARCHAR2 (1)
:= func_get_config_value ('TAGSEPRTR');
l_ind VARCHAR2 (10);
l_rec VARCHAR2 (4000);
l_sep_rep VARCHAR2 (4000) := '17_ACCSTMT_NOV_2010';
l_rem_rep VARCHAR2 (4000);
l_rep VARCHAR2 (4000);
l_mim_type VARCHAR2 (2000);
boundary CONSTANT VARCHAR2 (256)
:= '-----DMW.Boundary.605592468';
first_boundary CONSTANT VARCHAR2 (256) := '--' || boundary || crlf;
last_boundary CONSTANT VARCHAR2 (256)
:= '--' || boundary || '--' || crlf;
multipart_mime_type CONSTANT VARCHAR2 (256)
:= 'multipart/mixed; boundary="' || boundary || '"';
mime_type VARCHAR2 (255) := 'text/html';
l_offset NUMBER;
l_ammount NUMBER;
CURSOR cur_trnm
IS
SELECT trnm_email_enarr, trnm_email_anarr
FROM trnm
WHERE trnm_id = 16;
l_enarr trnm.trnm_email_enarr%TYPE;
l_anarr trnm.trnm_email_enarr%TYPE;
l_message_body VARCHAR2 (32000);
--// To check if all mails belongs to the customer already sent...
CURSOR cur_pdfd
IS
SELECT COUNT (*)
FROM pdfd
WHERE pdfd_cust_nb = p_cust_nb
AND pdfd_email_sts IS NULL
--NEWLY ADDED ...
AND NVL (pdfd_stmt_mode, '.') = 'E'
AND TRUNC (pdfd_to_dt) = (SELECT MAX (TRUNC (pdfd_to_dt))
FROM pdfd
WHERE pdfd_cust_nb = p_cust_nb);
l_cnt NUMBER := 0;
PROCEDURE send_header (NAME IN VARCHAR2, header IN VARCHAR2)
IS
BEGIN
UTL_SMTP.write_data (conn, NAME || ': ' || header || crlf);
END;
PROCEDURE write_raw (
p_conn IN OUT NOCOPY UTL_SMTP.connection,
p_message IN RAW
IS
BEGIN
UTL_SMTP.write_raw_data (p_conn, p_message);
END write_raw;
PROCEDURE binary_attachment (
p_conn IN OUT UTL_SMTP.connection,
p_file_name IN VARCHAR2,
p_mime_type IN VARCHAR2
IS
k_max_line_width CONSTANT PLS_INTEGER DEFAULT 54;
v_amt BINARY_INTEGER := 672 * 3;
/* ensures proper format; 2016 */
v_bfile BFILE;
v_file_len PLS_INTEGER;
v_buf RAW (2100);
v_buf1 RAW (2100);
v_modulo PLS_INTEGER;
v_pieces PLS_INTEGER;
v_file_pos PLS_INTEGER := 1;
v_data RAW (32767);
v_data1 RAW (32767);
v_chunks PLS_INTEGER;
l_amt NUMBER := 32767;
l_off NUMBER := 1;
l_raw RAW (32767);
l_raw1 RAW (32767);
l_lob BLOB;
l_lob_empt BLOB;
req UTL_HTTP.req;
resp UTL_HTTP.resp;
resp_empt UTL_HTTP.resp;
l_url VARCHAR2 (4000);
l_rep_path VARCHAR2 (2000);
l_report VARCHAR2 (100);
l_seq_nb repq.repq_seq_nb%TYPE;
l_parm repq.repq_parm_val%TYPE;
l_repq repq%ROWTYPE;
l_sts NUMBER;
l_user VARCHAR2 (10);
--L_MSG VARCHAR2(32000);
l_seq_id NUMBER;
usr_err EXCEPTION;
--// 07-Jun-2009 - Basheer A.S. : Code added for sending A/c Statement and PFL statements in single e-mail ...
CURSOR cur_pdfd
IS
SELECT
--UTL_COMPRESS.LZ_UNCOMPRESS(PDFD_DB_FILE) PDFD_DB_FILE,
pdfd_file_name
FROM pdfd
WHERE pdfd_cust_nb = p_cust_nb
--AND PDFD_EMAIL_STS IS NULL
--NEWLY ADDED ...
--AND NVL(PDFD_STMT_MODE,'.') = 'E'
AND pdfd_seq_nb = p_seq_id
AND TRUNC (pdfd_to_dt) = (SELECT MAX (TRUNC (pdfd_to_dt))
FROM pdfd
WHERE pdfd_cust_nb = p_cust_nb);
l_buffer_size INTEGER := 57;
l_offset INTEGER := 1;
l_raw RAW (57);
l_file_nm pdfd.pdfd_file_name%TYPE;
BEGIN
--// 06-Jun-2009 - Basheer A.S. : Code added for sending A/c Statement and PFL statements in a single e-mail ...
--// Initializing temporary CLOB data ...
DBMS_LOB.createtemporary (l_lob, FALSE);
--DBMS_LOB.createtemporary(L_LOB_EMPT, FALSE);
--// Loop thro all the records for the given Customer Number...
OPEN cur_pdfd;
LOOP
--FETCH CUR_PDFD INTO L_LOB, L_FILE_NM;
FETCH cur_pdfd
INTO --L_LOB_EMPT,
l_file_nm;
EXIT WHEN cur_pdfd%NOTFOUND;
proc_audit_log ('T',
'PROC_MAIL_ATTACH_PDFS, Customer No. '
|| p_cust_nb
|| ', File attachment: '
|| l_file_nm
UTL_SMTP.write_data (conn, first_boundary);
UTL_SMTP.write_data (conn,
'Content-Transfer-Encoding: base64 '
|| UTL_TCP.crlf
UTL_SMTP.write_data (conn,
'Content-Type: ' || mime_type || UTL_TCP.crlf
UTL_SMTP.write_data (conn,
'Content-Disposition: ATTACHMENT; filename="'
|| p_file_name
|| '"'
|| UTL_TCP.crlf
UTL_SMTP.write_data (conn, crlf);
l_ind := '1.1';
v_file_pos := 1;
--// Attaching individual PDF files ...
BEGIN
v_modulo := 0;
v_pieces := 0;
v_amt := 2016;
l_ind := '2.1';
v_file_len := DBMS_LOB.getlength (l_lob);
--v_file_len := dbms_lob.getlength(L_LOB_EMPT);
v_modulo := MOD (v_file_len, v_amt);
v_pieces := TRUNC (v_file_len / v_amt);
IF (v_modulo <> 0)
THEN
v_pieces := v_pieces + 1;
END IF;
l_ind := '2.2';
DBMS_LOB.READ (l_lob, v_amt, v_file_pos, v_buf);
--dbms_lob.read(L_LOB_EMPT, v_amt, v_file_pos, v_buf);
v_data := v_data1;
v_chunks := 0;
v_data := v_data1;
FOR i IN 1 .. v_pieces
LOOP
v_file_pos := i * v_amt + 1;
v_file_len := v_file_len - v_amt;
v_data := UTL_RAW.CONCAT (v_data, v_buf);
l_ind := '2.3';
v_chunks := TRUNC (UTL_RAW.LENGTH (v_data) / k_max_line_width);
IF (i <> v_pieces)
THEN
v_chunks := v_chunks - 1;
END IF;
l_ind := '2.4';
write_raw (p_conn => p_conn,
p_message => UTL_ENCODE.base64_encode (v_data)
v_data := v_data1;
IF (v_file_len < v_amt AND v_file_len > 0)
THEN
v_amt := v_file_len;
END IF;
l_ind := '2.5';
DBMS_LOB.READ (l_lob, v_amt, v_file_pos, v_buf);
--DBMS_LOB.READ(L_LOB_EMPT, v_amt, v_file_pos, v_buf);
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
proc_audit_log
('E',
'PROC_MAIL_ATTACH_PDFS.binary_attachment.inside BLOB loop, :'
|| SQLERRM
|| ',ind:'
|| l_ind
END;
v_file_pos := 1;
UTL_SMTP.write_data (conn, UTL_TCP.crlf);
UTL_SMTP.write_data (conn, UTL_TCP.crlf);
END LOOP;
--// END multiple file attachments
l_ind := '2.6';
UTL_SMTP.write_data (p_conn, last_boundary || UTL_TCP.crlf);
EXCEPTION
WHEN OTHERS
THEN
proc_audit_log ('E',
'PROC_MAIL_ATTACH_PDFS, when others:'
|| l_ind
|| ', '
|| SQLERRM
END binary_attachment;
BEGIN
--// If no pending emails for the given Customer, then exit the process...
OPEN cur_pdfd;
FETCH cur_pdfd
INTO l_cnt;
CLOSE cur_pdfd;
--// If still pending statements needs to be send...
--IF L_CNT > 0 THEN
IF l_cnt = 0
THEN
OPEN cur_trnm;
FETCH cur_trnm
INTO l_enarr, l_anarr;
CLOSE cur_trnm;
l_message_body :=
'<html>'
||
--'<meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1256(Arabic)">'||
--'<meta http-equiv="Content-Type" content="text/html; charset=WINDOWS-1256">'||
'<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-6">'
|| '<body>
<TABLE BORDER="0" WIDTH=100% style="table-layout:fixed;">
<TR>
<TD WIDTH="50%" ALIGN="LEFT" style="word-wrap: break-word"><B>'
|| l_enarr
|| '</B></TD>'
|| '<TD WIDTH="50%" ALIGN="RIGHT" style="word-wrap: break-word"><B>'
|| l_anarr
|| '</B></TD></TR></TABLE>
</body>
</html>';
proc_audit_log ('T', 'PROC_MAIL_ATTACH_PDFS, msg:' || l_msg);
v_smtp_server := func_get_config_value ('MAILHOST');
v_smtp_server_port := func_get_config_value ('MAILPORT');
l_ind := '3.1';
conn := UTL_SMTP.open_connection (v_smtp_server, v_smtp_server_port);
--utl_smtp.helo( conn, v_smtp_server );
--utl_smtp.mail( conn, '[email protected]' );
UTL_SMTP.helo (conn, v_smtp_server);
UTL_SMTP.mail (conn, from_name);
UTL_SMTP.rcpt (conn, to_name);
l_ind := '3.2';
l_rec := func_eti_tagval (l_msg, 'EMAIL');
proc_audit_log ('T', 'PROC_MAIL_ATTACH_PDFS, l_rec:' || l_rec);
proc_audit_log ('T', 'l_sep_rep1' || l_sep_rep);
UTL_SMTP.open_data (conn);
send_header ('From', '<' || from_name || '>');
send_header ('To', '<' || to_name || '>');
--send_header('To',''||Func_Eti_Tagval(L_MSG, 'EMAIL')||'');
send_header ('Date', TO_CHAR (SYSDATE, 'dd Mon yy hh24:mi:ss'));
send_header ('Subject', subject);
send_header ('Content-Type', multipart_mime_type);
UTL_SMTP.write_data (conn, first_boundary);
--utl_smtp.write_data(conn, 'Content-Type: '||mime_type||utl_tcp.crlf);
--utl_smtp.write_data(conn, 'Content-Type: '||mime_type||'; charset=Windows-1256'||utl_tcp.crlf);
UTL_SMTP.write_data (conn,
'Content-Type: '
|| mime_type
|| '; charset=ISO-8859-6'
|| UTL_TCP.crlf
--new...
UTL_SMTP.write_data (conn, crlf);
UTL_SMTP.write_raw_data (conn, UTL_RAW.cast_to_raw (l_message_body));
UTL_SMTP.write_data (conn, crlf);
UTL_SMTP.write_data (conn, crlf);
proc_audit_log ('T', 'l_sep_rep2' || l_sep_rep);
binary_attachment (p_conn => conn,
p_file_name => l_sep_rep || '.pdf',
p_mime_type => 'multipart/mixed'
); --||l_sep_rep||'.pdf');
UTL_SMTP.write_data (conn, last_boundary || UTL_TCP.crlf);
UTL_SMTP.close_data (conn);
UTL_SMTP.quit (conn);
END IF;
p_ret_cd := 0;
p_ret_desc := 'Mail sent successfully';
EXCEPTION
WHEN OTHERS
THEN
proc_audit_log ('E',
'PROC_MAIL_ATTACH_PDFS, error:'
|| SQLERRM
|| 'ind:'
|| l_ind
p_ret_cd := 1;
END;
Kindly help me to resolve this issue.
Thanks & Regards
Ariffpl ease check below link
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
Maybe you are looking for
-
Urgent:Upgrade JRE 1.1.7 to 1.3 for Weblogic 4.5.1
Hi! I have Weblogic 4.5.1 running on JRE 1.1.7,SPARC Solaris 2.6 platform.I need to upgrade the JRE to 1.3.I am given to understand that there are no issues about this w.r.t Weblogic(see http://www.weblogic.com/platforms/index.html#solaris).But I hav
-
Can you suggest a good external blue ray player drive that is compatable with Macbook Pro and avaiilable in the United States?
-
Hi all, pls can anybody send me the link or documents for message flow in XI....and also it will be helpful if u send me some faqs and answers on XI.. thanks & regards, Santosh
-
Nested loop variable in cf variable
Hi, I have a set of dynamic text boxes that I create inside a loop, like this: <cfset counter = 0> <cfoutput query="q1"> <cfset counter = counter+1 > <input name="user_name#counter#" type="text" maxlength="20"> <input name="desc#counter#" type="text"
-
I'm the only one with a Mac - all relatives have PCs and I can't get IChat to view anyone using either MSN Messanger or AIM - anyone have any solutions? I can do messaging but I can't see video.