Issue regarding sending attachment mail
hi all
i am using function module "SO_NEW_DOCUMENT_ATT_SEND_API1"
i am facing problem in sending attachment .....if width of my text line is more than 255.
pls guide me how to proceed further
Hi,
Check this threads:
SO_NEW_DOCUMENT_ATT_SEND_API1
unable to e-mail a pdf through FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
SO_NEW_DOCUMENT_ATT_SEND_API1
Best regards,
Guillaume
Message was edited by: Guillaume Garcia
Similar Messages
-
Issue regarding sending E-Mail with PDF file(s) as attachment
Hi,
Can anybody provide me with code to send PDF file as E-Mail Attachment!
I know we have to use F.M <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b> but how we have to use it to send PDF file as attachment!
I was able to send Text files as Attachments in my previous assignments.
Thanks in advance.
Thanks & Regards,
Kumar.Hi,
Check this threads:
SO_NEW_DOCUMENT_ATT_SEND_API1
unable to e-mail a pdf through FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
SO_NEW_DOCUMENT_ATT_SEND_API1
Best regards,
Guillaume
Message was edited by: Guillaume Garcia -
Regarding Send E-Mail..
Dear Friend,
I don't want to use coding. I want to send through Toolbar E-Mail Icon.
I am not using SDK i want to configure E-Mail in SAP.
I tried but when i wil click that Icon it throws Error,
"Attachement folder not define and attache ment folder has been changed or remove"
After that send message sceen open but when i wil Add receipient it add but when i click on send button it again throws Error,
"E-mail address has not been define for the sender, Cannot send E-Mail,SMS or Fax.."
Thanks,Hi Harish,
First, if you are send marketing documents as an E-mail, you should define
the correct path for the attachments folder under Administration -> System Initialization -> General settings -> Path
For second error, the user sending e-mail has to be defined e-mail address
under Adminstration -> Setup -> General -> Users
Regards,
Vijay kumar
SAP Business One Forums Team -
Issues in sending e-mail from FDM
Hi Experts,
I am working on FDM v 11.1.1.3, windows 2003 SP2, IIS 6.0 and I am trying to send an e-mail using the Send Mail accelerator and following is the code:
'Define variables etc.
strFromAddress = DW.Security.fUserEmailGet(DW.Connection.PstrUserID)
strToAddress = "[email protected]" '"YourToAddress"
strSubject = "Import Failed" '"YourSubjectLine"
strEmailMsgLine = "The import process has failed." '"YourMessageLine"
strSMTPServer = "smtp.gmail.com"
'CdoSendUsing enumeration-1=use smtp on local machine, 2=use smtp over network
intSendUsing = 1
'SMTP port on server
intSMTPPort = 25
Set objConfig = CreateObject("CDO.Configuration")
With objConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = intSendUsing
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")= intSMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With
'Create CDO message object
Set objMsg = CreateObject("CDO.Message")
'Assign config object to configuration property of message object
Set objMsg.Configuration = objConfig
'Set Message object settings and send mail
With objMsg
.To = strToAddress
.From = strFromAddress
.Subject = strSubject
.TextBody = strEmailMsgLine
.Send
End With
'Destroy message objects
Set objMsg = Nothing
Set objConfig = Nothing
When I set 'CdoSendUsing' to 1, an eml file gets generated on the path 'C:\Inetpub\mailroot\Pickup' but I never receive it on my gmail ID. When I set the 'CdoSendUsing' to 2, I get an error on the .Send line saying 'The server rejected the sender address. Server response was 530 5.7.0 must issue a STARTTLS command first'. I also checked the MetaBase.XML, 'PickupDirectory' is set.
Please suggest where am I going wrong.
Thanks & Regards!Just to confirm what Tony is saying :
- It's highly unlikely that Google functions as a Mail Relay for SMTP. If it did spammers would have a field day. An open relay is a mail server that will forward emails sent to it from unknown 3rd parties. I'm not familiar with your Google service; however, if they allow any type of mail relaying form you, it is probably secure with at least a login and password so they know it is coming from you. (This would mean when you use the CDONTS object, you'll need to supply a sender login and password)
- The reason why files are accumulating in the Pickup folder is you do not have a running SMTP service that is processing emails on the server that you pointed FDM to. For reference, the following folders are used by your typical SMTP mail service :
* Pickup : Email files waiting to be picked up by the SMTP server for processing (if you open the EML file in a text editor, should be apparent what it is) If the email is meant for an external party, it will be sent to their mail server. If the message is meant for an internal user, gets moved to Drop folder.
* Drop : Incoming messages for local users are stored here
* Queue : Messages that were sent but could not be immediately delivered are placed here. These will be resent at various intervals for a predetermined amount of attempts.
* Badmail : Messages that could not be delivered. Viewing in a text editor should indicate the failure, etc. Senders are not notified of these failures in most cases unless an Admin notifies them based on what is in this folder.
The easiest option here is to install SMTP on the FDM box and call it a day.
* MS Install Instructions for Server 2003 - http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
* MS Configuration information for SMTP on IIS 6.0
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
One NOTE :
- If your company has a mailserver (who doesn't?? :) ), the MX record will be linked to the IP of that machine and not your SMTP box. Certain anti-spam solutions as well as other mail servers might reject your emails as when they perform a reverse lookup, the IP address of your SMTP server will not match that of your MX entry (DNS).
If this happens, you should configure your FDM SMTP server to send its mail to your local mail server and talk to your IT department to make sure all necessary changes are in place. (i.e. you might need to configure Exchange to let your FDM SMTP use it as a mail relay, etc) -
Problem in sending attachment mail
hi all
i am using function module "SO_NEW_DOCUMENT_ATT_SEND_API1"
i am facing problem in sending attachment .....if width of my text line is more than 255.
pls guide me how to proceed furtherHi,
See this thread.
Re: How to email an attachment with more than 255 characters?
Hope it help you.
Regards,
Lijo Joseph -
Hi,
can any one help me out in sending a mail
i have all the data in hand regarding the sales order
i need to format all the data in the body of the mail
how can i format the data on the body of the mail
and wat function module i need to use to send the mail
regards,
siva
Points will be awardedHi,
Try following code:
report ztest_email.
parameters: psubject(40) type c default 'Hello',
p_email(40) type c default [email protected]' .
data: it_packing_list like sopcklsti1 occurs 0 with header line,
it_receivers like somlreci1 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.
write:/ 'done'.
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.
Populate the subject/generic message attributes
gd_doc_data-obj_descr = psubject.
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-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'
commit_work = 'X'
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
Reward points if useful. -
Issue in sending e mails with Excel attachment
Hi,
I am facing an issue with one function module - SO_DOCUMENT_SEND_API1. We were using this for sending mails to diff destination with excel sheet attachment contains sales data. This system has been migrated from 4.5B to ECC 5. Now this process is not working like the old one and the excel attachment is not properly formatted. All the data is being written into one cell of excel sheet and it seems only one line is present in output and is corrupted.
Can you please let me know what might be the issue here, any alternate option available or something to be modified in new version with this function module?
Thanks in advance,
UllasHi Ullas,
check this once.
REPORT ZLAXMI_ALVMAIL4 .
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
Regards,
Laxmi. -
Issue the send attach Pdf file in Email. (Urgent).
Hello folks, i have issue with attach pdf in e-mail using two lib´s: activation.jar and mail.jar. Currently using a platform SOA and am creating the serviceType, then a file don´t is local and yes by message, so far so good.
Already tried in several forums, but without success.
When send the message (pdf file), the program receive a type ContentType (application/octet-stream) and cause the MessageException, below:
MessageException - in Container:
Message: [B@79ffb7f7 /// the service received the pdf file
[09/03/02 12:22:45] ID=dev_ESBTest (info) application/octet-stream *///ContentType of message*
javax.mail.SendFailedException: Sending failed; *///Exception*
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
**javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream**
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream
at com.sun.mail.smtp.SMTPTransport.sendMessage (SMTPTransport.java:353)
at javax.mail.Transport.send0 (Transport.java:164)
at javax.mail.Transport.send(Transport.java:81)
With this, it send the e-mail without attach......above my source simple source code.
ServiceType Code:
protected void SendEmail(XQPart prt, String host, String from, String to) {
// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host";, host);
Session session = Session.getInstance(props, null);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test Subject.");
MimeBodyPart bp1 = new MimeBodyPart();
bp1.setText("Test Text.");
MimeBodyPart bp2 = new MimeBodyPart();
m_xqLog.logInformation(prt.getContentType());
bp2.setContent(prt.getContent(), prt.getContentType());
bp2.setFileName("teste.pdf";);
Multipart mp = new MimeMultipart();
mp.addBodyPart(bp1);
mp.addBodyPart(bp2);
msg.setContent(mp);
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("Email sent successfully!");
} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}Anybody would can help me, please....
Thanks ....
Paulo Sampei.Hello Folks, me again. Then the solution about this question above, below:
Solution:
Code 1: Call 2 method passing requirement parameter:
Obs: Always ContentType = application/octet-stream
ByteArrayInputStream attachStream = new ByteArrayInputStream((byte[]) prt.getContent());
//call constructor class:InputStreamDataSource
InputStreamDataSource isds = new InputStreamDataSource("Testepdf.pdf", prt.getContentType(),attachStream);
//call method sendMail(InputStreamDataSource,host,from,to)
sendMail(isds, s_Host, s_SendFrom, s_SendTo);Code 2: Class InputStreamDataSource
// statement DataSource
private class InputStreamDataSource implements DataSource {
private String name;
private String contentType;
private ByteArrayOutputStream baos;
InputStreamDataSource(String name, String contentType,
InputStream inputStream) throws IOException {
int read;
this.name = name;
this.contentType = contentType;
baos = new ByteArrayOutputStream();
byte[] buff = new byte[256];
while ((read = inputStream.read(buff)) != -1) {
baos.write(buff, 0, read);
public String getContentType() {
// TODO Auto-generated method stub
return contentType;
public InputStream getInputStream() throws IOException {
// TODO Auto-generated method stub
return new ByteArrayInputStream(baos.toByteArray());
public String getName() {
// TODO Auto-generated method stub
return name;
public OutputStream getOutputStream() throws IOException {
// TODO Auto-generated method stub
throw new IOException("Cannot write to this read-only resource");
}Code 3: mehod sendMail(InputStreamDataSource, host, from, to)
protected void sendMail(InputStreamDataSource attach, String host,
String from, String to) {
// create some properties and get the default Session
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
Session session = Session.getInstance(props, null);
try {
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = { new InternetAddress(to) };
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Assunto teste.");
// create and fill the first message part
MimeBodyPart bp1 = new MimeBodyPart();
bp1.setText("Texto teste.");
// create the second message part
m_xqLog.logInformation("[ContentType]:[attach] "
+ attach.getContentType());
// attach the file to the message
MimeBodyPart bp2 = new MimeBodyPart();
bp2.setDataHandler(new DataHandler(attach));
bp2.setFileName(attach.getName());
// create the Multipart and add its parts to it
Multipart mp = new MimeMultipart();
mp.addBodyPart(bp1);
mp.addBodyPart(bp2);
// add the Multipart to the message
msg.setContent(mp);
// set the Date: header
msg.setSentDate(new Date());
// send the message
Transport.send(msg);
System.out.println("Email sent successfully!");
} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}Thank you very much, forum and bshannon at your tips.
Cheers,
Paulo Sampei. -
Issue in sending a mail using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
HI Abappers,
I have contents of the attachmnet to be sent in an internal table. when i pass this table to the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' , the text attachment shows a slant format. i mean all the contents of the attachment shift to right and has no proper alignment.
What can be done.? pLease help...Hi,
You must have skipped some data declaration part which causes this.
Please refer to the below mentioned code for reference:
REPORT zrat NO STANDARD PAGE HEADING.
*DATA DECLARATION
DATA : BEGIN OF wa_ccode,
bukrs TYPE t001-bukrs,
END OF wa_ccode.
DATA : itab_ccode LIKE TABLE OF wa_ccode.
DATA : BEGIN OF wa_emp,
pernr TYPE pa0001-pernr,
sachp TYPE pa0001-sachp,
sname TYPE pa0001-sname,
END OF wa_emp.
DATA : itab_emp LIKE TABLE OF wa_emp.
DATA : BEGIN OF wa_bdate,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
pernr TYPE pa0002-pernr,
gbdat TYPE pa0002-gbdat,
END OF wa_bdate.
DATA : itab_bdate LIKE TABLE OF wa_bdate.
DATA : new_date LIKE sy-datum.
DATA : diff TYPE i.
DATA : years LIKE p0347-scryy,
months LIKE p0347-scrmm,
days LIKE p0347-scrdd.
DATA : sup_code LIKE pa0001-sachp,
itab_usrid LIKE t526-usrid,
sup_pernr LIKE pa0105-pernr.
DATA : BEGIN OF wa_email,
usrid_long LIKE pa0105-usrid_long,
END OF wa_email.
DATA : sup_email LIKE TABLE OF wa_email.
DATA : gwa_document_data LIKE sodocchgi1,
gc_name TYPE so_obj_nam VALUE 'RETIREMENT',
gc_senst TYPE so_obj_sns VALUE 'P',
gc_size TYPE so_doc_siz VALUE '510',
gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
DATA : smtp_addr LIKE adr6-smtp_addr.
DATA : wa_date LIKE sy-datum,
entries LIKE sy-tabix,
name(15),
line1(18) TYPE c,
line2(20) TYPE c,
line3(20) TYPE c,
line4(23) TYPE c,
line5(10) TYPE c,
line6(45) type c,
date(2) TYPE c,
month(2) TYPE c,
year(4) TYPE c.
*START OF SELECTION
SELECT bukrs
FROM t001
INTO TABLE itab_ccode
WHERE land1 EQ 'GB'.
SORT itab_ccode.
DELETE ADJACENT DUPLICATES FROM itab_ccode.
SELECT pernr sachp sname
FROM pa0001
INTO TABLE itab_emp
FOR ALL ENTRIES IN itab_ccode
WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
endda GE sy-datum and persg eq '1'.
SELECT nachn vorna pernr gbdat
FROM pa0002
INTO TABLE itab_bdate
FOR ALL ENTRIES IN itab_emp
WHERE pernr EQ itab_emp-pernr.
*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
LOOP AT itab_bdate INTO wa_bdate.
new_date = wa_bdate-gbdat.
*TO CALCULATE THE AGE TILL DATE
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = sy-datum
date2 = new_date
output_format = '05'
IMPORTING
years = years
months = months
days = days
IF sy-subrc <> 0.
ENDIF.
IF years EQ 64 AND months EQ 4.
IF days GE 23 AND days LE 31.
*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
sup_code.
SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
itab_usrid AND subty EQ '0001'.
clear sup_email[].
SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
sup_pernr AND subty EQ '0010'.
*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
CLEAR gi_obj_cnt.
CLEAR gi_recievers.
CLEAR gwa_document_data.
Loop at sup_email into wa_email.
write sy-uline+0(5).
write sy-uline+10(5).
write sy-uline+20(5).
write sy-uline+30(5).
write sy-uline+40(5).
write sy-uline+50(5).
write sy-uline+60(5).
write sy-uline+70(5).
smtp_addr = wa_email-usrid_long.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
Endloop.
smtp_addr = '[email protected]'.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
gwa_document_data-obj_name = gc_name.
gwa_document_data-obj_descr = 'RETIRE'.
gwa_document_data-sensitivty = gc_senst.
gwa_document_data-obj_langu = sy-langu.
*CONTENT OF THE EMAIL TO BE SENT
line1 = 'Please note that '.
line2 = wa_bdate-vorna.
line3 = wa_bdate-nachn.
line4 = ' will be 65 years on '.
line50(4) = wa_bdate-gbdat4(4).
date = line5+2(2).
month = line5+0(2).
year = wa_bdate-gbdat+0(4) + 65.
CONCATENATE date month year INTO line5 SEPARATED BY '.'.
line6 = '.Please complete the Retirement Procedure.'.
CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
SEPARATED BY space.
APPEND gwa_obj_cnt TO gi_obj_cnt.
CLEAR gwa_obj_cnt.
DESCRIBE TABLE gi_obj_cnt LINES entries.
READ TABLE gi_obj_cnt INDEX entries.
gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gwa_document_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = gi_obj_cnt
receivers = gi_recievers
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
*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
endif.
CASE sy-subrc.
WHEN 0.
LOOP AT gi_recievers.
IF gi_recievers-receiver = space.
name = gi_recievers-rec_id.
ELSE.
name = gi_recievers-receiver.
ENDIF.
IF gi_recievers-retrn_code = 0.
WRITE: / name, ': succesfully sent'.
ELSE.
WRITE: / name, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
ENDIF.
ENDIF.
ENDLOOP.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
How to send attachment mail in sap
hi all,
please guide me how to use function module named SO_NEW_DOCUMENT_ATT_SEND_API1.
i have text files in internal table.
please guide me how can i send files in my internal table as in attachment.Manish,
Just copy paste the below code as given into a report only changing the email address of receipient to your email address to testing.
That is line:
lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
Then I think your SCOT is not configured for automatic execution hence once you have run your report go to transaction SCOT and press (Ctrl + F7) to start send process.
A mail will be sent to your email address specified in the receipient list and a copy of it also placed in your SBWP Outbox.
Let me know if you need further help, else reward neccessary points.
Code
*& Report ZMFV_ROUGH_PAD
REPORT zmfv_rough_pad.
DATA :
li_attachment TYPE TABLE OF soli, " hold attachment contents
li_pdf TYPE TABLE OF tline, " hold data from spool in PDF format
li_objpack TYPE TABLE OF sopcklsti1, " hold email body, attachment details
li_objtxt TYPE TABLE OF solisti1, " hold message contents
li_reclist TYPE TABLE OF somlreci1. " hold email reciever details
DATA :
lwa_attachment LIKE LINE OF li_attachment,
lwa_pdf LIKE LINE OF li_pdf,
lwa_objpack LIKE LINE OF li_objpack,
lwa_objtxt LIKE LINE OF li_objtxt,
lwa_reclist LIKE LINE OF li_reclist,
lwa_document_data TYPE sodocchgi1. " hold document details like title, size etc.
DATA :
lv_sent_to_all TYPE c, " flag to check if mail is sent to all
l_att_lines TYPE i, " hold number of lines in attachment table
lv_spool_desc(68) TYPE c. " hold description of spool
CONSTANTS : lc_email_txt TYPE solisti1-line VALUE 'Find attached Payment Advice sent by this email.',
lc_sensitivity TYPE sodocchgi1-sensitivty VALUE 'O',
lc_raw TYPE sopcklsti1-doc_type VALUE 'RAW',
lc_pdf TYPE sopcklsti1-doc_type VALUE 'PDF',
lc_transf_bin TYPE sopcklsti1-transf_bin VALUE 'X',
lc_email TYPE sopcklsti1-obj_name VALUE 'Email',
lc_ext_id TYPE somlreci1-rec_type VALUE 'U',
lc_outbox TYPE sonv-flag VALUE 'X',
lc_obj_name TYPE sodocchgi1-obj_name VALUE 'Email Test',
lc_1 TYPE n VALUE '1',
lc_0 TYPE n VALUE '0'.
CLEAR: lwa_attachment,
lwa_pdf,
lwa_reclist,
lwa_objtxt,
lwa_objpack,
lwa_document_data.
REFRESH : li_attachment,
li_pdf,
li_reclist,
li_objtxt,
li_objpack.
Build attachment table
lwa_attachment-line = 'YOUR TEXT FROM INTERNAL TABLE LINES'.
APPEND lwa_attachment TO li_attachment.
Body of email
CLEAR lwa_objtxt.
MOVE lc_email_txt TO lwa_objtxt.
APPEND lwa_objtxt TO li_objtxt.
Title of the email
lwa_document_data-obj_descr = 'Title of email'.
lwa_document_data-sensitivty = lc_sensitivity.
lwa_document_data-expiry_dat = sy-datum + 15.
lwa_document_data-doc_size = STRLEN( lwa_objtxt ).
lwa_document_data-obj_name = lc_obj_name.
e-mail body
CLEAR lwa_objpack.
lwa_objpack-head_start = lc_1.
lwa_objpack-head_num = lc_0.
lwa_objpack-body_start = lc_1.
lwa_objpack-body_num = lc_1.
lwa_objpack-doc_type = lc_raw.
lwa_objpack-doc_size = STRLEN( lwa_objtxt ).
APPEND lwa_objpack TO li_objpack.
For e-mail attachment
DESCRIBE TABLE li_attachment LINES l_att_lines.
CLEAR lwa_attachment.
READ TABLE li_attachment INDEX l_att_lines INTO lwa_attachment.
CLEAR lwa_objpack.
lwa_objpack-transf_bin = lc_transf_bin.
lwa_objpack-head_start = lc_1.
lwa_objpack-head_num = lc_1.
lwa_objpack-body_start = lc_1.
lwa_objpack-body_num = l_att_lines.
lwa_objpack-doc_type = lc_raw.
lwa_objpack-obj_name = lc_email.
lwa_objpack-obj_descr = lv_spool_desc.
lwa_objpack-doc_size = ( 255 * ( l_att_lines - 1 ) ) + STRLEN( lwa_attachment-line ).
APPEND lwa_objpack TO li_objpack.
make recipient list
CLEAR lwa_reclist.
lwa_reclist-receiver = '[email protected]'. " Email address of your receipient
lwa_reclist-rec_type = lc_ext_id. " To external email id
lwa_reclist-COM_TYPE = 'INT'. " Internet mail
APPEND lwa_reclist TO li_reclist.
send mail with attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_document_data
put_in_outbox = lc_outbox
commit_work = 'X'
IMPORTING
sent_to_all = lv_sent_to_all
TABLES
packing_list = li_objpack
contents_bin = li_attachment
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.
WRITE: 'Success'.
ENDIF. -
Sending attachment Mail with multiple sheets in background mode
Hi,
I have a requirement that I am having a 3 internal table those values needs to be exported to multiple work sheets in one excel file which has to be mailed to the user. This program is running in back ground. Please suggest me.Firstly , generate the excel file ( The details of generating the excel file are described in detail in the below link).
https://wiki.sdn.sap.com/wiki/display/Snippets/DownloadDataintoMultipleSheetExcelDocumentwithNonEditableColumns(Passwordprotected)UsingABAP+OLE
After generating the excel file , use the FM SO_NEW_DOCUMENT_ATT_SEND_API1
to send the file. -
Very strange issue regarding Sender JDBC to Recevier RFC?
I've been testing sender JDBC to Receiver RFC,
but i realized that target RFC was not performed even though moni is clear and RFC adapter monitoring is clear,
both monitoring is successful.
also checked that RFC_Receiver adapter setting is correct.
i also checked RFC Function at Target side whether it is running or not correctly, it is no problem with test value.
i've never been seen such issue.
Dose anyone has such experience?
Message was edited by: Tony
Message was edited by: Tonyyes, nothing there.
but i forgot to tell you one thing,
sender has one and target has two each communication channel on service, JDBC to JDBC and RFC.
JDBC to JDBC is ok, but JDBC to RFC is above issue.
sxmb_moni has two message according to above two receivers when i execute, and two messages are correct
adapter monitoring is correct
Message was edited by: Tony -
My issue is that whenever i reply to a mail through outlook on my PC, i receive a mail on my blackberry of the original mail that i have replied on rather than the reply mail i.e the content on the mail is the same as of original mail and not of replied mail. It may be better if i dont receive a mail for the replies on blackberry or i receive a mail of the replied content. Can anyone pls help me with it...
Your work email account, is it setup using the BlackBerry Internet Service or BlackBerry Enterprise Server? If it is BlackBerry Internet Service, what type of email account is it? (Email Types: POP, IMAP or Outlook Web Access)
-
Issue regarding external mail send
Hi,
I have created a workflow wherein i am sending a mail to my gmail address. The problem is that when i execute a workflow, it gives me status for task as completed but when i check my gmail mail doesnot appear in it.
The thing i done regarding this issue is that i went to tcode SOST and from that tcode i executed but it was showing me error message as "Message cannot be transferred to node SMTP due to connection error (final)" How to solve this error ?
I have also gone through SCOT tcode and there i done with SMTP node
then why is this error and how to resolve it?
Thanks
ParagThis problem is related to configuration in SCOT. I think you can check the Basis forums for more help.
Check this link also
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/10dfad5a-5398-2b10-568b-d3d999d49b5c
Thanks
Arghadip -
Issue while sending mails using classes
Hi Experts ,
i have one issue when i try to send mails using classes cl_document_bcs,cl_cam_address_bcs,cl_bcs etc
ISSUE :
i put some data in selection screen and i get some output ( say i got 5 records), i select 3 records and press some button to trigger mail and mail is send, and now again the OUTPUT screen is shown with sended records but we can not send these records again ............ now i selcect remaining two records and press button to trigger mail and THIS TIME MAIL IS NOT SEND.
amd my code is :
CREATE OBJECT l_document.
CREATE OBJECT l_recipient.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = fp_wa_output
iv_codepage = fp_v_code_page
iv_add_bom = 'X'
IMPORTING
et_solix = l_wa_output_binary
ev_size = l_v_size ).
l_send_request = cl_bcs=>create_persistent( ).
*-->Creating Document
l_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = fp_it_content[]
i_subject = fp_text_48 ) .
*-->Adding Attachment*
CALL METHOD l_document->add_attachment
EXPORTING
i_attachment_type = fp_text_049
i_attachment_size = l_v_size
i_attachment_subject = fp_v_file
i_att_content_hex = l_wa_output_binary.
*-->Add document to send request*
CALL METHOD l_send_request->set_document( l_document ).
* do send delivery info for successful mails
CALL METHOD l_send_request->set_status_attributes
EXPORTING
i_requested_status = 'E'
i_status_mail = 'A'.
*-->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.
LOOP AT fp_s_mail INTO l_wa_mail.
l_v_objid = l_wa_mail-low.
l_v_mail = l_v_smtpadr.
TRANSLATE l_v_mail TO LOWER CASE.
l_recipient = cl_cam_address_bcs=>create_internet_address( l_v_mail ).
CALL METHOD l_send_request->add_recipient
EXPORTING
i_recipient = l_recipient
i_express = 'X' .
* i_copy = ' '
* i_blind_copy = ' '
* i_no_forward = ' '.
ENDLOOP.
**-->Trigger E-Mail immediately*
* IF fp_send_all EQ 'X'.
* l_send_request->set_send_immediately( 'X' ).
* ENDIF.
CALL METHOD l_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING result = l_v_sent_to_all ).
BREAK TARK.
IF l_v_sent_to_all = 'X'.
MESSAGE i000 .
ENDIF.
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.
CATCH cx_bcs INTO l_exp.
ENDTRY.
thanks in advance
rahulEvery time when i choose other network or dongle to send those mails it gets sent.
As per the description, seems it's an issue related to this specific network. Probably, they've adjusted their security policy, like blocked some port numbers, etc.
You might need to contact the support of your ISP to confirm what SMTP settings you need. Check port number, and security settings.
By the way, this is the forum to discuss questions and feedback for Windows-based Microsoft Office client. Since your query is directly related to
Office for mac, I would suggest you to post in the forum of
Office for Mac, where you can get more experienced responses:
http://answers.microsoft.com/en-us/mac/forum/macoffice2011?tab=Threads
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
Regards,
Ethan Hua
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs.
Maybe you are looking for
-
Error Error Processing Request. ORA-01403: no data found
To Whom It May Concern, I am trying to install the APEX listener by either using WebLogic or the standalone mode, both to no avail. I went through all the installation steps with my DBA for the DB side of things and we got no error messages. When try
-
An exception occurred during account Search
Hi Experts, On Account Search , I am getting the below exception. Cannot display view BP_HEAD_SEARCH/MainSearchResult of UI Component BP_HEAD_SEARCH An exception has occurred Exception Class CX_BOL_EXCEPTION - Access Previously Deleted Entity Method
-
Recently, just after the year period of course, my 4th gen ipod battery drained really fast. I got a replacement battery that is supposed to be better, but it still drains fast. It doesnt drain quite as fast, but if left unplugged overnight, I can no
-
I have had to have my hard drive rebuilt and as a result lost my music library. I have retained this on my ipod. I have followed the help given via the web links and it has stated that I need to click on the ipod icon on my explore page and copy the
-
How do I get my home page back and uninstall "home.mywebsearch"?
When I open up Mozilla Firefox the home page has been changed from "comcast.net" to "http://home.mywebsearch.com/index... Is this from Firefox? What happened to my homepage? What is this page, and how do I go back to the home page comcast.net? Who is