cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to check UserGroup&send email

Former Member
0 Kudos

Dear all

I developed feedback form, through which i'm able to send email to the respective "emailid" which i was mentioned in the form, based on logedon email id from portal. But in our secnario we divited the customers to different groups...lets say Branch1, branch2 etc..

I will assign the user to the Branch1. so it has to automatically find which group he belongs to and send email to the appropriate id of that branch.

public void doProcessAfterInput() throws PageException {

InputField myInputField = (InputField) getComponentByName("EMAIL_ADDR");

HtmlEdit txtdescr = (HtmlEdit)getComponentByName("Edit_Text");

if (myInputField != null) {

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IUserContext iuc = request.getUser();

IGroupFactory gf=UMFactory.getGroupFactory();

this.email_from = iuc.getEmail();

}if (txtdescr != null) {

this.txtdescr = txtdescr.getText();}

}

public void doProcessBeforeOutput() throws PageException {

System.out.println("doProcessBeforeOutput");

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IUserContext iuc = request.getUser();

try {

InternetAddress fromAddress = new InternetAddress(iuc.getEmail());

} catch (AddressException e) {

// TODO Auto-generated catch block

e.printStackTrace();}}}

public void send_mail (){

try{

Properties props = new Properties();

//put the smtp server here

props.put("mail.smtp.host","111.12.12.11");

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

Message msg = new MimeMessage(session);

IUser loggeduser = request.getUser();

if (loggeduser.isMemberOfGroup("BLR", true)){

InternetAddress addressTo = new InternetAddress("pradeep-pv.reddy@unilever.com");{

else if(){....}

msg.setFrom(addressTo);

msg.setRecipient(Message.RecipientType.TO,addressTo);

msg.setSubject("Portal Feedback");

msg.setContent(txtdescr, "text/html");

msg.setSentDate(new GregorianCalendar().getTime());

Transport.send(msg);

} catch (Exception E){ .....}}}}

Rgds

Pradeep

Message was edited by: Pradeep Reddy

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Pradeep,

1.) Use the "Code" button of the SDN forum editor to mark code. Makes it much more readable.

2.) Reduce any code submitted to a minimum showcase so that the problem is reproducable. More is not needed any many people will be shocked reading more than ten lines of code...

3.) "its not working" is not very precise!? How did it work, what is the concrete problem? Did the isMemberOfGroup never return true? Are you sure to have passed the correct uniqueGroupID?

4.) An alternative approach would be http://media.sdn.sap.com/html/submitted_docs/60_sp2_javadocs/ume/com/sap/security/api/IGroup.html#is... - anyhow, if you have a problem with one approach, probably you also would have it with the other.

Hope it helps

Detlev

Former Member
0 Kudos

Hi Detlev

Yeah..i Passed correct uniqueGroupId. It is sending mail...but unable to find to which mail id it is sending... it is not sending specific mail id which i have mentioned in code.

rgds

pradeep

detlev_beutner
Active Contributor
0 Kudos

Hi Pradeep,

> It is sending mail...

> but unable to find to which mail id it is sending...

Eeeem - if you don't know to which mail id it is sending the mail, how do you know that it in fact <i>sends</i> the mail?! Are you sure that no exception is thrown?!

For alternaive mailing approache(s) see /thread/98781 [original link is broken]

Hope it helps

Detlev

Answers (0)