Ok, so I know you have to set the security group id to be able to send emails using the apex mailer outside Apex
l_workspace_id := apex_util.find_security_group_id ('MYWORKSPACE');
apex_util.set_security_group_id (l_workspace_id);
to avoid getting errors like 'This procedure must be invoked from within an application session'.
But I'm running this procedure under a different database user then the Apex user. So my workspace id is null if I call the find security group id.
My database user is APPS (calling it from eBusiness Suite) and the Apex user is some custom user like XXX_APEX. He owns the workspace. APPS can execute the function, but cannot see any records in APEX_APPLICATIONS for example.
Is there a way around this so I can invoke these functions under APPS user rather than my custom user (since I may not be able to switch to the custom user when running procedures from Apps)?
Reason I want to do this is that we send emails from Apex front-end. However, if the number of emails is too high we like to schedule this for the background. But then suddenly I cannot use the Apex_Mail.Send procedure and have to use UTL_MAIL, which gives me other issues unfortunately due to the SMTP Host Address used.