cancel
Showing results for 
Search instead for 
Did you mean: 

how to send a email notification from scheduled task script?

Former Member
0 Kudos

Hi,

i have to send every day an email to all collaborators of selected MA.

i wrote a script which will be started as scheduled task.

// ... //

sendMaMail(maLink, emailAddress, userName, msg) {

    logInfo("sending e-mail to " + userName + " / " + emailAddress + " => msg from field: " + msg + ", link: " + maLink);

    sender = session.getAccount();

    mailTypeEnum = new MailTypeEnumType(MailTypeEnumType.ODP_CUSTOM_TEMPLATE1);

    NotificationUtil.sendNotification(emailAddress, sender, mailTypeEnum , params,null,null);

}

My problem is that "session.getAccount()" return the current user with his email address.

When the script is running as a scheduled task there is no current user logged in and

"session.getAccount()" return a user with the "sys@mail" email address witch is not valid.

Is there any way to send a "system notification" from scheduled task?

thanks und sorry for my terrible english

Waldemar

Accepted Solutions (1)

Accepted Solutions (1)

former_member190023
Contributor
0 Kudos

Hello Waldemar,

In a scheduled task, session.getAccount() should return the "Run As User" configured in the Scheduled Task. User should have a valid email anyway.

Next, check system property messaging.mail_source_policy. If it is set as SENDERS_COMPANY, then the actual 'from' address will be picked up from the company "Source E-mail:" field.

Somewhere you have a misconfiguration that returns the "sys@mail" value which needs to be corrected.

Bogdan

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you very much.

It is running now

former_member207877
Active Participant
0 Kudos

while setting up the schedule task you will be giving an entry "run as user" , the specific user which you have mentioned will execute the task

Raj