cancel
Showing results for 
Search instead for 
Did you mean: 

SENDING MAILS IN WEBDYNPRO JAVA

Former Member
0 Kudos

Hi,

Can anyone send the code for sending mails from webdynpro (JAVA) APPLICATION using JAVA API .. ?

Accepted Solutions (0)

Answers (3)

Answers (3)

sridhar_k2
Active Contributor
0 Kudos

Hi,

You can use this following code.

import javax.mail.*;

import java.util.*;

import javax.mail.internet.*;

class Mail

{

public static void main(String s[])

{

Session ses=null;

Message msg=null;

try

{

Properties p=System.getProperties();

//Properties p=new Properties();

p.put("mail.smtp.host","host");

p.put("mail.transport.protocol","smtp");

p.put("mail.smtp.auth","false");

p.put ("mail.smtp.port", "25");

boolean sessionDebug=true;

Authenticator a=new Auth("usr","pwde");

ses=Session.getInstance(p,a);

ses.setDebug(sessionDebug);

msg=new MimeMessage(ses);

msg.setFrom(new InternetAddress("fahadibm@gmail.com"));

(Message.RecipientType.TO,address[0]); msg.setRecipient(Message.RecipientType.TO,new InternetAddress("imran@abc.com"));

msg.setSubject("Test");

msg.setSentDate(new Date());

msg.setText("This is a Test");

}

catch(Exception e)

{

System.out.println("E1"+e);

}

try

{

Transport.send(msg);

}

catch(Exception e)

{

System.out.println("Exception is"+e);

}

}

}

class Auth extends Authenticator

{

String name;

String pwd;

public Auth(String name,String pwd)

{

this.name=name;

this.pwd=pwd;

}

public PasswordAuthentication getAuthenticate()

{

return new PasswordAuthentication(name,pwd);

}

}

For more info, go thru these links.

/thread/25456 [original link is broken]

Regards,

Sridhar

saraswathi_d
Participant
0 Kudos
Former Member
0 Kudos

Hi

See this Thread

Kind Regards

Mukesh