SlideShare a Scribd company logo
HOW TO SEND A MAIL FROM UTL_SMTP OR FROM BACK END :
create or replace FUNCTION xxx_popmd_upd_email_notif (p_po_number
VARCHAR2,
p_po_line
NUMBER,
p_po_shipment_num
NUMBER,
p_po_release_num
NUMBER,
p_po_promissed_date
VARCHAR2,
p_justification
VARCHAR2)
RETURN VARCHAR2
AS
v_mail_conn utl_smtp.connection;
v_mail_host VARCHAR2 (30);
v_port_no NUMBER;
v_to_recipients apps.alr_distribution_lists.to_recipients%TYPE;
v_cc_recipients apps.alr_distribution_lists.cc_recipients%TYPE;
v_mail_subject VARCHAR2 (3000);
v_from VARCHAR2 (80) := 'OracleMailerTest@xxx.com';
crlf VARCHAR2 (2) := CHR (13) ||CHR (10);
v_employee_name apps.fnd_user.user_name%TYPE;
v_cp_date VARCHAR2 (30);
v_user_id NUMBER := fnd_profile.value ('USER_ID');
v_req_id NUMBER := fnd_global.conc_request_id;
l_cc VARCHAR2 (3000);
v_cc VARCHAR2 (3000);
l_to VARCHAR2 (2000);
l_tmp VARCHAR2 (3000);
n NUMBER;
BEGIN
SELECT to_recipients,
cc_recipients
INTO v_to_recipients,
v_cc_recipients
FROM apps.alr_distribution_lists
WHERE name = 'ORIGINAL_PROMISE_DATE_UPDATE';
dbms_output.put_line ('Email Distribution List: ' || v_to_recipients);
SELECT DISTINCT NVL (pf.full_name, fu.user_name)
INTO v_employee_name
FROM per_all_people_f pf,
fnd_user fu
WHERE fu.employee_id = pf.person_id(+)
AND user_id = v_user_id;
dbms_output.put_line ('Update by User Name: ' || v_employee_name);
SELECT NVL (TO_CHAR (actual_start_date, 'DD-MON-YYYY HH24:MI:SS'), sysdate)
INTO v_cp_date
FROM fnd_concurrent_requests fcr
WHERE request_id = v_req_id;
dbms_output.put_line ('Update by date: ' || v_cp_date);
SELECT SUBSTR (v.profile_option_value, 1, instr (v.profile_option_value, ':')
- 1),
to_number (SUBSTR (v.profile_option_value, 20, 2))
INTO v_mail_host,
v_port_no
FROM fnd_profile_option_values v,
fnd_profile_options o
WHERE v.profile_option_id = o.profile_option_id
AND o.profile_option_name = 'XX_CUS_TOP_EMAIL_SMTP';
l_cc := v_to_recipients;
LOOP
EXIT WHEN l_cc IS NULL;
v_mail_subject := 'Original Promise Date Update - ' || p_po_number || ' by
' || v_employee_name;
v_mail_conn := utl_smtp.open_connection (v_mail_host, v_port_no);
utl_smtp.helo (v_mail_conn, v_mail_host);
utl_smtp.mail (v_mail_conn, v_from);
n := instr (l_cc, ',');
--IF n =0 THEN exit; end if;
l_tmp := SUBSTR (l_cc, 1, n - 1);
IF n = 0 THEN
l_tmp := l_cc;
l_cc := NULL;
END IF;
dbms_output.put_line ('Output1: ' || l_tmp);
dbms_output.put_line ('Output2: ' || l_cc);
--utl_smtp.rcpt( l_tmp );
utl_smtp.rcpt (v_mail_conn, l_tmp);
utl_smtp.data (v_mail_conn, 'Date: ' ||
TO_CHAR (sysdate, 'Dy, DD Mon YYYY hh24:mi:ss')
|| crlf || 'From: ' || v_from
|| crlf || 'Subject: ' ||
v_mail_subject
|| crlf || 'To: ' ||
v_to_recipients
|| crlf || 'Cc: ' ||
v_cc_recipients
|| crlf || 'PO Number: ' ||
p_po_number
|| crlf || 'Line Number: ' ||
p_po_line
|| crlf || 'Shipment Number: ' ||
p_po_shipment_num
|| crlf || 'Release Number: ' ||
p_po_release_num
|| crlf || 'New Original Promised Date: ' ||
p_po_promissed_date
|| crlf || 'Justification: ' ||
p_justification|| crlf
|| crlf || 'Updated By :' ||v_employee_name
|| crlf || 'Date Updated :' ||v_cp_date|| crlf);
l_cc := SUBSTR (l_cc, n + 1);
dbms_output.put_line ('Output3: ' || l_cc);
utl_smtp.quit (v_mail_conn);
END LOOP;
v_cc:=v_cc_recipients;
LOOP
EXIT WHEN v_cc IS NULL;
v_mail_subject := 'Original Promise Date Update - ' || p_po_number || ' by
' || v_employee_name;
v_mail_conn := utl_smtp.open_connection (v_mail_host, v_port_no);
utl_smtp.helo (v_mail_conn, v_mail_host);
utl_smtp.mail (v_mail_conn, v_from);
n := instr (v_cc, ',');
--IF n =0 THEN exit; end if;
l_tmp := SUBSTR (v_cc, 1, n - 1);
IF n = 0 THEN
l_tmp := v_cc;
v_cc := NULL;
END IF;
dbms_output.put_line ('Output1: ' || l_tmp);
dbms_output.put_line ('Output2: ' || v_cc);
--utl_smtp.rcpt( l_tmp );
utl_smtp.rcpt (v_mail_conn, l_tmp);
utl_smtp.data (v_mail_conn, 'Date: ' ||
TO_CHAR (sysdate, 'Dy, DD Mon YYYY hh24:mi:ss')
|| crlf || 'From: ' || v_from
|| crlf || 'Subject: ' ||
v_mail_subject
|| crlf || 'To: ' ||
v_to_recipients
|| crlf || 'Cc: ' ||
v_cc_recipients
|| crlf || crlf || 'PO Number: ' ||
p_po_number
|| crlf || 'Line Number: ' ||
p_po_line
|| crlf || 'Shipment Number: ' ||
p_po_shipment_num
|| crlf || 'Release Number: ' ||
p_po_release_num
|| crlf || 'New Original Promised Date: ' ||
p_po_promissed_date
|| crlf || 'Justification: ' ||
p_justification|| crlf
|| crlf || 'Updated By :' ||v_employee_name
|| crlf || 'Date Updated :' ||v_cp_date|| crlf);
v_cc := SUBSTR (v_cc, n + 1);
dbms_output.put_line ('Output3: ' || v_cc);
utl_smtp.quit (v_mail_conn);
END LOOP;
RETURN ('Notification Sent');
EXCEPTION
WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
raise_application_error ( - 20000, 'Unable to Send Mail', true);
WHEN OTHERS THEN
raise_application_error ( - 20001, 'Other Errors: '||sqlerrm||';'||
SQLCODE);
END xxx_popmd_upd_email_notif;

More Related Content

What's hot

Oopsprc1e
Oopsprc1eOopsprc1e
Oopsprc1e
Ankit Dubey
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Adding two integers in c
Adding two integers in cAdding two integers in c
Adding two integers in c
Khuthbu Din
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
Rumman Ansari
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
Dr. Loganathan R
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
mohamed sikander
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
C programs
C programsC programs
C programsMinu S
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
Saranya saran
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
Saranya saran
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
Dr. Loganathan R
 
Switch
SwitchSwitch
Switch
Ankit Dubey
 

What's hot (20)

Oopsprc1e
Oopsprc1eOopsprc1e
Oopsprc1e
 
week-18x
week-18xweek-18x
week-18x
 
week-11x
week-11xweek-11x
week-11x
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
 
Adding two integers in c
Adding two integers in cAdding two integers in c
Adding two integers in c
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Progr3
Progr3Progr3
Progr3
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
 
Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2Bcsl 033 data and file structures lab s4-2
Bcsl 033 data and file structures lab s4-2
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
 
C programs
C programsC programs
C programs
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2Bcsl 033 data and file structures lab s2-2
Bcsl 033 data and file structures lab s2-2
 
Switch
SwitchSwitch
Switch
 

Viewers also liked

Estrategias y Promoción
Estrategias y PromociónEstrategias y Promoción
Estrategias y Promoción
Yusmary Izquiel
 
ESTATUS CONOFAM
ESTATUS CONOFAMESTATUS CONOFAM
ESTATUS CONOFAM
CONOFAMAC NACIONAL
 
Coaching
CoachingCoaching
Coaching
Yusmary Izquiel
 
PROGRAMA "SOMOS MEXICANOS"
PROGRAMA "SOMOS MEXICANOS"PROGRAMA "SOMOS MEXICANOS"
PROGRAMA "SOMOS MEXICANOS"
CONOFAMAC NACIONAL
 
Chocolate andrey
Chocolate andreyChocolate andrey
Chocolate andrey
Erick Eduardo
 
Receta pollo empapelado
Receta pollo empapeladoReceta pollo empapelado
Receta pollo empapelado
Erick Eduardo
 
El hombre mas antiguo
El hombre mas antiguoEl hombre mas antiguo
El hombre mas antiguo
Joao2127
 
CONOFAM STATUTOS
CONOFAM STATUTOSCONOFAM STATUTOS
CONOFAM STATUTOS
CONOFAMAC NACIONAL
 
ESTADÍSTICA PARA EL ITAM
ESTADÍSTICA PARA EL ITAMESTADÍSTICA PARA EL ITAM
ESTADÍSTICA PARA EL ITAM
CONOFAMAC NACIONAL
 
Internal Kinetics Personal Training Team
Internal Kinetics Personal Training TeamInternal Kinetics Personal Training Team
Internal Kinetics Personal Training Team
Mike Dimaio
 
Duane Slaney Resume Word Format
Duane Slaney Resume Word FormatDuane Slaney Resume Word Format
Duane Slaney Resume Word FormatDuane Slaney
 
EJ Roe and Michael Watson-Deep Sea Soil Collector
EJ Roe and Michael Watson-Deep Sea Soil CollectorEJ Roe and Michael Watson-Deep Sea Soil Collector
EJ Roe and Michael Watson-Deep Sea Soil CollectorEvan (E.J.) Roe
 
Mercadeo Virtual
Mercadeo VirtualMercadeo Virtual
Mercadeo Virtual
Yusmary Izquiel
 
Empreendedorismo no marketing
Empreendedorismo no marketingEmpreendedorismo no marketing
Empreendedorismo no marketing
Laís Palma
 
ACCIONES PARA ATENCIÓN A MIGRANTES
ACCIONES PARA ATENCIÓN A MIGRANTESACCIONES PARA ATENCIÓN A MIGRANTES
ACCIONES PARA ATENCIÓN A MIGRANTES
CONOFAMAC NACIONAL
 
Mercadeo de servicios
Mercadeo de serviciosMercadeo de servicios
Mercadeo de servicios
Yusmary Izquiel
 
Fifa scam crisis
Fifa scam crisisFifa scam crisis
Fifa scam crisis
Chaitanya Soni
 
What Is Hip-Hop?
What Is Hip-Hop?What Is Hip-Hop?
What Is Hip-Hop?
katia velasquez
 

Viewers also liked (20)

Estrategias y Promoción
Estrategias y PromociónEstrategias y Promoción
Estrategias y Promoción
 
ESTATUS CONOFAM
ESTATUS CONOFAMESTATUS CONOFAM
ESTATUS CONOFAM
 
Coaching
CoachingCoaching
Coaching
 
Newsletter june 2015
Newsletter june 2015Newsletter june 2015
Newsletter june 2015
 
PROGRAMA "SOMOS MEXICANOS"
PROGRAMA "SOMOS MEXICANOS"PROGRAMA "SOMOS MEXICANOS"
PROGRAMA "SOMOS MEXICANOS"
 
Chocolate andrey
Chocolate andreyChocolate andrey
Chocolate andrey
 
Receta pollo empapelado
Receta pollo empapeladoReceta pollo empapelado
Receta pollo empapelado
 
El hombre mas antiguo
El hombre mas antiguoEl hombre mas antiguo
El hombre mas antiguo
 
CONOFAM STATUTOS
CONOFAM STATUTOSCONOFAM STATUTOS
CONOFAM STATUTOS
 
ESTADÍSTICA PARA EL ITAM
ESTADÍSTICA PARA EL ITAMESTADÍSTICA PARA EL ITAM
ESTADÍSTICA PARA EL ITAM
 
Internal Kinetics Personal Training Team
Internal Kinetics Personal Training TeamInternal Kinetics Personal Training Team
Internal Kinetics Personal Training Team
 
Duane Slaney Resume Word Format
Duane Slaney Resume Word FormatDuane Slaney Resume Word Format
Duane Slaney Resume Word Format
 
EJ Roe and Michael Watson-Deep Sea Soil Collector
EJ Roe and Michael Watson-Deep Sea Soil CollectorEJ Roe and Michael Watson-Deep Sea Soil Collector
EJ Roe and Michael Watson-Deep Sea Soil Collector
 
Mercadeo Virtual
Mercadeo VirtualMercadeo Virtual
Mercadeo Virtual
 
Empreendedorismo no marketing
Empreendedorismo no marketingEmpreendedorismo no marketing
Empreendedorismo no marketing
 
ACCIONES PARA ATENCIÓN A MIGRANTES
ACCIONES PARA ATENCIÓN A MIGRANTESACCIONES PARA ATENCIÓN A MIGRANTES
ACCIONES PARA ATENCIÓN A MIGRANTES
 
Mercadeo de servicios
Mercadeo de serviciosMercadeo de servicios
Mercadeo de servicios
 
Fifa scam crisis
Fifa scam crisisFifa scam crisis
Fifa scam crisis
 
What Is Hip-Hop?
What Is Hip-Hop?What Is Hip-Hop?
What Is Hip-Hop?
 
Portfolio_AccordionPages
Portfolio_AccordionPagesPortfolio_AccordionPages
Portfolio_AccordionPages
 

Similar to How to send a mail from utl smtp or from back end

Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07
Thuan Nguyen
 
PLSQL.docx
PLSQL.docxPLSQL.docx
PLSQL.docx
18BF1AO482
 
Rewrite the printInfo() functions of the Employee and Department cla.pdf
Rewrite the printInfo() functions of the Employee and Department cla.pdfRewrite the printInfo() functions of the Employee and Department cla.pdf
Rewrite the printInfo() functions of the Employee and Department cla.pdf
alertshoeshingkimand
 
Sql pl
Sql plSql pl
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
DHANUSHTEJVUNNAM
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
Kim Berg Hansen
 
Plsql task answers
Plsql task answersPlsql task answers
Plsql task answersNawaz Sk
 
MCRL2
MCRL2MCRL2
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01
Thuan Nguyen
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...
Andrey Karpov
 
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comMcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
kashif kashif
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd marchRajeev Sharan
 
Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03
Thuan Nguyen
 
Modelling and In-Database Management of Relational, Data-aware Processes
Modelling and In-Database Management of Relational, Data-aware ProcessesModelling and In-Database Management of Relational, Data-aware Processes
Modelling and In-Database Management of Relational, Data-aware Processes
Andrey Rivkin
 
dbms project with output.docx
dbms project with output.docxdbms project with output.docx
dbms project with output.docx
ssuseraf4601
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdf
RavinReddy3
 
Plsql
PlsqlPlsql

Similar to How to send a mail from utl smtp or from back end (20)

Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07Oracle - Program with PL/SQL - Lession 07
Oracle - Program with PL/SQL - Lession 07
 
PLSQL.docx
PLSQL.docxPLSQL.docx
PLSQL.docx
 
Rewrite the printInfo() functions of the Employee and Department cla.pdf
Rewrite the printInfo() functions of the Employee and Department cla.pdfRewrite the printInfo() functions of the Employee and Department cla.pdf
Rewrite the printInfo() functions of the Employee and Department cla.pdf
 
SQL-PL
SQL-PLSQL-PL
SQL-PL
 
Sql pl
Sql plSql pl
Sql pl
 
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
 
Oracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web ServicesOracle database - Get external data via HTTP, FTP and Web Services
Oracle database - Get external data via HTTP, FTP and Web Services
 
Plsql task answers
Plsql task answersPlsql task answers
Plsql task answers
 
MCRL2
MCRL2MCRL2
MCRL2
 
Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01Oracle - Program with PL/SQL - Lession 01
Oracle - Program with PL/SQL - Lession 01
 
Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...Detection of errors and potential vulnerabilities in C and C++ code using the...
Detection of errors and potential vulnerabilities in C and C++ code using the...
 
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.comMcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
Mcrl2 by kashif.namal@gmail.com, adnanskyousafzai@gmail.com
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
PL_PKG_TASK
PL_PKG_TASKPL_PKG_TASK
PL_PKG_TASK
 
February0504 pm
February0504 pmFebruary0504 pm
February0504 pm
 
Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03
 
Modelling and In-Database Management of Relational, Data-aware Processes
Modelling and In-Database Management of Relational, Data-aware ProcessesModelling and In-Database Management of Relational, Data-aware Processes
Modelling and In-Database Management of Relational, Data-aware Processes
 
dbms project with output.docx
dbms project with output.docxdbms project with output.docx
dbms project with output.docx
 
LAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdfLAB_MANUAL_cpl_21scheme-2.pdf
LAB_MANUAL_cpl_21scheme-2.pdf
 
Plsql
PlsqlPlsql
Plsql
 

Recently uploaded

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

How to send a mail from utl smtp or from back end

  • 1. HOW TO SEND A MAIL FROM UTL_SMTP OR FROM BACK END : create or replace FUNCTION xxx_popmd_upd_email_notif (p_po_number VARCHAR2, p_po_line NUMBER, p_po_shipment_num NUMBER, p_po_release_num NUMBER, p_po_promissed_date VARCHAR2, p_justification VARCHAR2) RETURN VARCHAR2 AS v_mail_conn utl_smtp.connection; v_mail_host VARCHAR2 (30); v_port_no NUMBER; v_to_recipients apps.alr_distribution_lists.to_recipients%TYPE; v_cc_recipients apps.alr_distribution_lists.cc_recipients%TYPE; v_mail_subject VARCHAR2 (3000); v_from VARCHAR2 (80) := 'OracleMailerTest@xxx.com'; crlf VARCHAR2 (2) := CHR (13) ||CHR (10); v_employee_name apps.fnd_user.user_name%TYPE; v_cp_date VARCHAR2 (30); v_user_id NUMBER := fnd_profile.value ('USER_ID'); v_req_id NUMBER := fnd_global.conc_request_id; l_cc VARCHAR2 (3000); v_cc VARCHAR2 (3000); l_to VARCHAR2 (2000); l_tmp VARCHAR2 (3000); n NUMBER; BEGIN SELECT to_recipients, cc_recipients INTO v_to_recipients, v_cc_recipients FROM apps.alr_distribution_lists WHERE name = 'ORIGINAL_PROMISE_DATE_UPDATE'; dbms_output.put_line ('Email Distribution List: ' || v_to_recipients); SELECT DISTINCT NVL (pf.full_name, fu.user_name) INTO v_employee_name FROM per_all_people_f pf, fnd_user fu WHERE fu.employee_id = pf.person_id(+) AND user_id = v_user_id; dbms_output.put_line ('Update by User Name: ' || v_employee_name); SELECT NVL (TO_CHAR (actual_start_date, 'DD-MON-YYYY HH24:MI:SS'), sysdate) INTO v_cp_date FROM fnd_concurrent_requests fcr WHERE request_id = v_req_id; dbms_output.put_line ('Update by date: ' || v_cp_date); SELECT SUBSTR (v.profile_option_value, 1, instr (v.profile_option_value, ':') - 1),
  • 2. to_number (SUBSTR (v.profile_option_value, 20, 2)) INTO v_mail_host, v_port_no FROM fnd_profile_option_values v, fnd_profile_options o WHERE v.profile_option_id = o.profile_option_id AND o.profile_option_name = 'XX_CUS_TOP_EMAIL_SMTP'; l_cc := v_to_recipients; LOOP EXIT WHEN l_cc IS NULL; v_mail_subject := 'Original Promise Date Update - ' || p_po_number || ' by ' || v_employee_name; v_mail_conn := utl_smtp.open_connection (v_mail_host, v_port_no); utl_smtp.helo (v_mail_conn, v_mail_host); utl_smtp.mail (v_mail_conn, v_from); n := instr (l_cc, ','); --IF n =0 THEN exit; end if; l_tmp := SUBSTR (l_cc, 1, n - 1); IF n = 0 THEN l_tmp := l_cc; l_cc := NULL; END IF; dbms_output.put_line ('Output1: ' || l_tmp); dbms_output.put_line ('Output2: ' || l_cc); --utl_smtp.rcpt( l_tmp ); utl_smtp.rcpt (v_mail_conn, l_tmp); utl_smtp.data (v_mail_conn, 'Date: ' || TO_CHAR (sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf || 'From: ' || v_from || crlf || 'Subject: ' || v_mail_subject || crlf || 'To: ' || v_to_recipients || crlf || 'Cc: ' || v_cc_recipients || crlf || 'PO Number: ' || p_po_number || crlf || 'Line Number: ' || p_po_line || crlf || 'Shipment Number: ' || p_po_shipment_num || crlf || 'Release Number: ' || p_po_release_num || crlf || 'New Original Promised Date: ' || p_po_promissed_date || crlf || 'Justification: ' || p_justification|| crlf || crlf || 'Updated By :' ||v_employee_name || crlf || 'Date Updated :' ||v_cp_date|| crlf); l_cc := SUBSTR (l_cc, n + 1); dbms_output.put_line ('Output3: ' || l_cc); utl_smtp.quit (v_mail_conn);
  • 3. END LOOP; v_cc:=v_cc_recipients; LOOP EXIT WHEN v_cc IS NULL; v_mail_subject := 'Original Promise Date Update - ' || p_po_number || ' by ' || v_employee_name; v_mail_conn := utl_smtp.open_connection (v_mail_host, v_port_no); utl_smtp.helo (v_mail_conn, v_mail_host); utl_smtp.mail (v_mail_conn, v_from); n := instr (v_cc, ','); --IF n =0 THEN exit; end if; l_tmp := SUBSTR (v_cc, 1, n - 1); IF n = 0 THEN l_tmp := v_cc; v_cc := NULL; END IF; dbms_output.put_line ('Output1: ' || l_tmp); dbms_output.put_line ('Output2: ' || v_cc); --utl_smtp.rcpt( l_tmp ); utl_smtp.rcpt (v_mail_conn, l_tmp); utl_smtp.data (v_mail_conn, 'Date: ' || TO_CHAR (sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf || 'From: ' || v_from || crlf || 'Subject: ' || v_mail_subject || crlf || 'To: ' || v_to_recipients || crlf || 'Cc: ' || v_cc_recipients || crlf || crlf || 'PO Number: ' || p_po_number || crlf || 'Line Number: ' || p_po_line || crlf || 'Shipment Number: ' || p_po_shipment_num || crlf || 'Release Number: ' || p_po_release_num || crlf || 'New Original Promised Date: ' || p_po_promissed_date || crlf || 'Justification: ' || p_justification|| crlf || crlf || 'Updated By :' ||v_employee_name || crlf || 'Date Updated :' ||v_cp_date|| crlf); v_cc := SUBSTR (v_cc, n + 1); dbms_output.put_line ('Output3: ' || v_cc); utl_smtp.quit (v_mail_conn); END LOOP; RETURN ('Notification Sent'); EXCEPTION WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN raise_application_error ( - 20000, 'Unable to Send Mail', true); WHEN OTHERS THEN
  • 4. raise_application_error ( - 20001, 'Other Errors: '||sqlerrm||';'|| SQLCODE); END xxx_popmd_upd_email_notif;