Tuesday 18 September 2012

API's to create User Password and Send Email

for crec in c1
loop
IF CREC.EMAIL_ADDRESS IS NOT NULL THEN
v_status:= fnd_user_pkg.ChangePassword (
username => crec.user_name,
newpassword =>crec.Pwd
);
IF v_status =TRUE THEN
dbms_output.put_line('The password reset successfully for the User:'crec.user_name);
commit;


begin
v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host,25);
utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
utl_smtp.Mail(v_Mail_Conn, v_From);
utl_smtp.Rcpt(v_Mail_Conn, crec.EMAIL_ADDRESS);
utl_smtp.Data(v_Mail_Conn,
'Date: ' to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') crlf
'From: ' v_From crlf
'Subject: ' 'R12' ' 'crec.NAME'-'v_Subject crlf
'To: ' v_Recipient crlf
crlf
'The new version of R12 system, goes live at 10:00 am tomorrow, Tuesday April 3' crlf
crlf
'You will be able to access the new SEAS using the following URL:' crlf
crlf
'https://XXXXXXXXXXXXX/OA_HTML/US/INDEX.htm' crlf
crlf
'Your User Name is ' ' : ' crec.user_name crlf -- Message body
'Your initial password (which you will be required to change at first login) is' ' : ' crec.Pwd crlf
crlf
crlf
'Please cut and paste the URL above into your browser window. If you have problems accessing the new system and need help please contact the Helpdesk'crlf
'on 12345 or log your call on AssystNET using R12 as a prefix.'crlf crlf
crlf
'Regards 'crlf
'System, Support & Development'crlf
'0123456800'
);
utl_smtp.Quit(v_mail_conn);
EXCEPTION
WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
raise_application_error(-20000, 'Unable to send mail: 'sqlerrm);
END;
ELSE
dbms_output.put_line('Unable to reset password due to'SQLCODE' 'SUBSTR(SQLERRM, 1, 100));
ROLLBACK;
END IF;
ELSE
dbms_output.put_line('Unable to Find Email Address for the User ' '--'crec.user_name);
END IF;

end loop;
END;

No comments:

Post a Comment