Mail_pkg Sending email

Hi All,
I am trying to send a mail through database. So, I tried to use a package mail_pkg given in Mr Tom link.
http://asktom.oracle.com/pls/asktom/f?p=100:12:0::NO::P12_QUESTION_ID,P12_PREV_PAGE:255615160805,11
I actually got success in doing so, the only problem is that when I have to send email to more users.. say 100 users and do I need to select individual mail id's from a table as below.Is there a better approach?
declare
Testid varchar2(2000);
Testid1 varchar2(2000);
Testid2 varchar2(2000);
Testid3 varchar2(2000);
Testid4 varchar2(2000);
Testid5 varchar2(2000);
begin
select email into Testid1 from Email_tables where NAME in ('Email1') and app_name='SendEmail';
select email into Testid2 from Email_tables where NAME in ('Email2') and app_name='SendEmail';
select email into Testid3 from Email_tables where NAME in ('Email3') and app_name='SendEmail';
select email into Testid4 from Email_tables where NAME in ('Email4') and app_name='SendEmail';
select email into Testid5 from Email_tables where NAME in ('Email5') and app_name='SendEmail';
mail_pkg.send( p_sender_email => '[email protected]',
p_from => 'Abc CorpMKB Account <[email protected]>',
p_to => mail_pkg.array(Testid1,Testid2,Testid3,Testid4,Testid5,Testid6),
p_cc => mail_pkg.array('[email protected]' ),
p_bcc => mail_pkg.array( '[email protected]' ),
p_subject => 'This is a test',
p_body => 'Test Email' );
end;
If I need to send email to 100 users - Is there a better way to pass the emailid variables instead of specifing each one in the: p_to => mail_pkg.array(Testid1,Testid2,Testid3,Testid4,Testid5,Testid6),
create or replace package mail_pkg as
type array is table of varchar2(255);
procedure send( p_sender_email in varchar2,
p_from in varchar2 default NULL,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2 default NULL,
p_body in long default NULL );
end;
create or replace package body mail_pkg
as
g_crlf char(2) default chr(13)||chr(10);
g_mail_conn utl_smtp.connection;
g_mailhost varchar2(255) := 'aaaaa';
function address_email( p_string in varchar2,p_recipients in array ) return varchar2
is
l_recipients long;
begin
for i in 1 .. p_recipients.count
loop
utl_smtp.rcpt(g_mail_conn, p_recipients(i) );
if ( l_recipients is null )
then
l_recipients := p_string || p_recipients(i) ;
else
l_recipients := l_recipients || ', ' || p_recipients(i);
end if;
end loop;
return l_recipients;
end;
Thank you,
procedure send( p_sender_email in varchar2,
p_from in varchar2 default NULL,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2 default NULL,
p_body in long default NULL )
is
l_to_list long;
l_cc_list long;
l_bcc_list long;
l_date varchar2(255) default
to_char( SYSDATE, 'dd Mon yy hh24:mi:ss' );
procedure writeData( p_text in varchar2 )
as
begin
if ( p_text is not null )
then
utl_smtp.write_data( g_mail_conn, p_text || g_crlf );
end if;
end;
begin
g_mail_conn := utl_smtp.open_connection(g_mailhost, 25);
utl_smtp.helo(g_mail_conn, g_mailhost);
utl_smtp.mail(g_mail_conn, p_sender_email);
l_to_list := address_email( 'To: ', p_to );
l_cc_list := address_email( 'Cc: ', p_cc );
l_bcc_list := address_email( 'Bcc: ', p_bcc );
utl_smtp.open_data(g_mail_conn );
writeData( 'Date: ' || l_date );
writeData( 'From: ' || nvl( p_from, p_sender_email ) );
writeData( 'Subject: ' || nvl( p_subject, '(no subject)' ) );
writeData( l_to_list );
writeData( l_cc_list );
utl_smtp.write_data( g_mail_conn, '' || g_crlf );
utl_smtp.write_data(g_mail_conn, p_body );
utl_smtp.close_data(g_mail_conn );
utl_smtp.quit(g_mail_conn);
end;
end;
Thank you.

user7988 wrote:
Hi All,
I am trying to send a mail through database. So, I tried to use a package mail_pkg given in Mr Tom link.
http://asktom.oracle.com/pls/asktom/f?p=100:12:0::NO::P12_QUESTION_ID,P12_PREV_PAGE:255615160805,11
I actually got success in doing so, the only problem is that when I have to send email to more users.. say 100 users and do I need to select individual mail id's from a table as below.Is there a better approach?
declare
Testid varchar2(2000);
Testid1 varchar2(2000);
Testid2 varchar2(2000);
Testid3 varchar2(2000);
Testid4 varchar2(2000);
Testid5 varchar2(2000);
begin
select email into Testid1 from Email_tables where NAME in ('Email1') and app_name='SendEmail';
select email into Testid2 from Email_tables where NAME in ('Email2') and app_name='SendEmail';
select email into Testid3 from Email_tables where NAME in ('Email3') and app_name='SendEmail';
select email into Testid4 from Email_tables where NAME in ('Email4') and app_name='SendEmail';
select email into Testid5 from Email_tables where NAME in ('Email5') and app_name='SendEmail';
mail_pkg.send( p_sender_email => '[email protected]',
p_from => 'Abc CorpMKB Account <[email protected]>',
p_to => mail_pkg.array(Testid1,Testid2,Testid3,Testid4,Testid5,Testid6),
p_cc => mail_pkg.array('[email protected]' ),
p_bcc => mail_pkg.array( '[email protected]' ),
p_subject => 'This is a test',
p_body => 'Test Email' );
end;
If I need to send email to 100 users - Is there a better way to pass the emailid variables instead of specifing each one in the: p_to => mail_pkg.array(Testid1,Testid2,Testid3,Testid4,Testid5,Testid6),
It depends.
Where do the 100 email addresses reside?
EXACTLY how does the code know or decide to which emails address the message should be sent?
post SELECT which obtains the 100 desired addresses.

Similar Messages

  • Send email to multiple users using form

    I am using following code to send email from forms.
    But i want to send email to multiple users like atleast 10 users
    It i sworking for one user.
    If i give mail_pkg.send('tim@'oracle.com;[email protected]','Testing Oracle forms to send email','Testing oracle forms to send email','c:/x.pdf');
    The email is not going
    Can anybody help how to send to multiple users
    Thanks for your help
    T
    PACKAGE Mail_pkg IS
    session OLE2.OBJ_TYPE; /* OLE object handle */
    args OLE2.LIST_TYPE; /* handle to OLE argument list */
    procedure logon( Profile IN varchar2 default NULL );
    procedure logoff;
    procedure send( Recp IN varchar2,
    Subject IN varchar2,
    Text IN varchar2,
    Attch IN varchar2
    END;

    As said,
    Reports9i is better than Reports6i as far as sending emails is concerned. Reports9i allows you to send Reports in different formats as email attachements (PDF v3 is only one option). You can set subject, cc, bcc and some body text the way you want it. The Reports server only needs the address of a SMTP Server and you are ready to go. In Reports6i this is a bit more limited as you are not able to provide your own subject and body texts.
    I know that you can do this with PL/SQL from teh databae, but never tried it before.
    There is another option, which is to use a Java Bean in Forms for email. Thsi only works on the Web and a demo is included in teh Forms9i demos that can be downloaded from OTN. Though the demo is written for Forms9i it should work with Forms6i as well (not the Forms demo files because they are created in Forms9i).
    Fran

  • Cannot send email from yahoo account on iPhone 5

    I just got an iPhone5 and I couldn't set up my Yahoo email as "yahoo"--it would not allow me to complete the process despot multiple attempts. I had to set it up as an "other" account. I can receive and read emails on my phone, but when I reply those messages will not send. They go to the outbox and an error message pops up that says" the email account has been rejected by the server" Does anyone have advice on either issue: setting up yahoo properly and/or sending email from phone?

    outgoing mail server
    SMTP - Yahoo! SMTP Server
    primary server
    Yahoo! SMTP server - ON
    server port 465
    That's what I have for my yahoo account.

  • Cannot send email from non .mac server

    I am only able to send/reply emails using my .mac address. My 2 other server addresses keep giving me the following message.
    "Cannot send mail. One of the recipient addresses was invalid".
    How can I fix this?

    You should be able to send email from Safari, however I do wonder why you wish to do this and whether there is something inherently wrong with using your mail app and your iCloud address.

  • Cannot send email from MobileMe account

    Apple recently pushed out an update to the MobileMe calendar. Since upgrading my account, I am unable to send emails from Firefox4 (current version) in Windows. The page sits indefinitely at a loading screen. Apple Support won't help because it isn't an issue with Safari. Anyone else have this issue?

    When using the MobileMe account preset to create the account, the SMTP server is created with 587 as the SMTP server port, which can't be changed when using the MM account preset to create the account.

  • Cannot send email from Verizon to a specific domain using the web UI

    I'm trying to send an email to a specific address on a domain I own from a Verizon account using the web UI. Whenever I click send, a popup appears saying "Your e-mail contains the following invalid e-mail addresses:" followed by the email address. I can send email to this address from a GMail account as well as my work email.
    In Chrome, I can see that a "code":1002 error is being produced.
    Does anyone know why this would happen? Does Verizon check destination domains for reputation? Is there any way to debug this further?

    rhodeislandred wrote:
    I'm trying to send an email to a specific address on a domain I own from a Verizon account using the web UI. Whenever I click send, a popup appears saying "Your e-mail contains the following invalid e-mail addresses:" followed by the email address. I can send email to this address from a GMail account as well as my work email.
    In Chrome, I can see that a "code":1002 error is being produced.
    Does anyone know why this would happen? Does Verizon check destination domains for reputation? Is there any way to debug this further?
    What is the domain that is giving you the error?

  • Cannot send email from Powershell on Mailbox Role

    Hi,
    I am trying to send an email from Powershell on Mailbox role of Exchange server. I have installed Symantec Mail Security on Mailbox Role.
    When I try to send email using Powershell, I got the following error.
    PS C:\a> Send-MailMessage -to [email protected] -Subject "Alert Closed.. Service is restarted on Computer" -from
    [email protected] -Body "The service was found stopped on Computer it was started automatically and it is now running normally." -bodyasHTML -priority High -SmtpServer smtp.domain.com
    Send-MailMessage : Service not available, closing transmission channel. The server response was: 4.3.2 Service not active
    At line:1 char:1
    + Send-MailMessage -to [email protected] -Subject "Alert Closed.. Service is ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
        + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
    This command is working fine on every server except exchange server (CAS, Mailbox). Firewall is off on the servers.
    Any help will be highly appreciated.
    Regards,
    Anees

    Hi,
    Please check the similar thread .
    http://social.technet.microsoft.com/Forums/exchange/en-US/ef699832-8da9-4709-9a50-c6223b13bd95/sendmailmessage-returns-the-server-response-was-432-service-not-available?forum=exchangesvrsecuremessaginglegacy
    smtp server (smtp.domain.com) is rejecting the connection from the
     Mailbox role of Exchange server.
    So please allow the mailbox server ip address on the smtp server's (i.e. smtp.domain.com)
    receive connector to get it done 
    Regards
    S.Nithyanandham
    Thanks S.Nithyanandham

  • Cannot send email from an iPhone to a Outlook group.

    Hi,
    My question is simple and I'd like an exactly same answer : Can iPhone users send emails from their iPhone's to one or more groups created in Outlook?
    This is my situation: our organization is using iPhone to provide email, calendar, contact, task etc. to some of their employees. We are using Airwatch MDM Agent on user's iPhone because we have an Airwatch server in place. I have an user and she has an iPhone 5 and she has created some groups in Outlook but these groups are not reflected in her Contacts in the iPhone. I have update her phone with the latest update, although I was almost sure that this was not the issue, then I've found some interesting posts on internet saying that this was a known problem for the users with the previous iOS but I thought this might has been corrected with the iOS, apparently not.
    Also I've tried ''the trick'' that is posted on several forums with the iCloud but neither so it's working. I am looking for a straight answer, if this works or not on iPhone's?
    Thanks,
    Sebastian.

    There indeed ARE apps in the app store that will do what you want.  Just search and find the one that best fits your needs.

  • Cannot send email from the Mail App?

    I've had an izymail subscription for 1 year and just renewed it last week. I could never send an email from my Mail App without a window popping up stating "izymail cannot connect to the server" and the sending bar (along the bottom of the screen) just freezes and will not send.
    I've a Hotmail account linked up to izymail. Anyone know how to fix this problem?

    I fixed my problem - I deleted my email account on my iPhone, then tried to setup a new account. I had a few problems setting it up. It wouldn't recognize the incoming or outgoing servers and I lost my email altogether for a few hours. Then I changed every setting possible and finally figured out that I had 2-3 "Other SMTP Servers" as well as my "Primary Server". Once I deleted the Other SMTP Servers, my email worked and i'm able to send emails now!
    I also think changing the "Server Port" number helped solve my problem also, and making sure "Use SSL" was turned off.

  • Cannot send email from sbcglobal account

    Does anyone from Apple take what's discussed here back to a department that is useful in getting bugs fixed? I hope so. I am making this post although I know that NONE of you have an answer to my question that is satisfactory. I will come back to this thread as often as possible in hopes that the next update my finally fix my issue. For the love of all things, I just want to send email via IMAP like this article says I should:
    http://docs.info.apple.com/article.html?artnum=306074
    To be clear for you all, I've set up my sbcglobal account as detailed above...ie, using yahoo. This worked great for me until I applied the 1.0.1 update. Since then, I cannot send an email to save my life. Though receiving has worked just great.
    I am well aware that I can set up my sbcglobal account using pop3/smtp. This is an annoying work around to me, not a solution. If I set it up using pop3, I loose all kinds of ability I had with IMAP. This is a documented feature that is supposed to work on the iPhone, and it doesn't. I see no reason I should have to go back to an older technology/protocol.
    I've submitted multiple comments on the iphone about this. I just pray that someone at Apple fixes this soon. I'm so frustrated, and of course way past my point of returning the dang phone.

    Here's the response I received from Yahoo following the link you posted. As usual, nothing that moves the problem closer to a solution. First, there is an attempt at deflecting the problem by pointing out all the other great services Yahoo offers. Note the operative word "some". That's the whole reason I am writing the note. I already know that "some" of the services are working. I'm wondering about the one that doesn't so this doesn't help. Next comes pass the buck. Go talk to Apple about it. No comment on that one, it speaks for itself. And finally, if none of that works please give me more information. I'll call that reflection. So now its back to me. I think I'll take the ball and go home. For what its worth the response is below:
    I understand that you are having issues with the Yahoo! Mobile service.
    I understand that your sbcglobal.net accounts are not working with the
    IMAP push email option on your mobile device.
    Allow us to inform you that you are able to access some of Yahoo!s most
    popular services on this device - Yahoo! Mail, Yahoo! Address Book,
    Yahoo! Weather, Yahoo! Finance and Yahoo! oneSearch. If you are looking
    for assistance regarding your Yahoo! customizations featured in the
    Apple iPhone widgets, please contact Apple Care at:
    - URL: www.apple.com/support/iphone or
    - Phone: 1-800-MY-IPHONE or
    - go to www.apple.com/iphone for more information.
    However, if you are still encountering an issue with our service. In
    order for us to better understand this issue we will need some
    additional information:
    - The text of any error messages received
    - Exact steps taken that lead up to this event
    If you can describe it in more detail or other pertinent information,
    we'll be happy to help in whatever way we can.
    Thank you again for contacting Yahoo! Mobile Tech Support.
    Regards,
    Timothy
    Yahoo! Mobile Tech Team

  • Cannot send email from iPhone5--calendar syncing issues also

    I have an iPhone 5 and am not currently using iCloud.  I have 3 email accounts. 
    The first is a yahoo email account--and it both receives & sends emails just fine. 
    I use Outlook for the other two email accounts (one is an IMAP and the other is a POP).  Both receive email, but I cannot send out emails from my iPhone.  When I try to send an email from either account, I get this message: 
    "A copy has been placed in your Outbox.  The sender address "[address I used]" was rejected by the server.
    Also, I don't know if it is related, but my iPhone calendar isn't syncing with Outlook.  I add an appointment on my iPhone or in Outlook, and it won't appear in the other location (Outlook/iPhone). 
    Thanks for your help. 

    Check your settings, maybe the mail index is at fault.
    Setup Wizard and troubleshooting tips:
    http://www.apple.com/support/mail
    Also has a link to Mail community section.

  • Cannot send email from scanned pages

    I am having trouble with the updated HP remote app on Ipad, since the update I can scan the pages in, but then cannot send them via email. This is qute important because i work remotley from the office and rely on getting my design drawings in on a nightly basis
    please help

    cannot send email from scanned pages

  • Cannot send email from ipad?

    I can receive, but cannot send emails from my iPad. Always get message that I have wrong user name or password.

    Then make sure that the settings are correct in your email account.
    Check the outgoing mail server setting. Make sure that your username and password are in there.
    Settings>Mail, Contacts, Calendars>Your email account>Account>Outgoing mail server - tap the server name next to SMTP and check in the primary server and make sure your username and password are entered and correct - even if it says that the password is optional.

  • Cannot send email from Exchange 2007 to Exchange 2013

    Hello Anyone,
    Anyone can help? I've prepare MS Exchange 2013 already, for Migration MS Exchange 2007 and I got the issue.
    My issue is I can't send email from Exchange 2007 to Exchagen 2013, but for Exchange 2013 can send email to Exchange 2007,
    is my issue only internal email for external email both Exchange server is working fine.
    Regards,
    Eakkasak

    Thanks for your reply, when I send email from Exchange 2007 to Exchange 2013 I'm get the error message below.
    Delivery is delayed to these recipients or distribution lists:
    Eakkasak Buajan
    Subject:
    This message has not yet been delivered. Microsoft Exchange will continue to try delivering the message on your behalf.
    Delivery of this message will be attempted until 8/29/2014 8:30:29 PM (GMT+07:00) Bangkok, Hanoi, Jakarta. Microsoft Exchange will notify you if the message can't be delivered by that time."
    I'm already tick  "Exchange server Authentication" in the Default Receive connector properties of Exchange 2013"
    I'm restart services and restart all Exchange Server but doesn't work.
    Thanks,
    Eakkasak
    Sent by Microsoft Exchange Server 2007

  • Cannot send email from my mobileme on iphone 3g

    Suddenly coudn't access my mobileme email account. So I changed my password; and since I couldn't send email from my iphone 3G
    I can send/receive emails from icloud webpage or Thunderbird.
    Any clues?

    outgoing mail server
    SMTP - Yahoo! SMTP Server
    primary server
    Yahoo! SMTP server - ON
    server port 465
    That's what I have for my yahoo account.

Maybe you are looking for

  • EP 6.0, SP11  and Solution Manager 3.2

    Hi everyone, Is it possible to do add EP satelite systms? currently I am on solution manger 3.2, kernal 6.40 and Enterprise Portal 6.0, Service Pack 11 I would really appreciate if anyone can answer this question and great points will be rewarded tha

  • New iphone software

    I linked my 3GS up to a friend's Mac running Snow Leopard in order to download new software for my iphone - 4.2.1 . The syncing was OK, but when I disconnected I found that itunes didn't respond and told me I had no content. But on checking - syncing

  • I keep getting error -3259 when trying to update my iPad to iOS 5, how do I fix this?

    I have tried everything! Updating my system, using system restore, turning off all my firewalls, updating all my security programs, uniinstalling iTunes, reinstalling iTunes, googling the answer and I can't seem to find anything to do with this speci

  • VL32N - Receipt reversal issue

    Hello Friends, We mistakenly reversed the VL32N receipt using MIGO instead of VL09.  the reversed material document(102) is again reversed(101) using MIGO but still not able to do VL09 for that inbound delivery. Is there any way to overcome the mista

  • Importing Vector Images/Pictures into FInal Cut

    Questions about Vector Images in Movie Clips. I have a Adobe Illustrator File of a Map of the World that I want to use in a NTSC format Documentary. It is a Vector Graphic and can be scaled infinitely. I wanted to get the Best possible Resolution whe