Sending e-mail with attachment from Oracle APEX
Hi,
Do we have an option to attach a report to the e-mail and send from Oracle APEX page?
In my case, I want to convert the report page into PDF format and attach to the mail. Is it feasible in APEX?
I understand that APEX_MAIL.ADD_ATTACHMENT can attach files stored in the database. But here we need to convert the page and send it
Thanks
Kind Regards,
Prasanth
HI,
Thank you for your input. Currently I'm using APEX 3.2.
Here my requirement is to send the content of the report to the user via e-Mail. If i'm not converting the page into PDF and planning to send as a HTML page or any other format.. The Objective is to send the info with the same format as it is in the report page. Its too big to send as mesage body.
Any idea how to proceed?
Regards,
Prasanth
Similar Messages
-
How can I send e-mail with attachment from oracle 10g?
How can I send email with attachment from oracle 10g?
hi you can achieve the same thing from database tier of unix.
-
How to send Notification mail (with attachement) from On-Demand job
Hi Experts,
I am using SAP IDM 7.2 SP8.
Requirement is to send a notification mail to a specific mail address [email protected] whenever we run a on-demand job.
On-Demand job should also attach a csv file (atttachement.csv, which is in a specific folder D:\folder) while sending the notification mail.
Please help.
Thanks & Regards,
Chandan KumarHi there,
It sounds like you have the basics all together. I would check how you are setting the following parameters of uSendSMTPMessage:
Attachment
Optional. Fully qualified file name of a file to be included as an attachment.
Multiple attachments can be added by separating the file names by a pipe character (|).
AttachmentType
Optional. Valid MIME attachment type.
Charset
Optional. Valid ISO character set identifier, for instance ISO-2022-JP. The default value is ISO-8859-1.
HeaderEncoding
Optional. 0: Plain text, 1: Base64. Default: 0
TransferEncoding
Optional. 1: 7bit, 2: 8bit, 3: Quoted ASCII, 4: Base64. Default: 4.
Sorry the first row got mangled a bit.
Matt -
Send mail with attachment from the uploaded file
hi,
From a form thread i got the following code to send mail with attachment with the file uploaded from the file upload ui element.
public void onActionLoadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionLoadFile(ServerEvent)
WDWebResourceType FileType = null;
String FileName = new String();
//get attribute info for context attribute 'FileUpload'
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(
IPrivateEmailView.IContextElement.FILE_UPLOAD);
//get modifiable binary type from the attribute info,requires type cast.
IWDModifiableBinaryType binaryType =
(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
IPrivateEmailView.IContextElement element =
wdContext.currentContextElement();
//if a file in the 'FileResource' attribute exists
if (element.getFileUpload() != null) {
try {
String mimeType = binaryType.getMimeType().toString();
byte[] file = element.getFileUpload();
//get the size of the uploaded file
element.setFileSize(this.getFileSize(file));
//get the extension of the uploaded file
element.setFileExtension(binaryType.getMimeType().getFileExtension());
//NOTE: context attribute 'FileName' must not be set
//because the FileUpload-UI-element property 'fileName'
//is bound to it. Consequently the fileName is automatically
//written to the context after file upload.
//report success message
wdComponentAPI.getMessageManager().reportMessage(
IMessageEmailComp.SF_UPLOAD,
new Object[] { binaryType.getFileName()},
false);
FileType = binaryType.getMimeType();
FileName = binaryType.getFileName();
} catch (Exception e) {
throw new WDRuntimeException(e);
//if no file in the 'FileResource' attribute exists
else {
//report error message
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportContextAttributeMessage(
element,
attributeInfo,
IMessageEmailComp.NO_FILE,
new Object[] { "" },
true);
//clear the FileResource context value attribute
//element.setFileUpload(null);
String URL;
URL = this.CreateAndGetPathFileUpload(
wdContext.currentContextElement().getFileUpload(),
FileName);
// if (URL.length() == 1){
// //ERRORE
wdContext.currentContextElement().setPATHFileUploaded(URL);
//@@end
public boolean send( java.lang.String subj, java.lang.String mess, java.lang.String dest, java.lang.String attach, java.lang.String FileName )
//@@begin send()
InitialContext ctx = null;
Address[] address = null;
Message msg = null;
Session sess = null;
MimeBodyPart bodyPart = null;
Multipart mp = null;
// "141.29.193.71" == milvl2ja.icn.siemens.it (SMTP di Siemens)
try {
Properties props = new Properties();
props.put("domain","true");
ctx = new InitialContext(props);
sess = (Session) ctx.lookup("java:comp/env/mail/MailSession");
msg = new MimeMessage(sess);
IWDClientUser utente = WDClientUser.getCurrentUser();
String senderEmail = utente.getSAPUser().getEmail();
InternetAddress addressFrom = new InternetAddress(senderEmail);
msg.setFrom(addressFrom);
String EmailDEST = dest;
InternetAddress addressTo = new InternetAddress(EmailDEST);
msg.setRecipient(Message.RecipientType.TO, addressTo);
msg.setSubject(subj);
// if ((mess != null) && (mess.length()>0)) {
// msg.setContent(mess, "text/plain");
// } else {
// msg.setContent("", "text/plain");
//Gestione ATTACHMENT...
String attachedFileName = new String(wdContext.currentContextElement().getFileName());
boolean hasAttachment = (attachedFileName != null) && (attachedFileName.length() > 0);
boolean isMultiPart = (mess != null) && (mess.length() > 1);
//adding an attachment makes the message multipart
if (isMultiPart || hasAttachment) {
mp = new MimeMultipart();
// add text parts
if (mess != null) {
for (int i = 0; i < mess.length(); i++) {
bodyPart = new MimeBodyPart();
bodyPart.setContent(mess,"text/plain");
mp.addBodyPart(bodyPart);
//attach the file to the message if needed
if (hasAttachment) { // avoid the case with no text parts
bodyPart = new MimeBodyPart();
bodyPart.setContent("Allegato incluso nel messaggio.","text/plain");
mp.addBodyPart(bodyPart);
// the part with the file
FileDataSource fds = new FileDataSource(attach);
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
attachmentBodyPart.setDataHandler(new DataHandler(fds));
//URL URLattachedFileName = new URL(attach);
//attachmentBodyPart.setDataHandler(new DataHandler(URLattachedFileName));
attachmentBodyPart.setFileName(FileName);
mp.addBodyPart(attachmentBodyPart);
msg.setContent(mp);
} else {
if ((mess != null) && (mess.length() > 0)) {
msg.setContent(mess, "text/plain");
} else {
msg.setContent("", "text/plain");
//fine ATTACHMENT
msg.setSentDate(new GregorianCalendar().getTime());
msg.saveChanges();
address = msg.getAllRecipients();
Transport.send(msg, address);
} catch (Exception e) {
e.printStackTrace();
return false;
return true;
//@@end
When i used the same code in my application i am gett ing error in many places..
1)FileDataSource fds = new FileDataSource(<b>attach</b>);
attach cannot be resolved
2)attachmentBodyPart.setFileName(<b>FileName</b>);
fliename cannot be resolved
3)byte[] file = element.getFileUpload();
type mismatch cannot convert sting to byte[]
4)element.setFileSize(this.getFileSize(file));
method getFileSize() is undefined
5)element.setFileExtension(binaryType.getMimeType().getFileExtension());
method getFilExtension() is undefined
6)URL = this.CreateAndGetPathFileUpload(wdContext.currentContextElement().getFileUpload(),FileName);
method CreateAndGetPathFileUpload() is undefined.
7)wdContext.currentContextElement().setPATHFileUploaded(URL);
from the above error i can understand that only i have got the part of the code.
Please send me the complete coding.
some method definitions are missing....
Please help me to send the mail with attachment from the file uploaded from the file upload ui element.
Thanks in advance,
shami.hi,
I got this from the following link
Re: Attaching an excel file
plz help me ...
I am using 2004s with nwds 7.0.06.
also tell me what should be the type of the context variable FileUpload
Thanks in advance,
shami. -
Send mail with attachment from webdynpro application
hi,
From a webdynpro application, the user will upload any files through the File upload ui element.These uploaded files has to go as an attachment in the mail which is being send to a particular ID ,when the user clicks the submit button in the form.
can you please give me the code regarding this and help me in sending mail with attachment from a webdynpro application.
Thanks in advance,
shami.Hai,
Properties props = System.getProperties();
props.put("mail.smtp.host", "xx.xx.x.xx");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected]", false));
msg.setSubject(subject);
msg.setText(body);
msg.setHeader("X-Mailer", " Email");
msg.setSentDate(new Date());
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Hai , This mail Generated By the Program");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource("C:\nag.xls");//Here you need to give the Path of uploaded File
messageBodyPart.setDataHandler( new DataHandler(source));
messageBodyPart.setFileName("nag.xls");
multipart.addBodyPart(messageBodyPart);
// Put parts in message
msg.setContent(multipart);
Transport.send(msg);
Regards,
Naga -
We want to send a mail with attachment pdf file.
Hi!!!
We want to send a mail with attachment pdf file.
The PDF file this is in the server sap.Hi,
Pls check web logs like
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
Eddy
PS.
Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
Spread the wor(l)d! -
Send a mail with attached file .xls but i got file without
i tried to send a mail with attached file .xls. but i am able to send the file , we recived the file without file name. please do the same
thnaks in advance.
END-OF-SELECTION.
Populate message body text
PERFORM POPULATE_EMAIL_MESSAGE_BODY.
Send file by email as .xls speadsheet
PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Example .xls documnet attachment'
'XLS'
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP AEDAT MATNR
UP TO 10 ROWS
FROM EKPO
INTO TABLE IT_EKPO.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
CONSTANTS: CON_CRET TYPE X VALUE '0D', "OK for non Unicode
CON_TAB TYPE X VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO IT_ATTACH SEPARATED BY ''.
CONCATENATE '' IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_EKPO INTO WA_CHAREKPO.
CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
INTO IT_ATTACH SEPARATED BY ''.
CONCATENATE '' IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_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.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM INITIATE_MAIL_EXECUTE_PROGRAM.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
FORM POPULATE_EMAIL_MESSAGE_BODY.
REFRESH IT_MESSAGE.
IT_MESSAGE = 'Please find attached a list test ekpo records'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODYPERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
TABLES IT_MESSAGE
IT_ATTACH
USING P_EMAIL
'Failed IDOC Analysis report'(020)
'xls'(021)
'IDOC_REP'(022)
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM. " F_MAIL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM BUILD_XLS_DATA_TABLE.
*CONSTANTS: CON_CRET TYPE X VALUE '0D', "OK for non Unicode
*CON_TAB TYPE X VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE text-040 text-041 text-042 text-043 text-044 text-045 text-046 text-047 text-048 text-049
INTO IT_ATTACH SEPARATED BY con_tab.
CONCATENATE con_cret IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
clear IT_ATTACH.
loop at i_final_t into w_final.
CONCATENATE
w_final-mestyp w_final-docnum w_final-statxt w_final-msgno w_final-rvplant w_final-kunnr w_final-vbeln w_final-credat
w_final-cretim w_final-flag INTO IT_ATTACH SEPARATED BY con_tab.
CONCATENATE con_cret IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
clear IT_attach.
endloop.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
PIT_ATTACH
USING P_EMAIL
P_MTITLE
P_FORMAT
P_FILENAME
P_ATTDESCRIPTION
P_SENDER_ADDRESS
P_SENDER_ADDRES_TYPE
CHANGING P_ERROR
P_RECIEVER.
DATA: LD_ERROR TYPE SY-SUBRC,
LD_RECIEVER TYPE SY-SUBRC,
LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
LD_EMAIL LIKE SOMLRECI1-RECEIVER,
LD_FORMAT TYPE SO_OBJ_TP ,
LD_ATTDESCRIPTION TYPE SO_OBJ_NAM ,
LD_ATTFILENAME TYPE SO_OBJ_DES ,
LD_SENDER_ADDRESS LIKE SOEXTRECI1-RECEIVER,
LD_SENDER_ADDRESS_TYPE LIKE SOEXTRECI1-ADR_TYP,
LD_RECEIVER LIKE SY-SUBRC.
LD_EMAIL = P_EMAIL.
LD_MTITLE = P_MTITLE.
LD_FORMAT = P_FORMAT.
LD_ATTDESCRIPTION = P_ATTDESCRIPTION.
LD_ATTFILENAME = P_FILENAME.
LD_SENDER_ADDRESS = P_SENDER_ADDRESS.
LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
Fill the document data.
W_DOC_DATA-DOC_SIZE = 1.
Populate the subject/generic message attributes
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
W_DOC_DATA-SENSITIVTY = 'F'.
Fill the document data and get size of attachment
CLEAR W_DOC_DATA.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND T_PACKING_LIST.
Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
T_RECEIVERS-RECEIVER = LD_EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_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.
Populate zerror return code
LD_ERROR = SY-SUBRC.
Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. "SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM INITIATE_MAIL_EXECUTE_PROGRAM.
WAIT UP TO 2 SECONDS.
SUBMIT RSCONN01 WITH MODE = 'INT'
WITH OUTPUT = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
FORM POPULATE_EMAIL_MESSAGE_BODY.
data: l1(99) type c,
l2(15) type c,
lt_message type standard table of solisti1,
ls_message like line of lt_message.
clear ls_message.
l1 = 'Dear'(007).
l2 = 'Sir/Madam'(008).
concatenate l1 l2 ',' into
ls_message-line separated by space.
append ls_message to lt_message.
*insert Blank Line
clear ls_message.
ls_message-line = space.
append ls_message to lt_message.
*Assign Message text
clear ls_message.
concatenate text-011
text-012
into ls_message-line separated by space.
append ls_message to lt_message.
*insert Blank Line
clear ls_message.
ls_message-line = space.
append ls_message to lt_message.
*Assign Message text
clear ls_message.
concatenate text-013
text-014
text-015
into ls_message-line separated by space.
append ls_message to lt_message.
concatenate text-016
text-017
into ls_message-line separated by space.
append ls_message to lt_message.
*insert Blank Line
clear ls_message.
ls_message-line = space.
append ls_message to lt_message.
ls_message-line = text-018.
append ls_message to lt_message.
ls_message-line = text-019.
append ls_message to lt_message.
clear: ls_message.
REFRESH IT_MESSAGE.
it_message[] = lt_message[].
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY -
How to send a mail with attaching a report
hi gurus,
my requirment is i have to send a mail with attaching the report of a program to the client.. is it possible? help me with sample code.
Thanks in advance.
Regards,
Indira DHi Indira,
plz check out this code below,
*& Report ZATTACH *
REPORT ZATTACH .
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver
DEFAULT '[email protected]'.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM build_xls_data_table.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform.
" POPULATE_EMAIL_MESSAGE_BODY
<b>
Reward points if this helps,</b>
Kiran -
Send External mail with Attchment from SAP
Hi All,
OUR REQUIREMENT: We need to send EXTERNAL MAIL with ATTACHMENT(Excel) form SAP .
We have developed a function module which converts the internal table data into Excel Format and sends it as an attachment to External Mail.
ISSUE : But our issue is we are unable to open that document using GOOGLE DOCS Could any one help me how to do this.
it was thriughing error like
Error log is .
''Sorry, we are unable to generate a view of the document at this time. Please try again later.
You can also try to download the original document by clicking here. Alternatively, you can view the plain HTML (automatically redirecting).
Regards
Venkat .
Edited by: venkata pradeep on Mar 5, 2012 10:26 AM
Edited by: venkata pradeep on Mar 5, 2012 10:28 AMIs the excel file recognized by MS Excel? If not, then issue is you have wrongly converted your attachment and/or your FM to create an excel file was wrongly coded or you have passed it wrongly to your mail code.
If you consider an OOP approach in sending external mail, refer to this link:
http://wiki.sdn.sap.com/wiki/display/Snippets/SendingmailwithattachmentusingObjectOriented+Approach -
Sending E-mail with attachment within a loop not working.
Hi,
I'm trying to send e-mails with attachment to multiple users with "subject & an attachment" within an ITAB loop.
SUBJECT for each mail to corresponding user is being sent properly.
But ATTACHMENT contents are not being sent properly.
1st ATTACHMENT contents are going to 2nd user(supposed to go to 1st user) & 2nd ATTACHMENT contents are going to 3rd user etc..
in almost all attempts, last ATTACHMENT contents within the loop were delivered properly to the last user.
As a test, I'm debugging by sending with same "SUBJECT" & "ATTACHMENT CONTENTS". still it's not working.
Following is the code for sending mail with same "SUBJECT" & "ATTACHMENT CONTENTS".
I even refreshed the file contents for each record within the ITAB. Greatly appreciate any help.
assume that ITAB has a field GROUP with values 501, 502, 503 & 504.
SUBJECT is the subject of e-mail & DIST_LIST is the e-mail id of the corresponding user.
DATA:
MAIL_FILE(20) TYPE C,
MAIL_TEXT(200) TYPE C,
COMMAND(512) TYPE C,
DIST_LIST(425) TYPE C,
SUBJECT(60) TYPE C.
DATA: BEGIN OF ITAB OCCURS 0.
DATA GROUP LIKE /BI0/PGRP-GRP.
DATA: END OF ITAB.
LOOP AT ITAB.
SUBJECT = ITAB-GROUP.
IF ITAB-GROUP = '501'.
DIST_LIST = '[email protected]'.
ENDIF.
IF ITAB-GROUP = '502'.
DIST_LIST = '[email protected]'.
ENDIF.
IF ITAB-GROUP = '503'.
DIST_LIST = '[email protected]'.
ENDIF.
IF ITAB-GROUP = '504'.
DIST_LIST = '[email protected]'.
ENDIF.
clear MAIL_FILE.
clear MAIL_TEXT.
UNASSIGN <FILE1>.
CONCATENATE '/tmp/' SY-UNAME '.txt' INTO MAIL_FILE.
TRANSLATE MAIL_FILE TO LOWER CASE.
OPEN DATASET MAIL_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
MAIL_TEXT = ITAB-GROUP.
TRANSFER MAIL_TEXT TO MAIL_FILE LENGTH 200.
CLOSE DATASET MAIL_FILE.
clear MAIL_TEXT.
CONCATENATE '< ' MAIL_FILE INTO MAIL_TEXT SEPARATED BY SPACE.
ASSIGN MAIL_TEXT TO <FILE1>.
*Create UNIX MAIL Command
CONCATENATE 'mailx -s'
'"' SUBJECT '"' '"' DIST_LIST '"' <FILE1>
INTO COMMAND SEPARATED BY SPACE.
Send the E-mail
CALL FUNCTION 'RFC_REMOTE_EXEC'
DESTINATION 'SERVER_EXEC'
EXPORTING
COMMAND = COMMAND
EXCEPTIONS
OTHERS = 04.
ENDLOOP.Hi Zhenglin,
thanks for your reply.
Now, it's working after I changed attachment file name (user name) with ITAB-GROUP.
but, I'm not clear on why it was not working even if the file name is same in every loop, as I'm unassigning the file contents and loading new contents at the start of each loop.
anyhow, it's working and many thanks for your help. -
Help in sending mails with attachment from workflow
Hi Experts,
I have a document in my local PC. Can anyone tell me how to send it like an attachment from workflow.
Thanks in advance.Hi,
when u want to send the attachment along with document created, then u can see the Service Object in left hand top corner. There u can attach your file. So that it will go with the document.
Regards,
JMB -
Send a file as attachement from Oracle Database
Hi all,
I m using Oracle 9i database with Developer 6i. I want to send (mail) a file as an attachement from oracle. Is is possible? If yes please help me on this matter.
Best Regards,
Hassan Raza Khan Lodhigo to :
http://asktom.oracle.com/
and search on "send mail attachment"
You'll find several options. -
Cofiguring & sending email with attachment from Oracle Report 10g
I want to run report from Oracle 10g reports to be sent as email attachement to differnt people with their respective personal content.
The first problem is to know how to configure Oracle reports 10g to be able to send output to email address.
The second problem is to be able to route seperate pages of the report to seperate email address.
Thanks to all.For configuring email for reports
http://download-east.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_conf.htm#sthref472
For sending the output to different mail id's you can use bursting and distribution feature of Oracle Reports. For details,
http://download-east.oracle.com/docs/cd/B14099_17/bi.1012/b14048/pbr_dist.htm#i1007338 -
Sending mail with attachment from OIM
Hi Experts,
We have a requirement to send mail from OIM with attachment. Could not find any relevant document how to achieve this using Notification template and NotificationService.
Any help would be appreciated.
Thanks in advance.this feature is not supported by the product. check Doc ID 1444359.1
You can raise a SR to know about it. -
Sending mail with attachment from Photos App get stuck in Outbox
Hey,
As it is described in the title, the photos I have previously selected in Photos App ( by clicking send > by mail ) get stucked in my Outbox.
In opposition to some other discussions, I can edit/delete that stucked mail, and even send it if I manually click again on "Send" from the outbox !
Other funny conclusion : If I copy&paste the photo and compose a new message from the Mail App, the same mail isn't stuck.
I tried to delete/reconfigure my Exchange Account, it doesn't change anything.
Google Mail account configured with Exchange Account.
Synchronising Mail&Calendar
Push activated
(It definitely worked properly before)
Device: Iphone 4
Carrier: Orange France
Country / Language: FR
OS / Browser / build number (if applicable): iOS 4.1 8B117Hi,
Please run Word in Safe Mode to test if it's 3rd-party add-ins related:
Press Win + R and type “word.exe /safe” in the blank box, then press Enter.
If there’s no problem in Safe Mode, disable the suspicious add-ins to verify which add-ins caused this issue.
We can also refer to the link below, to learn more and check the possible settings that may affect this behavior:
http://www.msoutlook.info/question/278
Regards.
Melon Chen
TechNet Community Support
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place.
Maybe you are looking for
-
How many song can you put on your ipod with 16 gb
how many song can you put on a 16 gb ipod
-
Needs help in buying ram for w520
hi guys! Im going to buy a w520 with "8 GB ram (installed) / 16 GB (max) - DDR3 SDRAM - 1333 MHz - PC3-10600 ( 2 x 4 GB )" from amazon. So i was thinking of buying w520 with a "Corsair 8 GB DDR3 Laptop Memory Kit CMSO8GX3M2A1333C9" to make it into 16
-
Why can't I upload a picture from my desktop to put with an ebay auction
I purchased an Intel Based Imac, 24" screen, in November and initially had problems uploading pictures from my desktop to put with my ebay auctions. After several attempts I was able to complete this task. However, 4 days ago, I'm now no longer able
-
How to put pages in english?
Hi, my macbook air is in french and i just bought pages but it is in french, and i would like to put it in english and french when i'am tipping. How do i do?
-
Migrating SP2010 host-named Site Collections
Hi all, I'm currently having an issue when upgrading Host-Named site collections from SP2010 to SP2013. Once upgraded into SP2013 (Database attach), It keeps on prompting me for credentials, even after adding my user as a Web Application user. Is t