Problem Sending mails in a loop using JavaMail API

Hello All,
I am sending emails in a loop(one after the other) using JavaMail API,but the problem is, if the first two,three email addresses in the loop are Valid it sends the Email Properly, but if the Fourth or so is Invalid Address it throws an Exception....
"javax.mail.SendFailedException: Sending failed;"
nested exception is:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
javax.mail.SendFailedException: 450 <[email protected]>:Recipient address rejected: Domain not found......
So if i want to send hundereds of emails and if one of the Emails inbetween is Invalid the process Stops at that point and i could not send the other emails in the Loop......
How Could i Trap the exception thrown and handle it in such a way, so that the loops continues ..
Is there something with the SMTP Server....?
The code which i am using is as follows....
<Code>...
try {
InitialContext ic = new InitialContext();
Session session = (Session) ic.lookup(JNDINames.MAIL_SESSION);
if (Debug.debuggingOn)
session.setDebug(true);
// construct the message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(eMess.getEmailSender()));
String to = "";
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
msg.setRecipients(Message.RecipientType.BCC,
InternetAddress.parse(eMess.getEmailReceiver(), false));
msg.setSubject(eMess.getSubject());
msg.setContent(eMess.getHtmlContents(),"text/plain");
msg.saveChanges();                
Transport.send(msg);
} catch (Exception e) {
Debug.print("createAndSendMail exception : " + e);
throw new MailerAppException("Failure while sending mail");
</Code>....
Please give me any suggestions regarding it....and guide me accordingly..
Thanks a million in advance...
Regards
Sam

How about something like the code attached here. Be aware it is lifted and edited out of an app we have here so it may require changing to get it to work. If it don't work - don't come asking for help as this is only a rough example of one way of doing it. RTFM - that's how we worked it out!
SH
try {
Transport.send(msg);
// If we get to here then the mail went OK so update all the records in the email as sent
System.out.println("Email sent OK");
catch (MessagingException mex) {
System.out.println("Message error");
Exception ex = mex;
do {
if (ex instanceof SendFailedException) {
if (ex.getMessage().startsWith("Sending failed")) {
// Ignore this message as we want to know the real reason for failure
// If we get an Invalid Address error or a Message partially delivered message process the message
if (ex.getMessage().startsWith("Message partially delivered")
|| ex.getMessage().startsWith("Invalid Addresses")) {
// This message is of interest as we need to process the actual individual addresses
System.out.println(ex.getMessage().substring(0, ex.getMessage().indexOf(";")));
// Now get the addresses from the SendFailedException
SendFailedException sfex = (SendFailedException) ex;
Address[] invalid = sfex.getInvalidAddresses();
if (invalid != null) {
System.out.println("Invalid Addresse(s) found -");
if (invalid.length > 0) {
for (int x = 0; x < invalid.length; x++) {
System.out.println(invalid[x].toString().trim());
Address[] validUnsent = sfex.getValidUnsentAddresses();
if (validUnsent != null) {
System.out.println("Valid Unsent Addresses found -");
if (validUnsent.length > 0) {
for (int x = 0; x < validUnsent.length; x++) {
System.out.println(validUnsent[x].toString().trim());
Address[] validSent = sfex.getValidSentAddresses();
if (validSent != null) {
System.out.println("Valid Sent Addresses found -");
if (validSent.length > 0) {
for (int x = 0; x < validSent.length; x++) {
System.out.println(validSent[x].toString().trim());
if (ex instanceof MessagingException)
ex = ((MessagingException) ex).getNextException();
else {
// This is a general catch all and we should assume that no messages went and should stop
System.out.println(ex.toString());
throw ex;
} while (ex != null);

Similar Messages

  • Problems sending mail with txt attachtment using SO_DOCUMENT_SEND_API1 MF

    Hi gurus,
    I allready tried to search in the forum some threads related with my problem, but i couldnt found any with the same problem that im having.
    My problem it's when attachting an txt file, using MF SO_DOCUMENT_SEND_API1 MF, the mail attachtment it's coming with the txt file but instead of coming with the all lines in the contents_bins table the file it's coming with a few lines. I think the problem it's that the txt file should come with 80 characters per line, like it's on the contents_bin table, buu instead that the MF it's filling me each line of the file with 1024 characters.
    Does anyone has ideas what im doing wrong?
    Ps - Below goes my code.
    Thanks in Advance,
    Best Regards,
    João Martins.
      CLEAR contents_bin.
      REFRESH contents_bin.
      PERFORM get_attachment TABLES tab_movimentos contents_bin
                             USING linha_inicial
                             linha_final.
      CLEAR: document_data, tab_lines.
      MOVE 'Aviso Ficheiro Retorno' TO document_data-obj_descr.
      MOVE 'Aviso Ficheiro de Retorno TU' TO document_data-obj_name.
      DESCRIBE TABLE contents_txt LINES tab_lines.
      READ TABLE contents_txt INDEX tab_lines.
      document_data-doc_size = ( tab_lines - 1 ) * 255
                               + STRLEN( contents_txt ).
      CLEAR packing_list.
      REFRESH packing_list.
      packing_list-transf_bin = space.
      packing_list-head_start = 1.
      packing_list-head_num = 0.
      packing_list-body_start = 1.
      DESCRIBE TABLE contents_txt LINES packing_list-body_num.
      packing_list-doc_type = 'RAW'.
      APPEND packing_list.
      packing_list-transf_bin = 'X'.
      packing_list-head_start = 1.
      packing_list-head_num   = 1.
      ADD 1 TO tab_lines.
      packing_list-body_start = tab_lines.
      CLEAR: lv_filename, tab_lines.
      CONCATENATE 'Fich Retorno -' nome_ficheiro INTO lv_filename.
      DESCRIBE TABLE contents_bin LINES tab_lines.
      packing_list-doc_type   =  'TXT'.
      packing_list-obj_descr  =  'Ficheiro Retorno'.
      packing_list-obj_name   =  lv_filename.
      packing_list-doc_size   =  tab_lines * 255.
      APPEND packing_list.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = document_data
                put_in_outbox              = 'X'
                sender_address             = 'SIFJOB'
                sender_address_type        = 'B'
           IMPORTING
                sent_to_all                = sent_to_all
           TABLES
                packing_list               = packing_list
                contents_bin               = contents_bin
                contents_txt               = contents_txt
                receivers                  = tab_receiver
           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.
      SUBMIT rsconn01 WITH mode = 'INT'
                  WITH output = SPACE
                  AND RETURN.
    FORM get_attachment TABLES   p_tab_movimentos STRUCTURE
                                 zlinha_movimentos_fich_retorno
                                 p_contents_bin STRUCTURE contents_bin
                        USING    p_linha_inicial STRUCTURE
                                 zlinha_inicial_ps2
                                 p_linha_final STRUCTURE
                                 zlinha_final_ps2.
      DATA: lv_valor(14).
      DATA : line(80) TYPE x.
      CONCATENATE p_linha_inicial-referencia p_linha_inicial-tipo_registo
      p_linha_inicial-tipo_operacao p_linha_inicial-situacao_conta
      p_linha_inicial-situacao_registo p_linha_inicial-iban+4(21)
      p_linha_inicial-moeda p_linha_inicial-data_pag
      p_linha_inicial-ref_ordenante p_linha_inicial-filler
      INTO p_contents_bin-line.
      CLEAR line.
      conv_bin p_contents_bin-line line.
      MOVE line TO p_contents_bin-line.
      APPEND p_contents_bin.
      CLEAR p_contents_bin.
      LOOP AT p_tab_movimentos.
        CLEAR: lv_valor.
        WRITE p_tab_movimentos-montante TO lv_valor.
        PERFORM normalize_value USING lv_valor.
        CONCATENATE p_tab_movimentos-referencia
          p_tab_movimentos-tipo_registo p_tab_movimentos-tipo_operacao
          p_tab_movimentos-sit_conta_retor p_tab_movimentos-situacao_registo
          p_tab_movimentos-nib lv_valor
          p_tab_movimentos-ref_ordenante p_tab_movimentos-filler
          INTO p_contents_bin-line.
        CLEAR line.
        conv_bin p_contents_bin-line line.
        MOVE line TO p_contents_bin-line.
        APPEND p_contents_bin.
        CLEAR p_contents_bin.
      ENDLOOP.
      CLEAR: lv_valor.
      WRITE p_linha_final-mont_total TO lv_valor.
      PERFORM normalize_value USING lv_valor.
      CONCATENATE p_linha_final-referencia p_linha_final-tipo_registo
        p_linha_final-tipo_operacao p_linha_final-filler_1
        p_linha_final-situacao_registo p_linha_final-filler_2
        p_linha_final-total_reg lv_valor
        p_linha_final-filler INTO p_contents_bin-line.
      CLEAR line.
      conv_bin p_contents_bin-line line.
      MOVE line TO p_contents_bin-line.
      APPEND p_contents_bin.
      CLEAR p_contents_bin.
    ENDFORM.                    " get_attachment

    Hi,
    I've solved this problem. The problem was because i was using the
    * Anexo - Descrição
      packing_list-transf_bin = 'X'.
      packing_list-head_start = 1. "Here it must be 0 because i wasn't using any table header
      packing_list-head_num   = 0.
      ADD 1 TO tab_lines.
      packing_list-body_start = 1.
      CLEAR: lv_filename, tab_lines.
      CONCATENATE nome_ficheiro 'TB' INTO lv_filename.
    *  CONCATENATE 'Fich Retorno -' nome_ficheiro INTO lv_filename.
      DESCRIBE TABLE contents_bin LINES tab_lines.
      packing_list-doc_type   =  'TXT'.
      packing_list-obj_descr  =  lv_filename."'Ficheiro Retorno'.
      packing_list-obj_name   =  lv_filename.
      packing_list-body_num = tab_lines.
      packing_list-doc_size   =  tab_lines * 255.
      APPEND packing_list.
    Best Regards
    Thanks,
    João Martins

  • Problem sending Mail

    I am having problem sending mail in Outlook (not using express). I receive mail no problem at all and I don't want to change account to IMAP to send mail. So what are my options to make this work using Outllok?

    Who is your internet service provider used for connecting to the internet?
    Are you also accessing an email account and SMTP server provided by your ISP and if so, can you send messages with this account?
    Does GoDaddy provide/support an authenticated SMTP server?
    Which server port are you using for this SMTP server - 25, 587 or something else?

  • Getting exceptions while sending mail using javamail api

    Hi to all
    I am developing an application of sending a mail using JavaMail api. My program is below:
    quote:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    public class sms
    public static void main(String args[])
    try
    String strstrsmtserver="smtp.bol.net.in";
    String strto="[email protected]";
    String strfrom="[email protected]";
    String strsubject="Hello";
    String bodytext="This is my first java mail program";
    sms s=new sms();
    s.send(strstrsmtserver,strto,strfrom,strsubject,bodytext);
    catch(Exception e)
    System.out.println("usage:java sms"+"strstrsmtpserver tosddress fromaddress subjecttext bodyText");
    System.exit(0);
    public void send(String strsmtpserver,String strto,String strfrom ,String strsubject,String bodytext)
    try
    java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties p=new Properties(System.getProperties());
    if(strsmtpserver!=null)
    p.put("mail.transport.protocol","smtp");
    p.put("mail.smtp.host","[email protected]");
    p.put("mail.smtp.port","25");
    Session session=Session.getDefaultInstance(p);
    Message msg=new MimeMessage(session);
    Transport trans = session.getTransport("smtp");
    trans.connect("smtp.bol.net.in","[email protected]","1234563757");
    msg.setFrom(new InternetAddress(strfrom));
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(strto,false));
    msg.setSubject(strsubject);
    msg.setText(bodytext);
    msg.setHeader("X-Mailer","mtnlmail");
    msg.setSentDate(new Date());
    Transport.send(msg);
    System.out.println("Message sent OK.");
    catch(Exception ex)
    System.out.println("here is error");
    ex.printStackTrace();
    It compiles fine but showing exceptions at run time.Please help me to remove these exceptions.I am new to this JavaMail and it is my first program of javamail.Please also tell me how to use smtp server.I am using MTNL 's internet connection having smtp.bol.net.in server.
    exceptions are:
    Here is exception
    quote:
    Javax.mail.MessagingException:Could not connect to SMTP host : smtp.bol.net.in, port :25;
    Nested exception is :
    Java.net.ConnectException:Connection refused: connect
    At com.sun.mail.smtp.SMTPTransport.openServer<SMTPTransport.java:1227>
    At com.sun.mail.smtp.SMTPTransport.protocolConnect<SMTPTransport.java:322>
    At javax.mail.Service .connect(Service.java:236>
    At javax.mail.Service.connect<Service.java:137>
    At sms.send<sms.java:77>
    At sms.main<sms.java:24>

    Did you find the JavaMail FAQ?
    You should talk to your ISP to get the details for connecting to your server.
    In this case I suspect your server wants you to make the connection on the
    secure port. The FAQ has examples of how to do this for GMail and Yahoo
    mail, which work similarly. By changing the host name, these same examples
    will likely work for you.

  • TS3276 Anyone experiencing problems sending mail using TalkTalk - can receive but not send  - was ok up until pm 24/08/12 - have recently loaded Mountain Lion patch could this be the problem?

    Anyone experiencing problems sending mail using Apple Mail viaTalkTalk - can receive but not send  - was ok up until pm 24/08/12 - have recently loaded Mountain Lion patch could this be the problem?

    jag157 wrote:
    "I managed to solve the problem. Under smtp settings (mail preferences/accounts/edit smtp) I set the outgoing port to 25 (as recommended by Talktalk), no authentication (set to none) and unchecked SSL. I found that until I set the port to 25 and authentication to none I was unable to uncheck SSL. One I had done this I was able to send from my main email and other email adddresses set up under my account."
    Superb advice R&W!  My email sending block using TalkTalk started 2 months ago using Snow Leopard, continued when I upgraded to 10.8.2, and has been persistent on my wife's new iPad (IOS 6.1).  Implementing your wise words has fixed all that, and now enables me to call her on FaceTime — previously only she could call me.  Thank you so much; this will save hours of further fruitless searching and phoning.
    Please remember that your email is now insecure, if you wish to have a secure connection SSL must be on and port 25 should be avoided.

  • I have a problem sending mail via smtp. I use a satellite system and the average return time for a ping is 675ms. Is this a problem with mail? If so can I change Mail to accept it. The problem also exists with Lion

    I have a problem sending mail via smtp. I use a satellite system and the average return time for a ping is 675ms. Is this a problem with mail? If so can I change Mail to accept it. The problem also exists with Lion and on both my MacPro and my wife's Imac. I also see my mailboxes randomly disconnecting and reconnecting. Any other ideas of a possible cause?

    I solved it myself, after the "note" which came back from FF/Mozilla just as I finished my message, commenting on what it was that my system had , I wnnt back to check my plug-ins etc. I downloaded the latest Java, BOTH 32bit AND 64 bit versions and latest Firefox.
    Now all is working.
    Thanks,
    B.

  • Problems sending mail to multiple receivers

    Hi everyone.
    I'm trying to send a mail with 'send mail'. In addresstring, i must put the user concatenated with string US. Type os user is 'B'.
    My problem is that i have to send the email to some users. This users are stored in a Z table. With a parameter, i must get the list of users.
    I've made a task in order to get the users and store them in a container. Then, i will make the binding between this container and the addressstring.
    This is only my idea, but don't know how to develop it.
    In other place, i've developed a FM that is used to determine the users to receive a task. In this case, i don't understant how the ACTOR_TAB works, because is not a container.
    Can anybody explain a simple way to do this?
    Sorry but i'm new with workflow.
    Regards,
    Inigo.

    Hi Inigo,
    I suggest you have an export parameter in your method , which would be a table type of string. Determine all the users to whom the mail has to be sent to in the method, and place the user names in this export parameter,also ensure that you have added US as the suffix to the usernames.
    then in the workflow use the send mail step in loop to send the mail to all the users. in the send mail step the address to which the mail has to be send can be derived from the expression ContainerElement<i>.
    Where ContainerElement would have all the user names and you need to increase the value of i.
    I hope the message has been conveyed properly and you find some relevance to the requirement you had asked for.....
    Please revert in case this is not what you were searching for.....
    Thank and Regards,
    Narsingh.
    Edited by: Narsingh Panigrahi on Feb 8, 2008 6:54 AM

  • 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

  • Problem sending mail over GPRS/EDGE

    problem sending mail over GPRS/EDGE
    i am in thailand right now with my iPhone 3G 16 GB (italian, no SIM-lock, 2.2). my problem: the iPhone does not send emails via GPRS/EDGE of local AIS mobile provider (there is no 3G in thailand right now). each time i try, i will get a prompt saying 'cannot send mail, the connection to the outgoing server "mail.gmx.net" failed'.
    in germany, i use a contract SIM from o2, in thailand a prepaid SIM from AIS. i have configured 2 german pop mail accounts on my phone (gmx.de, o2online.de). receiving and sending email work fine on WLAN (everywhere, also here in thailand) and in germany on 3G/EDGE/GPRS. internet works everywhere, too. so, configuration seems to be okay. for each account, i use the same (smtp) sending server for all networks (ie i do not change configurations, using mail.gmx.net and pop.o2online.de). for a test, i changed smtp server to the AIS proprietary server mail.cscoms.com, but no change in behaviour.
    so, any ideas how i can get my iPhone to not only receive but also send emails via GPRS of AIS?
    thank you!

    ok. i found the solution.
    The problem is not in the iphone, the problem was DNS resolution in the server side.

  • How to send mail in  HTML  format using SMTP

    I want to send mail in HTML format using SMTP.Can anybody please suggest how to do it.Can anybody send me the code.
    Thnx.

    If you don't know how to send a message using JavaMail see here : http://developer.java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailSending
    To send a html format mail you need to set the content type like this (msg is a javax.mail.internet.MimeMessage) :
    String subject = "An Email 4 U";
    String message = "<HTML><BODY>Here is a link<br><a href='http://javasoft.com'>Java</a></BODY></HTML>";
    msg.setSubject(subject);
    msg.setContent(message, "text/html");p.s This isn't really an advanced topic

  • Outgoing server port configuring not in Mail 3.5 - problems sending mail?

    I recently upgraded from Tiger to Leopard and one of the things I noticed is that in Mail 3.5 undere Mail>Preferences>Accounts under the Account Information tab, there is no longer the ability to select or change ports for the Outgoing Server.
    In Mail 2.x, there was an Advanced button that would let you choose a different port and select SSL (or not). In Mail 3.5, this feature is missing. Does anyone know if the outgoing server port can be changed? The reason I ask is that when I travel, my ISP will not accept any of my outgoing mail because I'm not using my home IP address (especially with .mac). This is usually remedied by changing to a different, less common port for the outgoing server. If I'm unable to change outgoing server ports in Mail 3.5, is this going to cause problems sending mail when I'm on the road? Any help would be appreciated. Thanks.
    Ed

    If you pull down the bar in the outgoing mail server, you should be able to select "edit server list" and the window shows up where you can set up port.

  • Problems Sending Mail -- ISP or Mac Mail?

    Typically, I need to send nearly every message at least twice -- once initially and however many times after that from the outbox until it finally goes. At times, I'll have mail stuck in my outbox for hours, if not days and often have to use webmail to send messages in a pinch (thus losing all the benefits of Mail).
    I contacted my ISP and spoke to a technician who was very helpful and attentive. I sent him screengrabs of all of my settings and he confirmed they are set correctly. However, he dismissed my belief that this is related to the ISP and said that it is probably something to do with my Mac Mail client, or my home network configuration. He suggested I switch to Entourage or another mail client, which I don't want to do.
    Either way, I'm skeptical about his response because prior to using this ISP I never had the problem with Yahoo using more or less the same configuration. (Both require authentication, POP3, etc.) Yahoo always accepted outgoing messages on the first try.
    Has anyone else seen this problem and can they share advice on what they did to fix it, or is the ISP blowing smoke up my skirt?

    I am also having problems sending mail. This has occurred for the past 6 weeks or so. Typically, I receive the drop down message about my ISP server: "Cannot send message using the server smtp.telus.net.....". I click the "try again later" button, open the Outgoing Mail box on Mail, click on the unsent email and it usually makes it out. This has become an annoying 4-step mail process.
    I contacted my ISP and they did their little tests and said that it all of my settings are fine (I wasn't surprised; I haven't changed anything) and said that I should contact my Mail client, Apple.
    I encounter the same problem regardless of who or how I send the mail...if I send to an address on the same ISP server, to mac.com, to yahoo, to private website accounts, etc. I've tried sending through mac.com, through my website account, etc. Nothing changes.
    From the many posts about this problem, it seems to be widespread.
    And sometimes, just sometimes, Mail sends my mail just like it did in the "good old" days, on the first click or keyboard shortcut.
    Has anyone found a workable solution to this annoying problem?
    I miss my Comm/Shift/D

  • Problem sending mail to one domain

    System: Netware 6.5.8 with all current patches.
    We are having a problem sending mail to one particular domain (neigerllp.com). When a message is sent our GW GWIA returns a "553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)" error message. We receive that error because our mail server is looking at their secondary mx instead of their primary mx. If I unload named then our mail server looks for the secondary external DNS server and mail is sent without error to this domain. When named is not loaded it sends to the correct mx server listed. If I reload named it will work for a while but then default to the incorrect mail server. It also works for a while when I load named -pa, but eventually reverts back to the incorrect server. Could someone help me resolve this issue?
    Thanks,
    bp

    On 23.03.2011 20:06, BPainter wrote:
    >
    > System: Netware 6.5.8 with all current patches.
    >
    > We are having a problem sending mail to one particular domain
    > (neigerllp.com). When a message is sent our GW GWIA returns a "553
    > sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)" error
    > message. We receive that error because our mail server is looking at
    > their secondary mx instead of their primary mx. If I unload named then
    > our mail server looks for the secondary external DNS server and mail is
    > sent without error to this domain. When named is not loaded it sends to
    > the correct mx server listed. If I reload named it will work for a
    > while but then default to the incorrect mail server. It also works for
    > a while when I load named -pa, but eventually reverts back to the
    > incorrect server. Could someone help me resolve this issue?
    Not here. It's a known GWIA bug. It doesn't look at the preference in
    the MX record, but merely uses them i nthe order they come in. Your DNS
    making a difference is a red herring.
    Check if your GWIA is up to date. If it is, you will have to open a SR
    with Novell.
    CU,
    Massimo Rosen
    Novell Product Support Forum Sysop
    No emails please!
    http://www.cfc-it.de

  • Has anyone an Intermittent Problem sending mail from Mac OS X (10.6.8)?

    I have a Mac mini operating on Mac OS X(10.6.8) Snow Leopard. In the last couple of weeks I have been having intermittent problems sending mail from Mac MAIL, especially if I hit the reply button.  It whirls around for ever and then tells me to 'Try Later' or 'Try Again'.  When I shut down my computer and open up mail again, I hear the mail whizzing off.  I have just tried it now and it went in the time that it has taken me to compose this email. But sometimes the mail doesn't go at all. Could it me because I have too many messages in my inbox and sent boxes (around 1000 in each)?  I read somewhere that you should delete Mail in library/pref/com.apple.mail.plst and reinstal it.  But I'm frightened to do this in case I can't re-instal it as I don't know how to.

    I have a Mac mini operating on Mac OS X(10.6.8) Snow Leopard. In the last couple of weeks I have been having intermittent problems sending mail from Mac MAIL, especially if I hit the reply button.  It whirls around for ever and then tells me to 'Try Later' or 'Try Again'.  When I shut down my computer and open up mail again, I hear the mail whizzing off.  I have just tried it now and it went in the time that it has taken me to compose this email. But sometimes the mail doesn't go at all. Could it me because I have too many messages in my inbox and sent boxes (around 1000 in each)?  I read somewhere that you should delete Mail in library/pref/com.apple.mail.plst and reinstal it.  But I'm frightened to do this in case I can't re-instal it as I don't know how to.

  • Problem sending mail from iPhone

    Hello
    I have a problem sending mails from a Horde account in iPhone 5S. I guess the problem is about configuring the outgoing mail server, but I tried several things and nothing seams to work. The message I get is :
    "Can't send mail. No password provided for account x
    Please go to Mail account settings and enter a password"
    Here goes the detailed configuration of the SMTP:
    SMTP server: mail.account.pt
    User name and Password: xxxxxx
    SSL: OFF
    Authentication: Password
    Server port:587
    What am I doing wrong?
    Thank you for your help!
    Best regards,
    Pedro

    After talking with my e-mail service provider I understood some more configurations, which might help you to help me:
    SMTP Settings:
    Authentication method: encrypted password
    Connection Security: STARTTLS
    How can I copy these settings into my iPhone 5S? In Authetication there's only the following options:
    Password, MD5 challenge-response, HTTP MD5 Digest and NTLM...
    Thank you!
    Best regards,
    Pedro Santos

Maybe you are looking for