Community Tip - You can change your system assigned username to something more personal in your community settings. X
Hi,
I have been trying to send email through code.And I'm getting problem while adding
content text to my mail.If I run my code without adding message body, it works fine and I have
doubts on adding ResourceBundle files here.
I've created a simple class for that
RemoteMethodServer rms = RemoteMethodServer.getDefault();
GatewayAuthenticator auth = new GatewayAuthenticator();
auth.setRemoteUser("wcadmin");
rms.setAuthenticator(auth);
System.out.println("Connected to PDMLink!");
String userName="GT-User";
WTUser user;
QuerySpec qspec=new QuerySpec(WTUser.class);
qspec.appendWhere(new SearchCondition(WTUser.class,WTUser.NAME,SearchCondition.LIKE,userName),new int[]{0});
QueryResult qresult=PersistenceHelper.manager.find((StatementSpec)qspec);
while(qresult.hasMoreElements()){
user=(WTUser) qresult.nextElement();
System.out.println("User present in Windchill and his email id is--"+user.getEMail());
String userEmail=user.getEMail();
// TeamCommands.email(arg0);
Locale locale=new Locale("en", "US");
ResourceBundle labels=ResourceBundle.getBundle("ext.gt.test.MyResources",locale);
EMailMessage mail=EMailMessage.newEMailMessage();
mail.setSubject("For Windchill test");
mail.addRecipient(user);
mail.addPart("ext.gt.test.MyResources", labels.getString("Message"), null, "text/html");
EMailMessage.fetchUserFromEmailAddress(userName);
boolean ok=EMailMessage.isValidEmailAddress(userEmail);
// TeamCCHelper.service.emailMembers(null);
if(ok){
mail.send(true);
System.out.println("Email Queue got started.");
}
Following is the output which I got
Connected to PDMLink!
User present in Windchill and his email id -
EMailMessage message submission failed
EMailMessage Can't find resource for bundle ext.gt.test.MyResources, key This is
for test
EMailMessage subject: For Windchill test
EMailMessage not submitted to: -
Email Queue got started.
I'm using this http://myjavadoc.net/view/viewzip.php/7994267cff17717f230350bf9dba9d7f-com.infoengine.util__-javadoc.local.zip*/api/wt/mail/EMailMessage.html#addPart(java.lang.String, java.lang.String, java.lang.Object[], java.lang.String) method from EMailMessage class to add content in text content in my mail.
Also I have placed my ResourceBundle class in package which I mentioned in code.In the output am getting the statement that I have given inside the
ResourceBundle class.
Can anybody tell me why this "EMailMessage Can't find resource for bundle ext.gt.test.MyResources, key This is
for test" is giving like this though I have ResourceBundle class in place?
Or Is there any other way to add text content to email using API?
Thanks,
Solved! Go to Solution.
Problem solved.
I forgot to register/Compile resourcebundle classes with ant command.
Then I run the following command from windchill shell and it got solved.
ant -f bin/tools.xml bundle -Dbundle.input=ext.gt.test.*
Problem solved.
I forgot to register/Compile resourcebundle classes with ant command.
Then I run the following command from windchill shell and it got solved.
ant -f bin/tools.xml bundle -Dbundle.input=ext.gt.test.*
COuld you please provide the details on what are the entries required in the resource bundle file placed at "ext.gt.test" as mentioned in the mail thread.