cancel
Showing results for 
Search instead for 
Did you mean: 

Portal mail service "from" specification

MauricioMiao
Contributor
0 Kudos

Hello all,

I am using Portal mail service but if I do not specify te from field it did not work:

ISendMailService sendMailSvc = (ISendMailService) ResourceFactory.getInstance().getServiceFactory().getService(ISendMailService.SERVICE_ID);

ISendMailItem mailItem = sendMailSvc.createMailItem();

mailItem = sendMailSvc.createMailItem();

mailItem.setContent(content);

mailItem.setSubject(subject);

mailItem.setMimeType(type);

mailItem.setTo(to);

mailItem.setFrom("generic@hotmail.com");

sendMailSvc.sendMail(mailItem, ep5User);

By now I am using the same user registered inside portal for notifications but as I did not find a way to read this configuration I am fixing the email account inside my program and this is something I want to avoid.

Does anyone know if there is a way to read what is the email account specified in Portal for notification or if there is a way to ommit the specification of setFrom.

Regards,

Mauricio

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mauricio,

Try setting the <i>From</i> to the string "anonymous".

Hope that helps,

Yoav.

MauricioMiao
Contributor
0 Kudos

Hi Yoav,

Unfortunatelly it did not work, but thanks anyway.

Mauricio

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Maurcio, have you solved the problem?

I want to use the mailing service from a basic form, a form with two fields and a send button,

What references are needed to use the mailing service?

What kind of project or component is the best to do the form?

Thanks in advanced.

Regards

MauricioMiao
Contributor
0 Kudos

Hello Optima,

The code I have is in Web Dynpro project, I have no experience in portal JSP Dynpro to tell you if this is better than WD for this case, what I can tell is that in WD it is very easy to be done.

The required references are:

bc.rf.framework_api.jar

bc.rf.global.service.notificator_api.jar

bc.sf.framework_api.jar

bc.util.public_api.jar

coll.appl.gw.srvcmail_api.jar

coll.shared.gw_api.jar

kmc.util.core_api.jar

public void onActionSendEmail(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionSendEmail(ServerEvent)

//Prepare user

IUser ep5User = null;

String message;

IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();

try {

IWDClientUser wdClientUser = WDClientUser.getCurrentUser();

com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();

//Create an ep5 user from the retrieved user

ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);

} catch (WDUMException e) {

message = e.getLocalizedMessage() + " (WDUMException)";

messageMgr.reportException(message,true);

} catch (UserManagementException e) {

message = e.getLocalizedMessage() + " (UserManagementException)";

messageMgr.reportException(message,true);

}

//Send the email

try {

ISendMailService sendMailSvc = (ISendMailService) ResourceFactory.getInstance().getServiceFactory().getService(ISendMailService.SERVICE_ID);

ISendMailItem mailItem = sendMailSvc.createMailItem();

mailItem = sendMailSvc.createMailItem();

messageMgr.reportSuccess("linha 1");

mailItem.setContent(this.getContent());

mailItem.setSubject("Session Registration");

mailItem.setMimeType("text/html");

messageMgr.reportSuccess("linha 2");

mailItem.setTo("mauricio@mail.com");

IChannel channel = ChannelFactory.getInstance().getChannel(ChannelFactory.EMAIL);

INotificatorService notificatorSvc = (INotificatorService) ResourceFactory.getInstance().getServiceFactory().getService(INotificatorService.NOTIFICATOR_SERVICE);

//notificatorSvc.getDefaultFromAddress(channel);

mailItem.setFrom(notificatorSvc.getDefaultFromAddress(channel));

messageMgr.reportSuccess(ep5User.getId());

sendMailSvc.sendMail(mailItem, ep5User);

messageMgr.reportSuccess("linha 4");

} catch (ResourceException e) {

message = e.getLocalizedMessage() + " (ResourceException)";

messageMgr.reportException(message,true);

} catch (GroupwareException e) {

message = e.getLocalizedMessage() + " (GroupwareException)";

messageMgr.reportException(message,true);

} catch (WcmException e) {

message = e.getLocalizedMessage() + " (WcmException)";

messageMgr.reportException(message,true);

}

//@@end

}

Regards,

Mauricio