Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CE8.5 JavaSdk - schedule to smtp

Status
Not open for further replies.

robot123

Programmer
Nov 8, 2002
8
DE
Hello,

I'm working at a java project that schedules reports to different smtp targets. The problem is, that the native java sdk object model is a bit different like the one of javascipt.. In *.csp the application is done, but not implementationable.

// the problem: The SmptOptions must be set, but the
//following statement couse an nullPointerExeption..
// .. but why ?? is DestinationPlugin == null after
// retrieving it ??

// SmtpOptions = ( ISMTPOptions ) DestinationPlugin.getScheduleOptions(); // null exeption

// I'm logged on the aps, got a session and infoObject(s)
// named myReport(s):




// set report schedule time
schedInfo = myReport.getSchedulingInfo();
schedInfo.setRightNow( true );
schedInfo.setType( CeScheduleType.ONCE );

// set the report schedule destination
System.out.print("attach smtp plugin:");
try
{
smtpPlugins = iStore.query("SELECT * From CI_SYSTEMOBJECTS WHERE SI_PARENTID = 29 AND SI_NAME = 'CrystalEnterprise.Smtp'");
}
catch (SDKException error)
{
System.out.println("FAILED reason:" + error.getMessage());
System.exit(1);
} System.out.println("OK");


if ( smtpPlugins.getResultSize() < 1 )
{
System.out.println(&quot;no smtp plugin found&quot;);
System.exit(1);
}
else smtpPlugin = (IInfoObject) smtpPlugins.get(0);


IPluginMgr pluginMgr = null;
IDestinationPlugin DestinationPlugin = null;
IPluginInfo pluginInfo = null;
ISMTPOptions SmtpOptions = null;

System.out.print(&quot;attach plugin manager:&quot;);
try
{
pluginMgr = session.getPluginManager();
DestinationPlugin = (IDestinationPlugin) pluginMgr.getPluginInterface(&quot;CrystalEnterprise.Smtp&quot; , IPluginMgr.Category.DESKTOP );

}
catch (SDKException error)
{
System.out.println(&quot;FAILED reason:&quot; + error.getMessage());
System.exit(1);
} System.out.println(&quot;OK&quot;);

if (DestinationPlugin == (IDestinationPlugin)null)
{ System.out.println(&quot;no report destinationPlugin found&quot;);
System.exit(1);
}



System.out.println(&quot;1&quot;);
SmtpOptions = ( ISMTPOptions ) DestinationPlugin.getScheduleOptions();
System.out.println(&quot;2&quot;);

SmtpOptions.setDomainName( CallParameter_SmtpDomain );
SmtpOptions.setServerName( CallParameter_SmtpServer );
SmtpOptions.setPort( 25 ); // standard smtport
SmtpOptions.setSMTPAuthenticationType( ISMTPOptions.CeSMTPAuthentication.NONE );
SmtpOptions.setSMTPUserName( CallParameter_SmtpServerUSER );
SmtpOptions.setSMTPPassword( CallParameter_SmtpServerPWD );
SmtpOptions.setSenderAddress( CallParameter_SmtpFROM_Address );

System.out.print(&quot;set smtp.toAdress:&quot;);
try
{
ToAdressList = SmtpOptions.getToAddresses();
}
catch (SDKException error)
{
System.out.println(&quot;FAILED reason:&quot; + error.getMessage());
System.exit(1);
} ToAdressList.clear();
ToAdressList.add( CallParameter_SmtpTO_Address );
System.out.println(&quot;OK&quot;);

//SmtpOptions.CCAddresses.Add(cc);
SmtpOptions.setSubject( CallParameter_SmtpSubject );
SmtpOptions.setMessage( CallParameter_SmtpSubject );
//SmtpOptions.Attachments.Add(mimetype, EloReportTyp + &quot;_&quot; + EloReportID + extension);


/*
IDestination reportDest = schedInfo.getDestination();

System.out.print(&quot;submit smtp plugin data to schedule instance:&quot;);
try
{
reportDest.setFromPlugin(reportDestinationPlugin);
}
catch (SDKException error)
{
System.out.println(&quot;FAILED reason:&quot; + error.getMessage());
System.exit(1);
} System.out.println(&quot;OK&quot;);

*/


.. one more question. Is it possible to use IReport for seperate scheduling tasks or is that the general Report interface ?

Regards
 
Does you fix your problems?And share your experience with me?

Thanks very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top