Trigger to Send Seperate Emails per Address on New Subscricption Insert

Hi Everyone,
I am trying to create a trigger that, on insert into and delete from a email_subscription table, will send an email to our MailMan server to subscribe or unsubscribe a member for each email address they have. The problem is I am not sure how to get the information form the other two related tables required to compose the message(s).
The tables are:
Email_Subscription (Member, Email_List)
Email (Member, Email)
EmailList (EmailListID, Email_List)
(where Email_Subscription.Member = Email.Member and Email_Subsciption.Email_List = EmailList.EmailListID)
A Member can have zero or more Email addresses but can only have one Email Subscription per Email List.
So this code:
utl_mail.send(
'[email protected]', --From
EmailList.Email_List || '[email protected]', --To
'', --BCC
'', --CC
'subscribe nodigest address=' || Email.Email, --Subject (subscribe on insert, unsubscribe on delete)
'', --Message
'text/plain; charset=us-ascii', --Email type
3); --Priority
Should be executed for each address the member has when a new email subscription is entered for them or to put it another way, the code should be run for each result of this query:
Select E.email, EL.email_list
From emaillist EL, email E
Where :NEW.member = E.member
And :NEW.email_list = EL.emaillistid
I know how to write a trigger that will insert a record once into another table but cannot work out how to run code for multiple records from related tables.
BTW I am using Oracle XE running on Windows 2003 and Utl_mail is set up and tested.
Any help is much appreciated.

Welcome to OTN.
I'm not sure sending a mail through trigger is at all a good option or not though it sounds rational but would like to share some thoughts.
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE    10.2.0.1.0      Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Elapsed: 00:00:00.08
satyaki>
satyaki>
satyaki>create table email_subq
  2   (  
  3     sr_no       number(5),
  4     s_name      varchar2(40),
  5     s_mail      varchar2(60)
  6   );
Table created.
Elapsed: 00:00:01.02
satyaki>
satyaki>create table send_mail_log
  2    (
  3      recipient_name   varchar2(40),
  4      email_id         varchar2(60)
  5    );
Table created.
Elapsed: 00:00:00.00
satyaki>
satyaki>create or replace trigger subsq_notifier
  2  before insert on email_subq
  3  for each row
  4  begin
  5    insert into send_mail_log values(:new.s_name,:new.s_mail);
  6  end;
  7  /
Trigger created.
Elapsed: 00:00:00.09
satyaki>
satyaki>
satyaki>insert into email_subq values(1,'SATYAKI','[email protected]');
1 row created.
Elapsed: 00:00:00.01
satyaki>
satyaki>select * from email_subq;
     SR_NO S_NAME                                   S_MAIL
         1 SATYAKI                                  [email protected]
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from send_mail_log;
RECIPIENT_NAME                           EMAIL_ID
SATYAKI                                  [email protected]
Elapsed: 00:00:00.00
satyaki>
satyaki>insert into email_subq values('A1','BILLY','[email protected]');
insert into email_subq values('A1','BILLY','[email protected]')
ERROR at line 1:
ORA-01722: invalid number
Elapsed: 00:00:00.01
satyaki>
satyaki>select * from email_subq;
     SR_NO S_NAME                                   S_MAIL
         1 SATYAKI                                  [email protected]
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from send_mail_log;
RECIPIENT_NAME                           EMAIL_ID
SATYAKI                                  [email protected]
Elapsed: 00:00:00.00
satyaki>
satyaki>rollback;
Rollback complete.
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from email_subq;
no rows selected
Elapsed: 00:00:00.00
satyaki>
satyaki>select * from send_mail_log;
no rows selected
Elapsed: 00:00:00.00Now, check the last part. If user somehow rollback it - still your mail will be send to the recipient which might be annoying for the user - i guess. ;)
So, my suggestion would be do not implement this kind of mailing approach through trigger. You can store them in any intermediate table and then after thorough verification you can send the mail using any job or scheduler that available in your version.
Regards.
Satyaki De.

Similar Messages

  • MAIL WILL REPLY, BUT WON'T SEND FRESH EMAILS FROM ADDRESS BOOK

    HI, Recently set up my pop3 account on mail. And hit a problem. Mail will receive emails, will send "REPLYS" but will not send fresh emails from address book or even if i type them in manually.
    This is so stupid.
    Help guys, Thanks
    Liam

    You should set it to Port 465, and select SSL, assuming this is the smtp.gmail.com server. Your ISP is probably blocking use of such a SMTP on Port 25, and that is very common policy.
    Ernie
    Message was edited by: Ernie Stamper

  • Thunderbird is no longer able to connect to internet (sending/receiving email, updating, creating a new account,...Firefox connects well

    Version 24.4.0 worked fine until yesterday (2014-04-06) running under windows 8.1 and suddenly it could no longer connetc to internet (sending/receiving email, updating, creating a new account,..). No change was done on my accounts configuration. Other applications connect correctly to internet. Some Windows 8.1 updates were automaticaly applied during the same period (??).
    Any suggestion would be appreciate
    Rgds

    Thank you for your answer. Of course before posting I checked the differetn relmated topics..
    As I explained nothing changed between the moment Thunderbird worked and the moment it stopped working. I checked the firewall (Norton intenet security) and the firewall of my router (Netgear). Nothing relates to Thunderbird.
    I cans get my mail from another workqtation (ubuntu/evolution) with the same provider (same parameters). I just wonder if the last windows 8.1 updates could provoke this trouble...
    For the moment I cannot get rid of this.

  • When needing to send an email from Pages a new email document does not come up. PDF

    When needing to send email document from Pages when I hit Share, send via email then PDF no new email document comes up. Please advise.

    Chances are you have an "illegal" character in the file name such as a / or *.

  • Broadcasting to send an email per project dynamically ?

    Hi all,
    The requirement of the business is the following :
    We want to send in an automated way a report to all PM (Project Manager) managing project in which they are in charge of.
    Every PM will receive 1 email per project he is in charge of.
    In standard broadcaster, we have the option u201Cbroadcast data burstingu201D but it unables to do dynamically, that is to say we do not know in advance project manager name. Each time we want to test, we have to select le Project Manager name.
    Following are the steps :
    1. We have created a query (A) with the required results and Infoobject 0Project Manager (ZXRESP) in drilldown. We have added an info-object email-address as attribute to info-object 0Project Manager (ZXRESP)
    2. We have created a new setting of type bursting -.
    a. On tab 'Recipient Determination' ->'Characteristic for Recipient Determination ' use 'Filter Document by Characteristic Value ' and select '0Project Manager ' as Characteristic
    b. 'Attribute for Recipient Determination' - Infoobject-emailaddress and 'Attribute Value Is '-->E-Mail address
    3. In section 'Selection of the Characteristic Values ' we have chosen u201CBy Following Selectionu201D and have to select project manager name. We would like to avoid this step manually but use in automatically way
    If  the fact to choose 'By Control Query' and use a variant to provide the necessary parameter can accomplish the requirement ? Do you have any solution for that ? Thank you in advance.
    All help are welcomed.
    Regards,
    Kevdin

    Check this blog:
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20d671c6-b377-2d10-7488-b75841c389a3
    Here we are creating a program and running it in background and that populates the values of the date variables.
    I think you can use the same to populate your varialbles.
    Please do close the thread if that answers your questions. Please help us keep the forums clean and open useful information only.
    For more information search on help.sap.com and you will get lots of material.
    Regards.
    Den

  • After I send an email, the address disappears from contnets sidebar

    Let's say I want to send an email to [email protected] The address is in the email contents sidebar, and I click twice on it to put the address in the To: space, and Send the email. Okay -- after doing that, if I then go back to the contents sidebar and look for that address, it has disappeared. (But, if I then type the name in the To: space, the entire address will appear.) It is also still in the Address Book. How do I stop the email addresses from being eliminated from the contents sidebar? Thank you very much! --Tom Carter, [email protected]

    Please ignore this question!   I am devolving into an even less capable computer user.  I realized that all my "Sent" emails have my address on the top. 
    BUT!  if someone could tell me how to display the address of the person I'm sending the email to…..  That would be very helpful.
    Cheers,
    S

  • Issue in sending a email internet address using 'so_new_document_send_api1'

    Hi ,
        I am calling  'SO_NEW_DOCUMENT_SEND_API1' inside an user exit to send an email whenever the notification gets created..If the user exit is called in the same transaction IW21 then the mail is sending successfully.But if the transaction IW21 is called via another transaction say IW31 or IW32 to create a notification,then the mail is not going.instead the mail still in waitning stage in Outbox in SAP business work place.
    Note:I should not use commit as 'X in 'SO_NEW_DOCUMENT_SEND_API1' because it is written inside the user exit.
    Edited by: Vigneswaran S on Dec 24, 2009 10:17 AM

    Hi,
    One option is to call the FM using STARTING NEW TASK and then also use commit = 'X'.
    Since we are using NEW TASK, it will occur in new task (and will not affect the user exit).
    Also the commit will be done INSIDE the new task, and will not affect the current user exit. This will be independent and done paralelly.
    Regards,
    Amit Mittal.

  • Email provider for sending many emails per day

    Morning all,
    I am looking for an email provider who can offer unlimited relays, I have at the moment a ever growing email list of over 1100. I would like to be able to email them all every single day. However using mac mail I have been told I can only send 250 emails each day.
    I am with Godaddy as hosting and email provider at the moment.
    Does anyone know how I can send more or other email clients/providers that offer such a service.
    Thanks in advance,
    Mike

    You need a service such as DirectMail (it's a purchased application linked to a mail service) or MailChimp (web service).
    http://directmailmac.com/
    Http://MailChimp.com
    Matt

  • Sending an email after creation of new role

    Whenever new role is created in Transaction PFCG I need to email to all the users.
    There is no User-Exit in PFCG and we can't create any new Program for this.
    So how it will be done?
    If anyone worked on it please reply to this as soon as possible.

    hi Zahid Khan,
    as said i tried the same.
    i have created a button "send" action :submit.
    and also have created a process"send mail" with the folloing code
    DECLARE
    l_body CLOB;
    BEGIN
    l_body := 'Thank you for your interest in the APEX_MAIL package.'||utl_tcp.crlf||utl_tcp.crlf;
    l_body := l_body ||' Sincerely,'||utl_tcp.crlf;
    l_body := l_body ||' The APEX Dev Team'||utl_tcp.crlf;
    apex_mail.send(
    p_to => '[email protected]',
    p_from => '[email protected]',
    p_body => l_body,
    p_subj => 'APEX_MAIL Package - Plain Text message');
    APEX_MAIL.push_queue;
    END;
    and , Process Success Message as "done" and When Button Pressed (Process After Submit When this Button is Pressed): "SEND" WITH Process Point : "ON SUBMIT AFTER COMPUTATIONS AND VALIDATION"
    The process is running.., getting the """success message""" but unable to""" get the mail""".(tried different combinations of mail ids)
    any help !!!

  • Sending e-mail old address dominates new one

    A friend has chaged his e-mail address. I send msil to the new address but it gets directed to his former one and I get an "undeliverable" reply.
    How can I remove an old address, address not contact from my list?

    Firefox doesn't do email, it's a web browser.
    If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
    If your problem is with Mozilla Thunderbird, see this forum for support.
    [http://www.mozillamessaging.com/en-US/support/] <br />
    or this one <br />
    [http://forums.mozillazine.org/viewforum.php?f=39]

  • Unable to send any email from my brand new ipad 2 and my iphone 3gs lately

    Lately I found that my Iphone & my brand new ipad2 are unable to send out any email. it keep mentioning about the outgoing setting.."the connection to the outgoing server"webmail..." failed.Additional Outgoing mail servers can be configures in setting, bla bla bla
    .I try look for some advices from apple suport communities seems doesn't work for me...pls help...>_<

    Anyone can help?

  • Trigger a event and send an email  when a new entry is created in a table

    Hi All,
                I have scenario here where i want to trigger a event and send an email too when a new entry is created in a Ztable or an existing entry is changed.
    Please let me know how can i achieve this.
    Please excuse me if you find it basic as I am not very old in Workflows.
    Thanks in Advance,
    Saket.

    Hi..
    For your Requirement workflow not Required.
    Write a  Program to send Mail. This Program has to execute when ever the Save Button is Click, then the mail will be sent.
    Check the program in this [link|https://wiki.sdn.sap.com/wiki/x/nYKdAw ], which send the mail.
    Regards,
    Surjith

  • Outgoing Mac Mail always send from the same address?

    Hey y'all -
    I use 3 gmail accounts through mac mail for 3 different purposes - all fine. But when I send mail, regardless of what account I send it from, recipients always recieve my emails from the same address? E.G. I send an email from addresses 1 or 2, but when they are received they are from address 3? I've also removed address 3 from mac mail, but recipients STILL see address 3 as the sender. Can anyone help? Would a reinstall of mail be appropriate, if so what would be the effective way to go about it?
    Thanks in advance,
    Stu

    SOLVED IT!
    Right, I had multiple email accounts, all gmail, address 1 2 & 3.
    All mail went to the right addresses, fine. But when I compose, lets say from address 1 or 2, it ALWAYS ends up being received the other end by address 3. I only find this out until I get a reply delivered to the wrong address.
    SO  go to preferences, select one of the problematic addresses, then outgoing mailserver (SMTP:) in this case it will say Gmail. Click it so you get the drop down and edit SMTP list. There is a tab that says advanced. This is where I noticed the problem. On my list of SMTP servers I had one for my microsoft account, and then one Gmail one for all 3 gmail accounts. And what did I find for authentication? the username and password of the problem address that ALL my gmail accounts were sending through. You need to create SEPERATE smtp servers for each and every account, especially when using multiple accounts of the same kind (e.g. 3 gmails!)
    This fixed the problem for me perfectly and now my emails send from the CORRECT selected address. HOORAH!
    ALSO...
    Regardless weather it by gmail or hotmail you compose from, mac defaults to using the next working server. Before setting up seperate smtp servers for each gmail I just deleted the one that was there and then it started sending from microsoft account etc... just to clarify that it works regardless of account type!

  • How can I send an email to a group from my iPhone?

    I want to send an email to a group in my contacts, but when I select the group, the individuals display for selection.  How can I send an email by addressing it to the group? 

    I recently upgraded my wife's computer to mountain lion so we could sync it with her iPhone, allowing her to send emails to the groups she manages whether she's at home or on the road.
    Is it really the case that the iPhone is incapable of this?  The mac does it fine and the iPhone goes through the motions but then bails when you hit send, saying it isn't a valid address.
    This really makes no sense.  Isn't this the whole point of iCloud?

  • Need to send a email alert to Projectmanger when publishing a project in project server 2010 PWA site

    Hi All
    When creating and publishing a project in PWA(server 2010) need to send a mail alert to the concerned project manager.
    How can i achieve this..
    I have configured the outgoing mail sending in sharepoint and its working fine now.
    Please help me..
    Thanks Advance
    SharePoint Module Lead Assyst International Private Ltd Cochin India

    Nothing is built in Project Server to do this for you automatically.
    They way I have done this in the past is to create a SQL job using SSIS.  It runs every hour and when it sees a project schedule that has a recent PUBLISHED date then this is a trigger to send an email to project manager.
    Cheers!
    Michael Wharton, MVP, MBA, PMP, MCT, MCTS, MCSD, MCSE+I, MCDBA
    Website http://www.WhartonComputer.com
    Blog http://MyProjectExpert.com contains my field notes and SQL queries

Maybe you are looking for

  • Errors upon erasing free space

    I have been experiencing particularly bizarre errors since switching to Mac. Two of the strangest are related to erasing free space. I wasn't aware that OS X could erase free space on its own, until I read the security guide, so I first purchased Shr

  • Diff in explain plan of 9i and 10g

    I am beginner and just started my dba career. Please can you help me by giving me the differences between a explain plan executed in oracle 9i and 10g. Why is there variations in the cost,cardinality and bytes. Is it that 9is explain plan is executed

  • No Service Available in BBP_PD

    HI Experts, In BBP_PD , when i click from menu System->Services for Objects... it popups a window where i can see the workflow overview e.tc..... But some times it shows that "No Service Available"... Please let me know why this happens Appreciated y

  • Portal runtime issue while starting up

    Hi Friends, We are getting the following error while stating portal http://<HN>:50000/irj/portal error msg "500: Internal server error. Application error occurred during request processing. Details: java.lang.NullPointerException: null". Whereas can

  • Microsoft Works, Outlook Express Addresses & Bookmarks converter.

    Just bought Mountain Lion and need to transfer Microsoft Works documents, Outlook Express addresses and IE bookmarks. Can anyone please point me to a free file converter for Imac?