cancel
Showing results for 
Search instead for 
Did you mean: 

Sending mail from user defined function.

Former Member
0 Kudos

Hi All,

Is it possible to send a mail with the content of user defined function.

I have a requiremnt saying, number of records processed related to header records needs to send a mail to third party people.

Following is the information i need to send:

MappingTrace writetrace;

writetrace = container.getTrace();

try

{

result.addValue(a[0]);

writetrace.addWarning("number of D1 records processed for " b[0] "is:"+ a[0]);

}

catch(RuntimeException e)

{

writetrace.addWarning("value is"+a[0] );

throw e;

}

Thanks,

venu.

Accepted Solutions (1)

Accepted Solutions (1)

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

yes this is possible:

1. you can create a java archive which will send the mail

and invoke a method of this java class in your

user defined function with the value of the number

of your records

2. you can do your scenario in a BPM

and do it properly (and clearly) with mail adapter

then you won't need to do any mail sending from UDF

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Another option would be to use a 3rd party mailing tool like SendSMTP which you can call in from a Java code / UDF directly in SAP XI.

Conditions

1) You need to have SendSmtp installed on XI server

2) Have your mailing server SMTP enabled and you shd be on..

Regards

Sriram V.

Former Member
0 Kudos

Hi Michal,

Thank you very much.

I'm trying to use the following java code.

import java.util.Properties;

import javax.mail.*;

import javax.mail.Session.*;

import javax.mail.internet.*;

import javax.mail.internet.MimeMessage;

import javax.mail.internet.InternetAddress;

import javax.mail.Message;

import javax.mail.internet.MimePartDataSource;

public class SendJavaMail

{

public SendJavaMail()

{

}

public static void main(String[] args)

{

Properties props = new Properties();

props.setProperty("abcd","xyz");

Session session = Session.getDefaultInstance(props,null);

try

{

MimeMessage mMeassage = new MimeMessage(session);

mMeassage.setSubject("Subject");

mMeassage.setText("Hello");

InternetAddress fromAddress = new InternetAddress("venugopal.sirangi@southernwater.co.uk");

InternetAddress toAddress = new InternetAddress("sougata.deb@southernwater.co.uk");

mMeassage.setFrom(fromAddress);

mMeassage.setRecipient(Message.RecipientType.TO,toAddress);

Transport transport = session.getTransport("SMTP");

transport.connect("mailhost","","");

transport.send(mMeassage);

transport.close();

}

catch (MessagingException e)

{

System.out.println(e.getMessage());

}

}

}

Getting error in Netweaver dev studio:

Included necssary jars also.

java.lang.NoClassDefFoundError: javax/activation/DataSource

at MvpDevelopment.SendJavaMail.main(SendJavaMail.java:38)

Exception in thread "main" .

can we use this type of code in XI r else any modifications i needed to do?

Thanks,

venu.

Former Member
0 Kudos

>>java.lang.NoClassDefFoundError: javax/activation/DataSource

This error is because only mail.jar doesnt help, you also need activation.jar., as you are testing in NWDS.

You dont need these jar files to be uploaded in XI as the J2EE stack of XI must be having it already available.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

activation.jar can be downloaded from

http://java.sun.com/products/javabeans/jaf/downloads/index.html

if you want to test in NWDS

Regards,

michal

-


<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

Former Member
0 Kudos

Hi Michal,

Can u pls tell me the approach to send mail using BPM with the message generated in message mapping.

I'm generating message in message mapping saying n number of records processed for this meter reading.

this message i need to send as a mail.

Thanks,

venu,

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Venu,

You can use the Receiver Mail Adapter for this.

Take a look at this blog by Michal,

/people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address

Regards,

Bhavesh

Former Member
0 Kudos

Hi Venu ,

Give your mail id.I ll send the silution.

Thanks,

sekhar

Former Member
0 Kudos

Hi sekhar,

Thank u..

my mail-id : venugopal.sirangi@southernwater.co.uk.

Thanks,

venu

Former Member
0 Kudos

Hi Venu ,

Check you ID.I have sent just now.

Thanks,

Sekhar

Former Member
0 Kudos

Hi Bavesh,

Thank you.

when I'm trying to do this scenario.

Importing the given xsd as target is giving problem saying:

Cause: Unable to recognize the loaded document as valid WSDL Tag schema is not permitted as a root element. definitions is expected

Thanks,

venu.

Former Member
0 Kudos

Hi sekhar,

Sorry..I haven't received:

mai yahoo-id: venugopal_sirangi@yahoo.com.

Give ur mail-id:

Thanks,

venu.

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Venu,

Use the link given in michals blog to get the XSD and use it as your Target Message Type and do the mapping for it . It should work fine.

Just make sure that the XSD imported is correct.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bavesh,

I'm using the same XSD.but after importing , when i'm activating that XSD i'm getting error as above i mentioned.

Thanks,

venu.

shailesh_mane
Participant
0 Kudos

Hello Venu,

Instead of importing the XSD, you could create a Data Type "Mail" with the structure as below: The Data type has to be called "Mail"

-Mail

-


Subject

-


From

-


To

-


X_Mailer

-


Content

You could then create a Message Type and a Message Interface from this to be used in your BPM. This should work. Hope this helps.

Let me know.

Regards,

Shailesh

Former Member
0 Kudos

>

> Hi Bavesh,

>

> Thank you.

>

> when I'm trying to do this scenario.

>

> Importing the given xsd as target is giving problem saying:

>

> Cause: Unable to recognize the loaded document as valid WSDL Tag schema is not permitted as a root element. definitions is expected

>

> Thanks,

> venu.

You can get this error when creating the External Definition of the wrong category type for the given input file. For example you have the setting "Category" as WSDL (default option) when you are really trying to import an XSD from the source file. Try to select the correct format category from the drop down list and then select the file again to import.

Answers (0)