Skip to Content
0
Former Member
Jan 11, 2006 at 08:31 AM

Unable to check UserGroup&send email

13 Views

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