cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are happy to announce the new Windchill Customization board! Learn more.

How can I get the email address of the administrator in Windchill ?

BernardWielfaer
6-Contributor

How can I get the email address of the administrator in Windchill ?

I have a java method that will send an email when dxf creation failes but how I can get the email address of the administrator configurated at Windchill ?

I hardcoded the email address now but it should be better if the java class does not need adaption when the administrator should ever change.

Best regards,

Bernard

1 ACCEPTED SOLUTION

Accepted Solutions
Prabhash
5-Regular Member
(To:BernardWielfaer)

Bernard, Once you have the admin as a WTPrincipal object, you can use below lines to fetch emailAddress dynamically:

String adminEmailId = null;

if(WTUser.class.isAssignableFrom(admin.getClass())){

WTUser adminUser = (WTUser)admin;

adminEmailId = adminUser.getEMail();

}

-Prabhash

View solution in original post

8 REPLIES 8
TomU
23-Emerald IV
(To:BernardWielfaer)

Not sure if it helps any, but the administrator's email address is listed in the wt.properties file. Maybe you can either retrieve the property with Java or manually parse the file. (It's available anonymously from <windchill url>/Windchill/wt.properties)

Look for these properties:

wt.mail.from=

wt.org.principalAdministratorEmail=

wt.notify.notificationSenderEmail=

BernardWielfaer
6-Contributor
(To:TomU)

The wt.mail.from is the senders email address (WindchillAlerts@lvd.be), I was looking for the administrator that is configurated via Site/Administrators, see picture a litle further.

jessh
5-Regular Member
(To:BernardWielfaer)

Another question would be which administrator(s) you want to contact.

For instance, in 10.2 (and maybe 10.1, I forget), the JMX-Administrators list is initially populated with the e-mail address entered at install time and this list can adjusted from that point to include more e-mail addresses.

BernardWielfaer
6-Contributor
(To:jessh)

I like to mail the Site administrator like in next picture. We are still running 9.1Snap1.jpg

Prabhash
5-Regular Member
(To:BernardWielfaer)

Hello Bernard,

I guess you can use SessionHelper.manager.getAdministrator() to fetch the wcadmin user.

Let me know if you need any clarification.

-Prabhash

Yes, Prabhash, this is what I have so far....

public void SendMailToAdmin(String errorMessage, Exception e)

{

try

{

EMailMessage email = EMailMessage.newEMailMessage();

wt.session.StandardSessionManager manager = wt.session.StandardSessionManager.newStandardSessionManager();

WTPrincipal admin = manager.getAdministrator();

String[] emailAddress = {"bwlf@lvd.be"};

email.addEmailAddress(emailAddress);

email.setSubject(errorMessage);

email.setOriginator(admin);

email.addPart(e.toString(), "text/html");

email.send(true);

}

catch (Exception Exception)

{

log.info("Creation of error email failed.\n" + Exception.toString());

}

}

Prabhash
5-Regular Member
(To:BernardWielfaer)

Bernard, Once you have the admin as a WTPrincipal object, you can use below lines to fetch emailAddress dynamically:

String adminEmailId = null;

if(WTUser.class.isAssignableFrom(admin.getClass())){

WTUser adminUser = (WTUser)admin;

adminEmailId = adminUser.getEMail();

}

-Prabhash

Thank you Prabhash, it works.

Top Tags