Sending email to multiple address using Utl_Smtp

Hi,
I want to send email to multiple address using the Utl_Smtp feature.
When I am sending email to one email address in the To:Field it works fine.However, when I send
to multiple address I am getting the below error.I am using a table(Email_test) to store all email id.
Error report:
ORA-29279: SMTP permanent error: 501 5.1.3 Invalid address
ORA-06512: at "SYS.UTL_SMTP", line 20
ORA-06512: at "SYS.UTL_SMTP", line 98
ORA-06512: at "SYS.UTL_SMTP", line 240
ORA-06512: at line 48
29279. 00000 - "SMTP permanent error: %s"
*Cause:    A SMTP permanent error occurred.
*Action:   Correct the error and retry the SMTP operation.
I am trying two options both ways I am getting error
Option 1:
Selecting two email id indivually in the select query as below
select email into v_Recipient1 from Email_test where Key_name='U1';
select email into v_Recipient2 from Email_test where Key_name='U2';
v_Recipient := v_Recipient1||';'||v_Recipient2;
Option 2:
Is there a way to use option
select email into v_Recipient1 from Email_test where Key_name='U4';
===========================================================
Create table Script
===========================================================
create table Email_test (Email varchar2(100),Key_name varchar2(10));
insert into Email_test values ('[email protected]','U1');
insert into Email_test values ('[email protected]','U2');
insert into Email_test values ('[email protected]','U3')
insert into Email_test values ('[email protected];[email protected];[email protected]','U4');
select * from Email_test
[email protected]                         U1
[email protected]                         U2
[email protected]                         U3
[email protected];[email protected];[email protected]     U4
select * from Email_test where Key_name in ('U1','U2','U3')
[email protected]     U1
[email protected]     U2
[email protected]     U3
select * from Email_test where Key_name='U4'
[email protected];[email protected];[email protected]
=======================================================
PL/SQL Block
===========================================================
declare
v_From VARCHAR2(80) := '[email protected]';
v_cc VARCHAR2(80);
v_Recipient VARCHAR2(80) ;
v_Recipient1 VARCHAR2(80) ;
v_Recipient2 VARCHAR2(80) ;
v_Subject VARCHAR2(80);
v_Mail_Host VARCHAR2(50);
v_Mail_Conn utl_smtp.Connection;
crlf VARCHAR2(2) := chr(13)||chr(10);
begin
--Mail Host name
select VALUE into v_Mail_Host from Server_info where server_name = 'SMTPServer';
select email into v_Recipient1 from Email_test where Key_name='U1';
select email into v_Recipient2 from Email_test where Key_name='U2';
v_Recipient := v_Recipient1||';'||v_Recipient2;
--for CC
select email into v_cc from Email_test where Key_name='U3';
v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
utl_smtp.Mail(v_Mail_Conn, v_From);
utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
utl_smtp.Rcpt(v_Mail_Conn, v_cc); -- To CC recepient
utl_smtp.Rcpt(v_Mail_Conn, v_BCC); To BCC recepient
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_From || crlf ||
'Subject: '|| v_Subject || crlf ||
'To: ' || v_Recipient || crlf ||
'Cc: ' || v_cc || crlf ||
'Content-Type: text/html;' ||crlf ||
--'Hello this is a test email');
crlf || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf );
utl_smtp.Quit(v_mail_conn);
end;
Any suggestion how to approach this issue.
Thank you

Simple Mail Transfer Protocol RFC 5321 specifications.
      RCPT TO:<forward-path> [ SP <rcpt-parameters> ] <CRLF>
   The first or only argument to this command includes a forward-path
   (normally a mailbox and domain, always surrounded by "&gt;" and "&lt;"
   brackets) identifying one recipient.In other words, you can only define a SINGLE mailbox address at a time. Multiple addresses requires multiple repeats of this command verb, once per maibox.
Do not confuse this and the To: tag line in the Mime header that contains a comma delimited list of recipients. That tag line can contain anything - it is not parsed, not checked, and not verified as matching the actual recipient mailboxes as specified via the RCPT TO verb.

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

  • Sending Mails to Multiple Recipients using UTL_SMTP

    create or replace procedure send_mail(msg_text varchar2) is
    c utl_smtp.connection;
    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
    utl_smtp.write_data(c, name || ': ' || header || utl_tcp.CRLF);
    END;
    BEGIN
    c := utl_smtp.open_connection('outlook.abc.com');
    utl_smtp.helo(c, 'abc.com');
    utl_smtp.mail(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.open_data(c);
    send_header('From', '"root" <[email protected]>');
    send_header('To', '"abc" <[email protected]>');
    send_header('Subject', 'WARNING: Salary has been changed');
    utl_smtp.write_data(c, utl_tcp.CRLF || msg_text);
    utl_smtp.close_data(c);
    utl_smtp.quit(c);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    BEGIN
    utl_smtp.quit(c);
    EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
    NULL; -- When the SMTP server is down or unavailable, we don't have
    -- a connection to the server. The quit call will raise an
    -- exception that we can ignore.
    END;
    raise_application_error(-20000,
    'Failed to send mail due to the following error: ' || sqlerrm);
    END;
    ==============
    when I execute the above using
    sql> exec send_mail('hihihih');
    I am getting the mails..no problems...
    So..I created the following trigger and used the above procedure to send the mail...
    CREATE OR REPLACE TRIGGER test_emp_table_trg
    AFTER UPDATE
    ON test_emp_table
    FOR EACH ROW
    WHEN (NEW.sal <> OLD.sal)
    DECLARE
    l_employee_name VARCHAR2 (240);
    l_old_sal VARCHAR2 (240);
    l_new_sal VARCHAR2 (240);
    l_message VARCHAR2 (240);
    BEGIN
    /* Gets the employee full name */
    BEGIN
    SELECT ename
    INTO l_employee_name
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_employee_name := NULL;
    END;
    /* Gets the old Salary */
    BEGIN
    SELECT sal
    INTO l_old_sal
    FROM test_emp_table
    WHERE empno = :OLD.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_old_sal := 0;
    END;
    /* Gets the new salary */
    BEGIN
    SELECT sal
    INTO l_new_sal
    FROM test_emp_table
    WHERE empno= :NEW.empno;
    EXCEPTION
    WHEN OTHERS
    THEN
    l_new_sal := 0;
    END;
    l_message:=
    'Employee Name= '
    || l_employee_name
    || 'Old Salary= '
    || l_old_sal
    || 'New Salary= '
    || l_new_sal;
    BEGIN
    send_mail (l_message);
    END;
    END;
    ===================
    I am not getting desired output..what might be problem friends...I am getting 0 values for old salary and new salary......
    One more thing..when i use 2 receipts in the send_mail procedure like this...I added the following lines in the procedure to send to multiple receipents..
    ======
    utl_smtp.rcpt(c, '[email protected]');
    utl_smtp.rcpt(c, '[email protected]');
    =============
    Pleas have a look and correct me, where i went wrong....
    Edited by: oraDBA2 on Sep 22, 2008 3:12 PM

    Hi, You can use the following routine to send mail to multiple recipients through utl_smtp.
    create or replace package mail_pkg
    as
    type array is table of varchar2(255);
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    create or replace package body mail_pkg
    begin
    g_crlf char(2) default chr(13)||chr(10);
    g_mail_conn utl_smtp.connection;
    g_mailhost varchar2(255) := 'ur mail server';
    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;
    procedure send( p_sender_e_mail in varchar2,
    p_from in varchar2,
    p_to in array default array(),
    p_cc in array default array(),
    p_bcc in array default array(),
    p_subject in varchar2,
    p_body in long );
    end;
    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_e_mail);
    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_e_mail ) );
    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;
    begin
    mail_pkg.send
    (p_sender_e_mail => 'urmail',
    p_from => 'urmail',
    p_to => mail_pkg.array( 'urmail','othersmail' ),
    p_cc => mail_pkg.array( ' othermail ' ),
    p_bcc => mail_pkg.array( '' ),
    p_subject => 'This is a subject',
    p_body => 'Hello Buddy, this is the mail you need' );
    end;
    /

  • Send email with multiple attachments using MS outlook

    Hi,
    Is it possible to send an email with multiple attachments using MS outlook. (Using activex)
    Regards,
    Neha

    nehrnul wrote:
    Hey thanks for the reply. I'll try that way also.
    but currently my requirement is to send email using MS Outlook. And I found 1 solution using invoke node
    Regards,
    Neha
    That' "requirement" sounds like it was written by someone who is trying to drive the design of the application.  Without knowing your personal situation it's hard for me to say, but if I had to guess I would say the real requirement is to send an email with multiple attachements, and the person giving that requirement thought sending it through Outlook would be the best way.  You should get clairification on what the real intend of that requirement is.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Help with sending emails to multiple users.

    Currently we have a process to send mail to muliple users by looping through the list of users and sending each individual an email
    <Action id='1' name='sendEmail' application='com.waveset.provision.WorkflowServices'>
    <Argument name='op' value='notify'/>
    <Argument name='template' value='$(template)'/>
    <Argument name='toUser' value='$(tuser)'/>
    <Argument name='catch' value='notificationException'/>
    </Action>
    The variable tuser contains a single email address.
    Is there any way to setup tuser to contain multiple email addresses?
    I have tried passing a list and a string separated by colons (ex: <s>[email protected]; [email protected]</s>) and neither one works.
    Question 2
    Is it a bad idea to try and send email to up to 50000 users at once using IDM? Besides the fact that I would need to search for specific users and get their email addresses based on their capabilities.

    Hi,
    For sending emails to multiple users, use to instead of toUser. Put the names in comma seperated values
    <Action id='0' application='com.waveset.provision.WorkflowServices'>
    <Argument name='op' value='notify'/>
    <Argument name='template' value='$(template)'/>
    <Argument name='to' value='$(to)'/>
    <Argument name='cc' value='$(cc)'/>
    <Argument name='catch' value='notificationException'/>
    </Action>
    You can use IDM to send emails.
    it will be a good idea to break down the email that you are sending into groups/batches. If possible, you can send email to DL s
    Else, you can segregate the users based on roles and send emails. This will reduce the load. Hope it helps
    Regards
    Arjun
    Edited by: arjun.sengupta on Dec 4, 2012 3:26 AM

  • Why I can't send emails to some address and also i...

    Hello!
    Why I can't send  email using my ovi mail account to some email address and also i can't send email using Thunderbird? So what is the problem?
    I can't send email to any address using Mozilla Thunderbird. Every time show "Login to server mail.ovi.com failed." but Thunderbird download my ovi account email without any problem. how do i fix this error. I don't know where to post this matter!

    Yahoo has messed with their stuff lately (honestly they've been messing with their servers for months)
    One thing would be if you guys wanted to use the yahoo mail app, or there have been other users posting solutions that they say work for them
    https://discussions.apple.com/message/27906475?ac_cid=tw123456#27906475
    https://discussions.apple.com/message/27894621?ac_cid=tw123456#27894621
    These have applied to people not able to get mail but changing the settings may help you and your wife. (My yahoo is still working so I haven't needed to try any of these)
    I've noticed with my Yahoo that they've changed their login protocols. For example 'stay signed in' is always clicked and the push is for people to merge multiple accounts to access their multiple yahoo from one account/sign in instead of signing out/in to access different accounts. I'm wondering if that change is what's messing with the protocols needed for iOS mail to work. But no one really knows for sure (and neither Apple or Yahoo will comment on the issue)
    About all users can do is find work arounds that work for them.
    If these don't work or if you don't want to use the yahoo mail app, you might try using safari to go to yahoo.com and access your mail that way.

  • How do I send an email to multiple addresses?

    How do I sed an email to multiple addresses?

    Use the BCC field that is enabled through the View or Edit menu.   This will ensure you don't put everyone on a spammers list, should one of your recipients have a virus that feeds addresses to spammers.

  • Send email to different domain using different address

    hi
    I want to set my exchange recipients have 2 email address.
    1=[email protected] 2=[email protected]
    1.how can I set this setting? (I know I can use something called policy but I don't know how can use that for exchange 2013; please tell me how can do this)
    2.how can set my exchange server to send email to different domain with different account? (after question 1; my recipients has 2 email address (***@domain.com,
    ***@domain.co) I want my recipients when send email to "company.com" using domain.com address and for other domains using domain.co)
    thanks

    1.  Add an accepted domain.  Add the e-mail address to your e-mail address policy.  Update the e-mail address policy.
    2.  http://www.ivasoft.biz/choosefrom2007.shtml  This has been the traditional answer for Exchange 2010 and earlier.  You might contact him to see if it works for Exchange 2013. 
    I don't know of a native way to do this except to create separate mailboxes for each address.
    Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."

  • Reply address: is it possible to use another reply address other than the pop address used in my account. I have a special work account and would like to send emails with that address as my reply address...or sent from address

    Reply address: is it possible to use another reply address other than the pop address used in my account. I have a special work account and would like to send emails with that address as my reply address...or sent from address

    i found out how to do this finally!
    1) set up google gmail account to forward your emails to (from the [email protected])
    2) go to your gmail account
    3) go to settings (cog in right hand corner)
    4) go to 'accounts and import'
    5) go to 'send mail as'
    6) click 'Add another email address you own' - add your [email protected] address
    7) google will send a verification email with code to that email address.
    8) enter code
    9) go back to gmail account  >'send mail as' and select 'make default'
    10) close mac 'mail' program and reopen it.
    as long as you have gmail account selected as the primary account in MAIL - mail will now come throught as being sent from that  [email protected] address!!

  • How to send emails to Multiple Users from a Single People Picker lookup field using Sharepoint designer workflow

    Hi All,
    I am working with SharePoint 2013 designer workflow. we are using office 365.
    Our requirement to send email to multiple users, get the user groups from lookup list people and groups column.
    But SP designer sending emails to the first user alone.
    Please guide me to proceed.
    Advance Thanks.
    Regards
    Jenkins NS
    Thanks and Regards Jenkins

    finally I got a solution
     Identified a workaround to solve the issue using SharePoint designer.
    Step 1
    Create a lookup list Example department
    Columns
    Title (by default) – Single line of text
    Users – Person or Group
    Emails – Multiple lines of text
    hidden the Emails column (go to content type and set the column as hidden)
    Create a SharePoint designer Workflow
    Start Workflow automatically when an item is created
    Also Start Workflow automatically when an item is changed
    Workflow Stage 1
    Set Emails to current Item: Users
    The workflow will get all users email ids and add in the Emails column delimiter as semicolon.
    Step 2
    Create a custom list to get the email ids and send email
    Create a lookup column ex: analysis and refer department list, Allow multiple values
    Then Create a SharePoint designer workflow
    full details workflow steps please follow below
    URL
    http://jenkinsblogs.com/2015/04/30/how-to-send-emails-to-multiple-users-from-lookup-list-people-picker-field-using-sharepoint-designer-workflow/
    Thanks and Regards Jenkins

  • Can't send emails to multiple recipients any more?

    Yesterday I had to send an email to some 30 other people (I only do this occasionally).
    It refused to go and I received this error message:-
    I have several email accounts but each one was the same.
    At that time I could not even send single emails but incoming emails were unaffected.
    Later in the day I received this email from my ISP mail account.
    Your emails may be blocked – please confirm your alternate BT Yahoo! Mail addresses
    Dear Customer,
    You’ve received a ‘553’ error message because we’ve upgraded your BT Yahoo! Mail account security to help protect against ‘spoofing’ – when people use alternate email addresses to disguise the real sender, possibly to commit fraud.
    What you need to do
    We need you to take a few minutes to confirm each of the BT Yahoo! Mail alternate email addresses you use are genuine. If you don’t, you might get more ‘553’ error messages and have problems sending emails. Just log in and follow these simple steps. We don’t ask for any personal information.
    This is rubbish and I had a similar one last year which I ignored, as the simple steps were far from simple, and the following morning all was back to normal.
    So I ignored this email and tried again this morning.
    I was still unable to send emails to multiple recipients but now I can send single emails OK!
    Any ideas what is going on?
    Is it Mail's fault or my ISP's?

    From the error message, it looks like there was a problem with at least one of the addresses ("NONE"). It is possible that a bad address is in the list you tried to send to.
    I don't know anything about BT Internet, so I can't confirm the authenticity of the email you received.
    You should be able to log into your BT account directly from the web without using any links sent in the email.
    The email also seems to indicate you used an alias as the reply-to (from) email address.
    You didn't mask out the username for your smtp server and it is definitely different from the from account. This may all be normal, but it does tend to match what the email is telling you.

  • Question regarding sending email to multiple recipients

    Hi All,
    I am creating a workflow that will send an email notification everytime a new campaign is created. I've learned that R16 is capable of sending emails to multiple recipients, the only concern I have is I can't find any doumentation on how to do it. It is stated in the R16 Administrator Preview Guide that you can select 'Specific Email Address' and enter multiple email addresses directly, I tried to enter multiple email addresses separated by comma - [email protected],[email protected],[email protected] as an example, but it doesn't work and prompts me to enter a valid email address. Could anybody guide me on how to enter multiple email addresses once the 'Specific Email Address' is selected or how to do it in the expression builder to define the expression that will define the list of emails. I know that using group email addresses can be used as an alternative to this requirement but I hope theirs a way to do this with workflows.
    Thanks,
    Wayne

    According to the R16 Admin preview guide;-
    "Send Email to Multiple Recipients
    Expression Builder is now linked to the email address text field that is presented when the Specific Email Address
    option is selected. Workflow administrators can enter multiple email addresses directly, or click the "fx" icon
    beside the field, and use Expression Builder to define expressions that evaluate to one or more email addresses.
    The benefit of this feature is that emails can be stored on any text field in the base record and multiple emails can
    be sent using one workflow action. "
    But how that works exactly is not clear, I have tried commas, semi-colons, spaces, apostrophes, doublequotes, to separate and try to establish the correct syntax without luck.
    Bob - Perhaps you can do some digging and find out the correct syntax for multiple addresses?

  • On OnPremise, Sending email to multiple recipients doesn't work with SendEmail method

    Hi,
    We are creating a site collection on OnPremise from App by using Sharepoint Client API's (16 version).
    After creation of site collection, we are sending an email to all site collection administrators. But we found that email is being sent to the only first person mentioned in the "To" list. For sending email we are using following method "Microsoft.SharePoint.Client.Utilities.Utility.SendEmail()".
    We tried different scenarios by passing alternately domain username and email address.
    Here are the findings for the different scenarios for the "To" field:
    1) "domain\user1; domain\user1" => sends email to first user
    2) "[email protected]; [email protected]" => sends email to both emails (at least shows in inbox To field, two occurances of email)
    3) "domain\user1; domain\user2" => sends email to first user
    4) "[email protected]; [email protected]" => sends email to first user
    Here is the code we are using:
                    EmailProperties properties = new EmailProperties();
                    properties.To = to.ToList();
                    if (cc != null)
                        properties.CC = cc;
                    properties.Subject = subject;
                    properties.Body = body;
                    Utility.SendEmail(context, properties);
                    context.ExecuteQuery();
    Please let us know what is going wrong here.
    Thanks in advance for your valuable inputs.
    Br,
    Shriram
    Shri07

    According to the R16 Admin preview guide;-
    "Send Email to Multiple Recipients
    Expression Builder is now linked to the email address text field that is presented when the Specific Email Address
    option is selected. Workflow administrators can enter multiple email addresses directly, or click the "fx" icon
    beside the field, and use Expression Builder to define expressions that evaluate to one or more email addresses.
    The benefit of this feature is that emails can be stored on any text field in the base record and multiple emails can
    be sent using one workflow action. "
    But how that works exactly is not clear, I have tried commas, semi-colons, spaces, apostrophes, doublequotes, to separate and try to establish the correct syntax without luck.
    Bob - Perhaps you can do some digging and find out the correct syntax for multiple addresses?

  • Error while sending email to Multiple Recipients

    Hi,
    I am trying to send email to multiple recipients .It works fine if all the email-addresses are valid. If even one is invalid throws exception .I wish to send it all the valid addresses even if some are invalid as this email will be going to 3000 users some of them will be wrong addresses.
    Help is greatly appreciated.
    -ksg
    Exception thrown:
    Exception in SendEmail.setAddress as :javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    javax.mail.SendFailedException: 550 <[email protected]>... User unknown
    Here is the main piece of code:
    message.saveChanges();
    Transport transport = session.getTransport("smtp");
    transport.connect("myhost", "", "");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();

    Hi there,
    Well I find the easiest way is to use a comma delimited string with the following bit of code.
    msg.setRecipients(
    addrType,
    InternetAddress.parse(smtpAddress, false));
    addrType will be TO,CC or BCC
    smtpAddress is a comma delimited string that I get from the results of a SQL Select request (looks something like "[email protected],[email protected],....,....,...."
    The boolean false is to prevent the parse checking the validity of the SMTP addresses as I prefer to deal with this by letting the SMTP server tell me which addresses are no good.
    Hope this helps,
    SH

  • How to send mails to multiple recipents using SO_DOCUMENT_SEND_API

    Hi ,
    I am using the FM "SO_DOCUMENT_SEND_API".
    I am able to send an Excel sheet as attachement, but my requirement is to send multiple mails to the corresponding persons. I tried using coma, colan, semi colan as the separator in the import parameter SENDER_ADDRESS for two different mail id's but it was not useful.
    I need to send mails to multiple recipens using the same FM. (keeping one person in to list and two of the persons in CC.)
    can any on throw some light on this. 
    Thanks
    rewards will be great.....................................

    Hi,
    The code below demonstrates how to send an email to an external email address([email protected]),
    where the data is stored within a .xls attachment.
    Instead of the statement, <b>PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.</b>,
      use select-options & give the e-mail addresses that you want.
    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

Maybe you are looking for

  • Can't get notifications to work

    I have tried and tried but can't get mail and messages or twitter to work on notifications, can anyone help? I have already tried the systems preferences and taken everything out and then ticked everything back in again

  • [SOLVED] gcc not recognizing standard c header files

    So my gcc used to work but now I'm getting these strange error messages. For example I wrote the most basic of C programs: int main(){ return 0; And the terminal error message I get is: gcc: error trying to exec '/usr/lib/gcc/x86_64-unknown-linux-gnu

  • Downloaded iTunes but Windows cannot open file

    I am on my shiny new Toshiba notebook and I cannot open the iTunes program I just downloaded. When I try to open and run it I get a Windows message that it needs to know what program created it. How do I open a .pf file? I never had this problem on m

  • "HttpServletRequest" from ContextHandler in JAAS Login Module

    Hi All. I've developed a custom authenticator in WL 9.1. This CA has a custom JAAS Login Module. Inside this module I use weblogic.security.auth.callback.ContextHandlerCallback in order to get javax.http.servlet.HttpServletRequest using the key HttpS

  • PLEASE HELP!!!! Songs not allowed to load on iPod.....

    How do I get iTunes to default back to it's settings?? when I first opened iTunes it said that my audio might not work correctly. So a check box appeared and being totally stupid, I checked all the boxes. Now I can't get back!!!!  I have tried to loa