Attachments using GOS
Hi all,
How to create and display attachments using GOS ?
Please reply in details as I am new to GOS. Thanks in advance.
Ananya
Hi Ananya,
check out these help docs
<b>About GOS(Generic Object Services):</b>
http://help.sap.com/saphelp_46c/helpdata/en/be/3fe63659241157e10000009b38f889/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/be/3fe63659241157e10000009b38f889/content.htm
<b>on how to create attachments:</b>
http://help.sap.com/saphelp_nw04/helpdata/en/87/50dbfba27f11d389c80000e8216438/content.htm
<b>and for a detail picture of GOS:</b>
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVOBS/BCSRVOBS.pdf
hope that helpz u,
shameem
Similar Messages
-
Attaching URL using GOS with 2 key fields
I found a program to attach URL using GOS. I tried the program using his sample Business object (BUS2012) and supplied a valid PO and the program works.
When I use the program using business object BUS1505 (Real Estate Contract) and put a valid contract number, the program didn't attached the URL. When I check the business object, I found out that the key fields are 2, Company Code and Contract Number. With this, how can attach it to the program.
Please help me on this. Thanks in advance.
Report Z_RMTIWARI_ATTACH_DOC_TO_BO
Written By : Ram Manohar Tiwari
Function : We need to maintain links between Business Object and
the attachment.Attachment document is basiclally a
business object of type 'MESSAGE'.In order to maintain
links, first the attachment will be crated as Business
Object of type 'MESSAGE' using Message.Create method.
Need to check if we can also use FM
'SO_DOC_INSERT_WITH_ORIG_API1' or SO_OBJECT_INSERT rather
than using Message.Create method.
REPORT Z_RMTIWARI_ATTACH_DOC_TO_BO .
Include for BO macros
INCLUDE : <cntn01>.
Load class.
CLASS CL_BINARY_RELATION definition load.
CLASS CL_OBL_OBJECT definition load.
PARAMETERS:
Object_a
P_BOTYPE LIKE obl_s_pbor-typeid DEFAULT 'BUS1505', " e.g. 'BUS2012'
P_BO_ID LIKE OBL_S_PBOR-INSTID DEFAULT '0000010000273', " Key e.g. PO No.
Object_b
P_DOCTY LIKE obl_s_pbor-typeid DEFAULT 'MESSAGE' NO-DISPLAY,
P_MSGTYP LIKE SOFM-DOCTP DEFAULT 'URL' NO-DISPLAY,
Relationship
P_RELTYP LIKE mdoblrel-reltype DEFAULT 'URL'.
types: BEGIN OF TY_MESSAGE_KEY,
FOLTP TYPE SO_FOL_TP,
FOLYR TYPE SO_FOL_YR,
FOLNO TYPE SO_FOL_NO,
DOCTP TYPE SO_DOC_TP,
DOCYR TYPE SO_DOC_YR,
DOCNO TYPE SO_DOC_NO,
FORTP TYPE SO_FOR_TP,
FORYR TYPE SO_FOR_YR,
FORNO TYPE SO_FOR_NO,
END OF TY_MESSAGE_KEY.
DATA : LV_MESSAGE_KEY type TY_MESSAGE_KEY.
DATA : LO_MESSAGE type SWC_OBJECT.
DATA : LT_DOC_CONTENT type standard table of SOLI-LINE with header
line.
First derive the Attachment's ( MESSAGE )document type.
P_DOCTY = 'MESSAGE'.
CASE P_RELTYP.
In case of URls
WHEN 'URL'.
P_MSGTYP = 'URL'.
In case of Notes / Private Notes
WHEN 'NOTE' OR 'PNOT'.
P_MSGTYP = 'RAW'.
WHEN 'ATTA'.
P_MSGTYP = 'EXT'.
Not implemented as yet...exit
EXIT.
WHEN OTHERS.
....exit
EXIT.
ENDCASE.
Create an initial instance of BO 'MESSAGE' - to call the
instance-independent method 'Create'.
swc_create_object LO_MESSAGE 'MESSAGE' LV_MESSAGE_KEY.
define container to pass the parameter values to the method call
in next step.
swc_container LT_MESSAGE_CONTAINER.
Populate container with parameters for method
swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTTITLE' 'Title'.
swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTLANGU' 'E'.
swc_set_element LT_MESSAGE_CONTAINER 'NO_DIALOG' 'X'.
swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTNAME' P_DOCTY.
swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTTYPE' P_MSGTYP.
'DocumentContent' is a multi-line element ( itab ).
In case of URLs..it should be concatenated with &KEY& in the begining.
CASE P_MSGTYP.
WHEN 'URL'.
LT_DOC_CONTENT = '&KEY&http://intranet.corpoff' .
append LT_DOC_CONTENT.
In case of Notes or Private Notes, get the data from files on appl
server or from wherever(? - remember background).
WHEN 'RAW'.
LT_DOC_CONTENT = 'Hi How r u?' .
append LT_DOC_CONTENT.
In case of File attachments
WHEN 'EXT'.
Upload the file contents using open dataset in lt_doc_content .
Some conversion ( Compress ) might be required.
Not sure at this point
ENDCASE.
swc_set_element LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT.
swc_call_method LO_MESSAGE 'CREATE' LT_MESSAGE_CONTAINER.
Refresh to get the reference of create 'MESSAGE' object for attachment
swc_refresh_object LO_MESSAGE.
Get Key of new object
swc_get_object_key LO_MESSAGE LV_MESSAGE_KEY.
Now we have attachment as a business object instance. We can now
attach it to our main business object instance.
Create main BO object_a
data: LO_IS_OBJECT_A type SIBFLPORB.
LO_IS_OBJECT_A-INSTID = P_BO_ID.
LO_IS_OBJECT_A-TYPEID = P_BOTYPE.
LO_IS_OBJECT_A-CATID = 'BO'.
Create attachment BO object_b
data: LO_IS_OBJECT_B type SIBFLPORB.
LO_IS_OBJECT_B-INSTID = LV_MESSAGE_KEY.
LO_IS_OBJECT_B-TYPEID = P_DOCTY.
LO_IS_OBJECT_B-CATID = 'BO'.
*TRY.
CALL METHOD CL_BINARY_RELATION=>CREATE_LINK
EXPORTING
IS_OBJECT_A = LO_IS_OBJECT_A
IP_LOGSYS_A =
IS_OBJECT_B = LO_IS_OBJECT_B
IP_LOGSYS_B =
IP_RELTYPE = P_RELTYP
IP_PROPNAM =
I_PROPERTY =
IMPORTING
EP_LINK_ID =
EO_PROPERTY =
*CATCH CX_OBL_PARAMETER_ERROR .
*CATCH CX_OBL_MODEL_ERROR .
*CATCH CX_OBL_INTERNAL_ERROR .
*ENDTRY.
Check if everything OK...who cares!!
commit work.HI
You can look at object VBAP as an example. It'sthe sales order item and has two keys - sales order number and item number.
the key was created:
BEGIN OF KEY,
SALESDOCUMENTNO LIKE VBAP-VBELN,
ITEMNO LIKE VBAP-POSNR,
END OF KEY,
MATERIAL TYPE SWC_OBJECT,
SALESDOCUMENT TYPE SWC_OBJECT,
_VBAP LIKE VBAP.
ND_DATA OBJECT. " Do not change.. DATA is generated
Here is a object instantiation - just build the key with the two fields - then when you call the macro - you pass the one field that already has both keys in it.
GET_PROPERTY SALESDOCUMENT CHANGING CONTAINER.
SWC_CREATE_OBJECT
OBJECT-SALESDOCUMENT 'VBAK' OBJECT-KEY-SALESDOCUMENTNO.
SWC_SET_ELEMENT CONTAINER 'SalesDocument' OBJECT-SALESDOCUMENT.
END_PROPERTY. -
How to store notes using GOS functionality
hi expert
urgent things
can u help me in this issue how to store note or text in repository using GOS generic object services ???
as soon as possible .
thank youHello,
We cannot move the notes, stored through GOS, to content server as the size of the notes is not huge.
Only the PC attachments through GOS can be directed to content server.
Refer to the note 530792 for more details.
Cheers
Amit -
Uploading attachment using GOS for XK02/XK03
Hi All,
i am trying to upload the attachments to XK02(or XK03) for a corresponding vendors using GOS.
i have no idea how to do this.
plz help me...
thanks in advance.hi Surinder.
thanks for the link that was very help full.
but i need to upload the attachments through a program.
and the thing is BDC will not work in this case
do you know any other way to upload these attachements like using RFC's ? -
Hi All,
I have a requirement to send email to an external ID for which I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1.Can anyone give a sample code to send multiple excel attachments using this function module.
Points would be rewarded.
Thanks
Archana.Check the Thread,,
Re: more than 1 attachements/sheets in SO_DOCUMENT_SEND_API1 -
How can I send multiple attachments using SO_DYNP_OBJECT_SEND?
Hi,
I hope someone can offer advice on my problem.
My requirement is to allow users to select one or more documents from an ALV grid. I am then required to send these documents to multiple users via email using function module SO_DYNP_OBJECT_SEND.
I can successfully send one document as an attachment. However, I can't seem to figure out how to send multiple documents as attachments using SO_DYNP_OBJECT_SEND. Is this done in the packing list?
Is there some way to tell the program where the 1st attachment ends and the 2nd attachment starts?
My attachment content is in i_att_cont.
CALL FUNCTION 'SO_DYNP_OBJECT_SEND'
EXPORTING
object_hd_change = l_title
object_type = 'RAW'
raw_editor = abap_true
starting_at_x = '5'
starting_at_y = '1'
ending_at_x = '120'
ending_at_y = '20'
edit_title = 'X'
external_commit = abap_true
TABLES
objcont = i_objcont
rec_tab = i_rec_tab
packing_list = i_packing_list
att_cont = i_att_cont
exclude_fcode = i_exclude_fcode
EXCEPTIONS
object_not_sent = 1
owner_not_exist = 2
parameter_error = 3
OTHERS = 4.
If you require more information, please let me know. I will be happy to provide it.
Thanks.I finally found the solution.
The trick is to ensure you put the correct values in the body_start, body_num and objlen fields of the packing list.
Each additional attachment should start (body_start) at the end of the last attachment + 1.
The value for body_num is equal to the number of lines in the attachment being added.
And the objlen field is calculated by multiplying the number of lines in the attachent * 255.
Static data
gs_packing_list-file_ext = lv_ext.
gs_packing_list-transf_bin = 'X'.
gs_packing_list-objla = sy-langu.
gs_packing_list-objtp = 'EXT'.
gs_packing_list-objdes = lv_filename.
gs_packing_list-objnam = 'Attachment'.
gs_packing_list-head_start = 1.
gs_packing_list-head_num = 1.
Body Start
CLEAR lv_count.
DESCRIBE TABLE gt_temp_att_cont LINES lv_count.
gs_packing_list-body_start = lv_count + 1.
Body Num + Object Length
CLEAR lv_count.
DESCRIBE TABLE gt_att_cont LINES lv_count.
gs_packing_list-body_num = lv_count.
gs_packing_list-objlen = lv_count * 255.
APPEND gs_packing_list TO gt_packing_list.
Hopefully this helps some desperate soul in the future. -
Add attachments using workflow api throwing error
Hi,
I am getting the following error when i am trying to add attachments using worklist API.
Missing class: invokeBPEL.MetaData
Dependent class: com.evermind.io.ClassLoaderObjectInputStream
Loader: oc4j:10.1.3
Code-Source: /D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar
Configuration: <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar
This load was initiated at hw_services.root:0.0.0 using the Class.forName() method.
The missing class is not available from any code-source or loader in the system.
at oracle.classloader.PolicyClassLoader.handleClassNotFound (PolicyClassLoader.java:2068) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
at oracle.classloader.PolicyClassLoader.internalLoadClass (PolicyClassLoader.java:1679) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1635) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
at oracle.classloader.PolicyClassLoader.loadClass (PolicyClassLoader.java:1620) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/pcl.jar (from system property java.class.path), by sun.misc.Launcher$AppClassLoader@10469011]
at java.lang.ClassLoader.loadClassInternal (ClassLoader.java:319) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at java.lang.Class.forName0 (Native method) [unknown, by unknown]
at java.lang.Class.forName (Class.java:242) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at com.evermind.io.ClassLoaderObjectInputStream.resolveClass (ClassLoaderObjectInputStream.java:33) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at java.io.ObjectInputStream.readNonProxyDesc (ObjectInputStream.java:1538) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at java.io.ObjectInputStream.readClassDesc (ObjectInputStream.java:1460) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at java.io.ObjectInputStream.readOrdinaryObject (ObjectInputStream.java:1693) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at java.io.ObjectInputStream.readObject0 (ObjectInputStream.java:1299) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at java.io.ObjectInputStream.readObject (ObjectInputStream.java:339) [jre bootstrap, by jre.bootstrap:1.5.0_06]
at com.evermind.server.rmi.RMIProtocol$Version.unmarshallParameterDirectly (RMIProtocol.java:402) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIProtocol$Version_1_0.unmarshallParameter (RMIProtocol.java:471) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIProtocol.readObject (RMIProtocol.java:80) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIProtocol.readValue (RMIProtocol.java:161) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.ServerRmiMessageHandler.handleMethodInvocation (ServerRmiMessageHandler.java:514) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.ServerRmiMessageHandler.handleOrmiRequest (ServerRmiMessageHandler.java:272) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.ServerRmiMessageHandler.dispatchRequest (ServerRmiMessageHandler.java:241) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIServerConnection.processReceivedCommand (RMIServerConnection.java:176) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIConnection.handleCommand (RMIConnection.java:152) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands (RMIConnection.java:127) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIServerConnection.listenForOrmiCommands (RMIServerConnection.java:390) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.server.rmi.RMIConnection.run (RMIConnection.java:107) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run (ReleasableResourcePooledExecutor.java:303) [D:/product/10.1.3.1/OracleAS_1/j2ee/home/lib/oc4j-internal.jar (from <code-source> in META-INF/boot.xml in D:\product\10.1.3.1\OracleAS_1\j2ee\home\oc4j.jar), by oc4j:10.1.3]
at java.lang.Thread.run (Thread.java:595) [jre bootstrap, by jre.bootstrap:1.5.0_06]
Exception in thread "main"
This is the code i used
String userId = "oc4jadmin";
String password = "welcome1";
String sTaskId = "";
IWorkflowServiceClient wfSvcClient = WorkflowServiceClientFactory.getWorkflowServiceClient(WorkflowServiceClientFactory.REMOTE_CLIENT);
System.out.println("Before getting TaskService");
ITaskQueryService querySvc = wfSvcClient.getTaskQueryService();
System.out.println("After getting TaskService");
IWorkflowContext wfCtx = querySvc.authenticate(userId,password,"jazn.com",null);
System.out.println("Last out");
Predicate pred = new Predicate(TableConstants.WFTASK_STATE_COLUMN,Predicate.OP_EQ,IWorkflowConstants.TASK_STATE_ASSIGNED);
List queryColumns = new ArrayList();
queryColumns.add("TITLE");
queryColumns.add("PRIORITY");
queryColumns.add("STATE");
queryColumns.add("TASKID");
queryColumns.add("TASKNUMBER");
List tasks = querySvc.queryTasks(wfCtx,
queryColumns,
null, //Do not query addtional info
ITaskQueryService.ASSIGNMENT_FILTER_MY_AND_GROUP,
null, //No keywords
pred, //No custom predicate
null, //No special ordering
0, //Do not page the query result
0);
System.out.println("Task Size !!" +tasks.size());
if (tasks != null)
String[] taskList = new String[tasks.size()];
for (int i=0; i< tasks.size(); i++)
Task t = (Task)tasks.get(i);
taskList[i] = t.getSystemAttributes().getTaskId();
System.out.println("Found task: "+taskList);
sTaskId = taskList[i];
else
System.out.println("Did not find any tasks");
Task task = querySvc.getTaskDetailsById(wfCtx, sTaskId);
//Add Attachments
FileInputStream fs = new FileInputStream("D:/Test.txt");
ITaskService itask = wfSvcClient.getTaskService();
MetaData mdata = new MetaData();
mdata.setMimeType("text/html");
mdata.setContent("D:/Test.txt");
mdata.setInputStream(fs);
mdata.setName("Test Document");
itask.addAttachment(wfCtx, sTaskId, mdata);
if (task != null)
System.out.println("Completing task: "+task.getTitle());
wfSvcClient.getTaskService().updateTaskOutcome(wfCtx, task, "APPROVE");
Kindly let me know how to solve this issue.
Thanks,
Gomathihi,
Actually i have used AttachmentType..MetaData is the class which i created for implementing AttachmentType as it is Interface Class. Here is the code of MetaData class.
public class MetaData implements AttachmentType,java.io.Serializable{
public String getBoundary() {
// TODO Auto-generated method stub
return null;
public String getContent() {
// TODO Auto-generated method stub
return null;
public InputStream getInputStream() {
// TODO Auto-generated method stub
return null;
public String getMimeType() {
// TODO Auto-generated method stub
return null;
public String getName() {
// TODO Auto-generated method stub
return null;
public String getSystemVersionFlag() {
// TODO Auto-generated method stub
return null;
public String getTaskId() {
// TODO Auto-generated method stub
return null;
public String getURI() {
// TODO Auto-generated method stub
return null;
public String getUpdatedBy() {
// TODO Auto-generated method stub
return null;
public int getVersion() {
// TODO Auto-generated method stub
return 0;
public void setBoundary(String arg0) {
// TODO Auto-generated method stub
public void setContent(String arg0) {
String cont = null;
cont = arg0;
public void setInputStream(InputStream arg0) {
InputStream sStream = null;
sStream = arg0;
public void setMimeType(String arg0) {
String mime = null;
mime = arg0;
public void setName(String arg0) {
String sname = null;
sname = arg0;
public void setSystemVersionFlag(String arg0) {
// TODO Auto-generated method stub
public void setTaskId(String arg0) {
// TODO Auto-generated method stub
public void setURI(String arg0) {
// TODO Auto-generated method stub
public void setUpdatedBy(String arg0) {
// TODO Auto-generated method stub
public void setVersion(int arg0) {
// TODO Auto-generated method stub
kindly tell me how can i solve this issue.
Thanks,
Gomathi
Edited by: user647559 on Sep 23, 2008 10:05 PM -
Sending Attachments using JavaMail
I trying to send attachments using JavaMail API which is loaded into an oracle 8.1.7 database as a stored procedure, the code looks like this:-
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "SendMail" AS
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendMail {
// Sender, Recipient, CCRecipient, and BccRecipient are comma-
// separated lists of addresses;
// Body can span multiple CR/LF-separated lines;
// Attachments is a ///-separated list of file names;
public static int Send(String SMTPServer,
String Sender,
String Recipient,
String CcRecipient,
String BccRecipient,
String Subject,
String Body,
String ErrorMessage[],
String Attachments) {
// Error status;
int ErrorStatus = 0;
// create some properties and get the default Session;
Properties props = System.getProperties();
props.put("mail.smtp.host", SMTPServer);
Session session = Session.getDefaultInstance(props, null);
try {
// create a message;
MimeMessage msg = new MimeMessage(session);
// extracts the senders and adds them to the message;
// Sender is a comma-separated list of e-mail addresses as
// per RFC822;
InternetAddress[] TheAddresses =
InternetAddress.parse(Sender);
msg.addFrom(TheAddresses);
// extract the recipients and assign them to the message;
// Recipient is a comma-separated list of e-mail addresses
// as per RFC822;
InternetAddress[] TheAddresses =
InternetAddress.parse(Recipient);
msg.addRecipients(Message.RecipientType.TO,
TheAddresses);
// extract the Cc-recipients and assign them to the
// message;
// CcRecipient is a comma-separated list of e-mail
// addresses as per RFC822;
if (null != CcRecipient) {
InternetAddress[] TheAddresses =
InternetAddress.parse(CcRecipient);
msg.addRecipients(Message.RecipientType.CC,
TheAddresses);
// extract the Bcc-recipients and assign them to the
// message;
// BccRecipient is a comma-separated list of e-mail
// addresses as per RFC822;
if (null != BccRecipient) {
InternetAddress[] TheAddresses =
InternetAddress.parse(BccRecipient);
msg.addRecipients(Message.RecipientType.BCC,
TheAddresses);
// subject field;
msg.setSubject(Subject);
// create the Multipart to be added the parts to;
Multipart mp = new MimeMultipart();
// create and fill the first message part;
MimeBodyPart mbp = new MimeBodyPart();
mbp.setText(Body);
// attach the part to the multipart;
mp.addBodyPart(mbp);
// attach the files to the message;
if (null != Attachments) {
int StartIndex = 0, PosIndex = 0;
while (-1 != (PosIndex = Attachments.indexOf("///",
StartIndex))) {
// create and fill other message parts;
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex,
PosIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
PosIndex += 3;
StartIndex = PosIndex;
// last, or only, attachment file;
if (StartIndex < Attachments.length()) {
MimeBodyPart mbp = new MimeBodyPart();
FileDataSource fds =
new FileDataSource(Attachments.substring(StartIndex));
mbp.setDataHandler(new DataHandler(fds));
mbp.setFileName(fds.getName());
mp.addBodyPart(mbp);
// add the Multipart to the message;
msg.setContent(mp);
// set the Date: header;
msg.setSentDate(new Date());
// send the message;
Transport.send(msg);
} catch (MessagingException MsgException) {
ErrorMessage[0] = MsgException.toString();
Exception TheException = null;
if ((TheException = MsgException.getNextException()) !=
null)
ErrorMessage[0] = ErrorMessage[0] + "\n" +
TheException.toString();
ErrorStatus = 1;
return ErrorStatus;
show errors java source "SendMail"
CREATE OR REPLACE PACKAGE SendMailJPkg AS
-- EOL is used to separate text line in the message body;
EOL CONSTANT STRING(2) := CHR(13) || CHR(10);
TYPE ATTACHMENTS_LIST IS
TABLE OF VARCHAR2(4000);
-- high-level interface with collections;
FUNCTION SendMail(SMTPServerName IN STRING,
Sender IN STRING,
Recipient IN STRING,
CcRecipient IN STRING DEFAULT '',
BccRecipient IN STRING DEFAULT '',
Subject IN STRING DEFAULT '',
Body IN STRING DEFAULT '',
ErrorMessage OUT STRING,
Attachments IN ATTACHMENTS_LIST DEFAULT NULL)
RETURN NUMBER;
END SendMailJPkg;
show errors
CREATE OR REPLACE PACKAGE BODY SendMailJPkg AS
PROCEDURE ParseAttachment(Attachments IN ATTACHMENTS_LIST,
AttachmentList OUT VARCHAR2) IS
AttachmentSeparator CONSTANT VARCHAR2(12) := '///';
BEGIN
-- boolean short-circuit is used here;
IF Attachments IS NOT NULL AND Attachments.COUNT > 0 THEN
AttachmentList := Attachments(Attachments.FIRST);
-- scan the collection, skip first element since it has been
-- already processed;
-- accommodate for sparse collections;
FOR I IN Attachments.NEXT(Attachments.FIRST) ..
Attachments.LAST LOOP
AttachmentList := AttachmentList || AttachmentSeparator ||
Attachments(I);
END LOOP;
ELSE
AttachmentList := '';
END IF;
END ParseAttachment;
-- forward declaration;
FUNCTION JSendMail(SMTPServerName IN STRING,
Sender IN STRING,
Recipient IN STRING,
CcRecipient IN STRING,
BccRecipient IN STRING,
Subject IN STRING,
Body IN STRING,
ErrorMessage OUT STRING,
Attachments IN STRING) RETURN NUMBER;
-- high-level interface with collections;
FUNCTION SendMail(SMTPServerName IN STRING,
Sender IN STRING,
Recipient IN STRING,
CcRecipient IN STRING,
BccRecipient IN STRING,
Subject IN STRING,
Body IN STRING,
ErrorMessage OUT STRING,
Attachments IN ATTACHMENTS_LIST) RETURN NUMBER IS
AttachmentList VARCHAR2(4000) := '';
AttachmentTypeList VARCHAR2(2000) := '';
BEGIN
ParseAttachment(Attachments,
AttachmentList);
RETURN JSendMail(SMTPServerName,
Sender,
Recipient,
CcRecipient,
BccRecipient,
Subject,
Body,
ErrorMessage,
AttachmentList);
END SendMail;
-- JSendMail's body is the java function SendMail.Send();
-- thus, no PL/SQL implementation is needed;
FUNCTION JSendMail(SMTPServerName IN STRING,
Sender IN STRING,
Recipient IN STRING,
CcRecipient IN STRING,
BccRecipient IN STRING,
Subject IN STRING,
Body IN STRING,
ErrorMessage OUT STRING,
Attachments IN STRING) RETURN NUMBER IS
LANGUAGE JAVA
NAME 'SendMail.Send(java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String,
java.lang.String[],
java.lang.String) return int';
END SendMailJPkg;
show errors
var ErrorMessage VARCHAR2(4000);
var ErrorStatus NUMBER;
-- enable SQL*PLUS output;
SET SERVEROUTPUT ON
-- redirect java output into SQL*PLUS buffer;
exec dbms_java.set_output(5000);
BEGIN
:ErrorStatus := SendMailJPkg.SendMail(
SMTPServerName => 'gmsmtp03.oraclecorp.com',
Sender => '[email protected]',
Recipient => '[email protected]',
CcRecipient => '',
BccRecipient => '',
Subject => 'This is the subject line: Test JavaMail',
Body => 'This is the body: Hello, this is a test' ||
SendMailJPkg.EOL || 'that spans 2 lines',
ErrorMessage => :ErrorMessage,
Attachments => SendMailJPkg.ATTACHMENTS_LIST(
'/tmp/on.lst',
'/tmp/sqlnet.log.Z'
END;
print
If I try and send file as attachments from the tmp directory, then everything works ok, but if I try to send the same file from any other directory, then it doesn't work. Can anyone help? Is there something wrong with the code, I'm not aware of anything that would make it directory specfic. Permissions are the same on /tmp as the new directory /NRS/Data/SystemX which I'm trying to send the file from now.well
if u see the end of ur mail it shows the attachment dir there in which u have specified the address..why don't u do a change there or better have some in parameteres in the procedure for it..that would help in choosing the attachment directory on users wish?
hope i am getting the problem right..if not kindly correct me in understanding the problem.
thanX. -
Attachments using MDM java API
Hi
How to store attachments in MDM repository using MDM java API.
Could you please suggest us.
Thanks
SowmyaHi Sowmya,
You can store attachments using MDM Java API. You can use the following piece of code.
BinaryBlobRecord record2 = RecordFactory.createEmptyBinaryObjectRecord(tableID);
//Attachment to be saved
String filePath = wdContext.currentContextElement().getVa_Resource().getUrl(0);
IWDResource resource = wdContext.currentContextElement().getVa_Resource();
FileInputStream stream = (FileInputStream)resource.read(true);
int length = 0;
while(stream.read() != -1)
length++;
byte[] b = new byte[(int) length];
stream.read(b);
stream.close();
record.setName(new StringValue("filename"));
record.setOriginalName(new StringValue("filename"));
record.setHasOriginal(new BooleanValue(true);
RetrieveGroupTreeCommand groupTreeCommand = new RetrieveGroupTreeCommand(wdContext.currentContextElement().getVa_ConnectionStr());
groupTreeCommand.setSession(wdContext.currentContextElement().getVa_SessionID());
groupTreeCommand.setGroupType(GroupTypes.DATA_GROUP_TYPE);
groupTreeCommand.execute();
//Set data location and data group ID
record.setDataLocationId(new GroupNodeId("GN2"));
record.setDataGroupId(new GroupNodeId("GN2"));
record.setBinary(new BinaryValue(b));
CreateRecordCommand createRecComm =
new CreateRecordCommand(wdContext.currentContextElement().getVa_ConnectionStr());
createRecComm.setSession(wdContext.currentContextElement().getVa_SessionID());
createRecComm.setRecord(record);
createRecComm.execute();
//Link this record to the main table record
Record QRec = RecordFactory.createEmptyRecord(mainTable);
//Setting the above created record in main table record object
QRec.setFieldValue(attachmentField, new LookupValue(record.getId()));
CreateRecordCommand createRecComm =
new CreateRecordCommand(wdContext.currentContextElement().getVa_ConnectionStr());
createRecComm.setSession(wdContext.currentContextElement().getVa_SessionID());
createRecComm.setRecord(QRec);
createRecComm.execute();
Now the main table record is created with an attachment.
Hope this helps you.
Regards,
Sruti -
Can't Send Attachments Using Exchange Account
For some reason I can't send attachments using my Exchange account on my iPhone. Pictures, Word docs, Excel Docs, doesn't matter. They just get stuck in my out box and I get the following message, "Cannot Send Mail - An error occurred while delivering this message." I can receive attachments just fine, but cannot send or forward them. If I use any of the other email accounts on my phone, it works fine. The Exchange account is the only issue. Is this some limitation with Exchange on an iPhone or something? Anyone ever have the same problem as was able to fix it? Thanks!
I've got 38 iPhones deployed running the 3.1.2 OS against an Exchange 2007 server. Several of my users complain about the same issue, and I've seen it myself. I have found a workaround of sorts - I've found that if I've sent a message with an attachment and I get a failure to send, if I manually browse down to the Sent Items folder, that forces a replication of the Sent Items. The next time I do a manual sync, the e-mail with the attachment will go.
I presume this has something to do with Exchange trying to put a copy of the e-mail in to your Sent Items at the same time the iPhone is trying to send the message.
Potentially, this might be solved by turning off the option to always store your sent e-mails in the Sent Items. I have not yet tested that as a workaround as from a corporate standpoint and an ease-of-use standpoint, we want that e-mail in the Sent Items for reference.
If anyone has any success with this fix, please let me know. -
How to send mail attachments using java mail
can any one help how to create mails attachments using java mail
you can do it like this:
Message msg = new MimeMessage(session);
String fileAttachment = "c:/test.txt";
Multipart mp = new MimeMultipart();
BodyPart bp = new MimeBodyPart();
FileDataSource fds = new FileDataSource(fileAttachment);
bp.setDataHandler(new DataHandler(fds));
bp.setFileName(fds.getName());
mp.addBodyPart(bp);
msg.setContent(mp);
... -
Can we process files with attachments using File Adapter
Hi All,
I want to process files which have attachments using File Adapter.
Is it possible to process such files?
May be using standard modules?
Regards,
CBKLPAssuming you are talking about sender FILE channel....you can make use of PayloadSwapbean provided by SAP (standard module)...to read data from attachment.
Regards,
Abhishek. -
How to remove file attachments using the SDK
I am looking for ways to programmatically remove file attachments from work items. If I recall correctly, the system only keeps the file for as long as the relationship exists, so that, in theory, the file is deleted from the database a soon as the
relationship is removed.
I found this
Using the SDK to Create and Edit Objects and Relationships Using Type Projections
Is this the only way or are the other, simpler ways for deleting relationships and/or file attachments?
Is this something I could do with the Orchestrator Remove Relationship activity?
A little background on this question: I have multiple different teams with varying data retention requirements for Service Requests. My longest requirement is 3 years (audit) while most teams only require 90 days. I was looking to add in some
jobs for some more aggressive file attachment grooming to keep the database smaller.
Thanks.The relationship is defined as a membership/containment relationship. So, yes, if you delete the relationship, the file attachment (and the associated blob) are deleted as well.
Based on the background you described, I'm assuming you identify a bunch of work orders whose files you want to delete if they're older than X. So, for instance "Work Items with Y team; delete file attachments older than 90 days", "Work Items
with Q team; delete file attachments older than 3 years". Is that right?
If so, you don't necessarily need to delete relationships specifically...you can simply delete the file attachment objects which will delete the relationship, the file attachment object, and the associated blob (the file itself in the database).
Using the SDK, you will not need type projections for this. You'll only need the work item object(s) (an incident or service request or whatever), the GetRelatedObjects<>() method, and an IncrementalDiscoveryData object.
So, after you get all of the appropriate work items, you can use the following snippet to delete their file attachments if the attachments meet your age requirements
//Connect to the management group
String strMySCSMServer = "<my mgmt server>";
emg = new EnterpriseManagementGroup(strMySCSMServer);
IncrementalDiscoveryData idd = new IncrementalDiscoveryData();
ManagementPackRelationship relWorkItemHasFileAttachment = emg.EntityTypes.GetRelationshipClass(new Guid("AA8C26DC-3A12-5F88-D9C7-753E5A8A55B4")); //System.WorkItemHasFileAttachment
//Get the work item's related file attachments using it's Id
Guid myWorkItemGuid = new Guid("<some work item guid>");
IList<EnterpriseManagementObject> lstFileAttachments = emg.EntityObjects.GetRelatedObjects<EnterpriseManagementObject>(myWorkItemGuid, relWorkItemHasFileAttachment, TraversalDepth.OneLevel, ObjectQueryOptions.Default);
//Loop through each file attachment
foreach (EnterpriseManagementObject emoFile in lstFileAttachments)
//Determine its age
DateTime AddedDate = (DateTime)emoFile[null, "AddedDate"].Value;
TimeSpan FileAttachmentAge = AddedDate.Subtract(DateTime.Now);
//Prep the file attachment for deletion if it's old enough, in this example, older than 90 days
if (FileAttachmentAge.Days > 90)
idd.Remove(emoFile);
//Submit the deletions to the database.
idd.Commit(emg); -
Sending Attachments using Oracle Alerts
Hi All,
I am working on Oracle Alerts. I have to send an output of the report to the client, is it possible to send using Oracle Alerts.
Thanks in Advance,
Venky.Hi,
To send attachments using Oracle Alert, you can follow below mentioned steps:
1) While defining Oracle alert Action, Select 'Action Level' as 'Summary'
2) In Action Details, select 'Action Type' as 'Operating System Script'
3) Select 'Text' radio button
4) Write following code : uuencode <Name of the file along with the path> <Name of the attachment in the mail>|mailx -c &cc_mail_id,&to_mail_id -s "<Subject of the Mailer>" &to_mail_id.
5) You can use mail or sendmail command also instead of mailx command.
6) Save Alert details
Thanks and regards,
Indira -
Sending mails with attachments using oracle 8i
Hi,
Could anybody please send a sample code for sending mails
with attachments using oracle 8i.
Thanks in advanceFor oracle8i there is an example package from OTN:
http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
You have to re-write the package a bit to work it with BLOBs instead of RAW attachments, but that should be no problem
Hop this helps,
Michiel
Maybe you are looking for
-
2011 Macbook Pro powers off - need advice
Hi there I have a macbook pro that switches off randomly (happens sometimes when i move/transport it), and sometimes it only turns on when plugged in. When not plugged in and i press the power button to switch on i can hear the machine running for ab
-
Tecra A8 windows 7 64 Bit winload.exe boot error
Hi all, I hope that someone can help me on this because I really don't know what do to here:I have a Toshiba Tecra A8 PTA83E-01D031PT which had Windows 7 32 bit installed with 4GB of RAM, but it only detected 3,2Gb, which was normal due to the 32 bit
-
After updating to iOS8 I can no longer see photos in text messages. instead the photo briefly shows up then go to the Downloading text bubble. Any Help on this would be great. Brett
-
Can't subscribe to Weather Underground calendar
Hi Folks: I've been trying to subscribe to the local Weather Underground report as a subscribed calendar on my iPod Touch but when I do there's no data. The link is here: http://ical.wunderground.com/auto/ical/VA/Charlottesville.ics?units=english and
-
Adobe wont print, no page selected
I am experiencing a problem with my Windows 64 bit workstation, trying to print an extra-large (60"X90") poster to my HP Plotter. The Print dialog box shows the project divided vertically in three 36" wide strips, which should work out with my plotte