JustToKnow
JustToKnow

Reputation: 823

Error while passing email inside utl_mail.send (Oracle 11g - sql) 06502 - 06512

I am getting this error message:

Error at line 1
ORA-06502: PL/SQL: numeric or value error 
ORA-06512: in "SYS.UTL_MAIL", line 654
ORA-06512: in "SYS.UTL_MAIL", line 671
ORA-06512: in "APPS.PR_MAIL_ME", line 44
ORA-06512: in line 2

This is my code, my cursor:

  cursor email_detail is
  select email
    from
    (
       <the subquery>
      )
   where rn = 1
     and status in ('WARNING','ERROR','STAND BY'); 

Then, i want to pass every single email inside utl_mail.send function using a LOOP

begin

  for c in email_detail
  loop
    begin

      utl_mail.send(sender => '[email protected]',recipients => c.email ,subject => 'Concurrents' ,message => 'adasdas');
    end;  
  end loop;

end;

I've tried so many times to solve this but i failed, could you please help me to solve this?

Upvotes: 0

Views: 2818

Answers (1)

Popeye
Popeye

Reputation: 35900

In 11g, you will need to execute following commands before using utl_mail package:

@rdbms/admin/utlmail.sql
@rdbms/admin/prvtmail.plb
grant execute on utl_mail to <your_user_or_public>

Now, the important step is, you need to add the address and port of the e-mail server to the “smtp_out_server” initialization parameter. If you do not do this, you will receive a “ORA-06502: PL/SQL: numeric or value error” error when you try to use the UTL_MAIL package.

See this oracle documentation for more details on smtp_out_server.

Cheers!!

Upvotes: 1

Related Questions