Sending email from a dynpro?

Hi,
during a course of vocational training I have come across the challenge to send a newsletter, which should be done by clicking a button on a dynpro. I guess it can be done, but have no idea on the how.
I'd appreciate any help on this topic.
Best regards,
Ulrich Waiditschka
<i>Student of business IT</i>

No problem.  Just add a button to the gui status of the dynpro,  in the PAI of your screen,  check for the FCODE that has been assigned to button. 
save_ok = ok_code.
case ok_code.
   when 'EMAIL'.
      clear ok_code.
      perform_send_newsletter.
endcase.
Here is an eample program, for sending an email with embedded HTML.
report zrich_0002.
data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.
start-of-selection.
  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.
  perform build_text_message.
  perform build_receivers.
  perform send_mail_nodialog..
*      Form  BUILD_TEXT_MESSAGE
form build_text_message.
  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.
  mailtxt  = '<html>'.
  append mailtxt.
  mailtxt  = '<head>'.
  append mailtxt.
  mailtxt  = '<title>Untitled Document</title>'.
  append mailtxt.
  mailtxt  = '<meta http-equiv="Content-Type" content="text/html;'.
  append mailtxt.
  mailtxt  = 'charset=iso-8859-1">'.
  append mailtxt.
  mailtxt  = '</head>'.
  append mailtxt.
  mailtxt  = '<body>'.
  append mailtxt.
  mailtxt  = '<div align="center"><em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif">THIS'.
  append mailtxt.
  mailtxt  = '  IS A TEST </font></em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif"></font>'.
  append mailtxt.
  mailtxt  = '</div>'.
  append mailtxt.
  mailtxt  = '</body>'.
  append mailtxt.
  mailtxt  = '</html>'.
  append mailtxt.
endform.
*      Form  BUILD_RECEIVERS
form build_receivers.
*  mailrec-receiver = '[email protected]'.
  mailrec-rec_type  = 'U'.
  append mailrec.
endform.
*      Form  SEND_MAIL_NODIALOG
form send_mail_nodialog.
  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       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.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.
endform.
Welcome to SDN!.
Regards,
Rich Heilman

Similar Messages

  • Sending Email from Web Dynpro

    Hi,
    I'am new in that business and have a simple question:
    What is the easiest way to send emails from a web dynpro application to a specific (e.g. value of an input field in my application).
    The only way I found was the "email - web service tutorial in the pdk).
    Can anyone give me some code to solve this problem.
    Thanx
    christoph

    Hi,
    Sorry ! One sec! I will edit it and do it again !
              InitialContext ctx = new InitialContext();
              Properties props = new Properties();
              props.put("mail.smtp.host","Message server");
              Session sess = Session.getInstance(props);
              //Create new mime message object
              Message message = new MimeMessage(sess);
              message.setFrom(new InternetAddress(wdContext.currentContextElement().getFrom()));
              String recepient = wdContext.currentContextElement().getTo();
              message.setRecipient(Message.RecipientType.TO, new InternetAddress(recepient));
              String subject = wdContext.currentContextElement().getSubject();
              message.setSubject(subject);
              String content = wdContext.currentContextElement().getMessage();
              message.setContent(content,"text/plain");
              //Send the message
              Transport.send(message);
    This should work.. (Some editing error while i was pasting it !)
    Message was edited by: Bharathwaj R

  • Send email from WDA

    Hi,
    I would like to send an email from Web dynpro ABAP.
    How can I proceed to do this ???
    Code samples are most welcome.
    Thx,
    Suba

    Hi RAM,
    If your problem is not solved yet then please use following code for ur reference. Its a running code for which i have used Thomas Jung's blog .
    Its very easy so just understand the code step by step.
    Here i am sending an internal table to a customer .
      DATA: l_text1  TYPE char255. " Text
      DATA: l_lines TYPE i,
            l_size  TYPE  sood-objlen. " Size of Attachment
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      lo_api_controller ?= wd_this->wd_get_api( ).
      lo_message_manager = lo_api_controller->get_message_manager( ).
    * Mail related
      DATA: i_content TYPE   soli_tab, " Mail content
            i_attach  TYPE   soli_tab. " Attachment
      DATA: l_send_request    TYPE REF TO    cl_bcs,  " E-Mail Send Request
            l_document        TYPE REF TO    cl_document_bcs,  " E-Mail Attachment
            l_recipient       TYPE REF TO    if_recipient_bcs, " Distribution List
            l_sender          TYPE REF TO    if_sender_bcs,  " Address of Sender
            l_uname           TYPE           salrtdrcpt,  " Sender Name(SY-UNAME)
            l_bcs_exception   TYPE REF TO    cx_document_bcs, " BCS Exception
            l_addr_exception  TYPE REF TO    cx_address_bcs,  " Address Exception
            l_send_exception  TYPE REF TO    cx_send_req_bcs. " E-Mail sending Exception
    *        l_SO_OBJECT_MIME_GET type ref to SO_OBJECT_MIME_GET.
      DATA: l_recipient_soos  TYPE  soos1.
      DATA: lv_i_with_error_screen TYPE os_boolean.
      DATA: lv_result TYPE os_boolean.
      CONSTANTS: c_tab(1) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,  " Tab Character
                 c_cr(1)  TYPE c VALUE cl_abap_char_utilities=>cr_lf, " Line Feed for End-Of_line
                 c_ext    TYPE soodk-objtp VALUE 'XLS'. " XLS Extension
      DATA p_uname TYPE so_dir_ext .
      p_uname = 'sumit.goenka -avaya.co.in'.
    * Preparing body of the Mail
      MOVE 'Please execute the trade given in the attached excel file' TO l_text1.
      APPEND l_text1 TO i_content.
      MOVE '' TO l_text1.
      APPEND l_text1 TO i_content.
      MOVE '' TO l_text1.
      APPEND l_text1 TO i_content.
      MOVE 'Warm Regards SAP' TO  l_text1.
      APPEND l_text1 TO i_content.
    * Preparing contents of attachment with Change Log
      FIELD-SYMBOLS: <lfs_table> TYPE ANY,    " Internal table structure
                     <lfs_con> TYPE ANY.      " Field Content
      DATA: l_text TYPE char1024.    " Text content for mail attachment
      DATA: l_con(50) TYPE c.        " Field Content in character format
    * Columns to be tab delimeted
      LOOP AT detail ASSIGNING <lfs_table>.
        DO.
          ASSIGN COMPONENT sy-index OF STRUCTURE <lfs_table>
                 TO <lfs_con>.
          IF sy-subrc NE 0.
            CONCATENATE c_cr l_text INTO l_text.
            APPEND l_text TO i_attach.
            EXIT.
          ELSE.
            CLEAR: l_con.
            MOVE <lfs_con> TO l_con.
            CONDENSE l_con.
            IF sy-index = 1.
              CLEAR: l_text.
              MOVE l_con TO l_text.
            ELSE.
              CONCATENATE l_text l_con INTO l_text
                 SEPARATED BY c_tab.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    * Creates persistent send request
      TRY.
          l_send_request = cl_bcs=>create_persistent( ).
    * Creating Document
          l_document = cl_document_bcs=>create_document(
                                        i_type  = 'RAW'
                                        i_text  = i_content[]
                                        i_subject = 'Buy / Sell Order' ).
          DESCRIBE TABLE detail LINES l_lines.
    * Size to multiplied by 2 for UNICODE enabled systems
          l_size = l_lines * 2 * 255.
    * Adding Attachment
          CALL METHOD l_document->add_attachment
            EXPORTING
              i_attachment_type    = c_ext
              i_attachment_size    = l_size
              i_attachment_subject = 'Buy Sell Order Detail'
              i_att_content_text   = i_attach[].
    * Add document to send request
          CALL METHOD l_send_request->set_document( l_document ).
    * Get Sender Object
          l_uname = sy-uname.
          l_sender = cl_sapuser_bcs=>create( l_uname ).
          CALL METHOD l_send_request->set_sender
            EXPORTING
              i_sender = l_sender.
    * E-Mail
          TRANSLATE p_uname TO UPPER CASE.
          l_recipient_soos-recesc = 'U'.
          l_recipient_soos-recextnam = p_uname.
    * Preparing recepient from SAP Logon Name
          CALL METHOD cl_send_request_bcs=>create_recipient_from_soos1
            EXPORTING
              i_soos1 = l_recipient_soos
            RECEIVING
              result  = l_recipient.
    * Add Recipient
          CALL METHOD l_send_request->add_recipient
            EXPORTING
              i_recipient  = l_recipient
              i_express    = 'U'
              i_copy       = ' '
              i_blind_copy = ' '
              i_no_forward = ' '.
    *Trigger E-Mail immediately
          l_send_request->set_send_immediately( 'X' ).
          CALL METHOD l_send_request->send( lv_result ).
          IF lv_result IS INITIAL.
    *       *    report message
            CALL METHOD lo_message_manager->REPORT_SUCCESS
              EXPORTING
                message_text = 'Mail sent successfully '.
          ENDIF.                                                              .
          COMMIT WORK.
        CATCH cx_document_bcs INTO l_bcs_exception.
        CATCH cx_send_req_bcs INTO l_send_exception.
        CATCH cx_address_bcs  INTO l_addr_exception.
      ENDTRY.
    if any doubt please ask.
    regards
    panky

  • 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 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 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.

  • Cannot send email from Iphone. A setting is off.

    What are the correct settings to send email from my aol account that's included in my I Cloud acct. any suggestions???? Thanks Sue

    Read this
    How do I set up AOL Mail on my iPhone or iPod Touch? - AOL Help

  • Cannot send email from outbox

    Why can't i send email from my outbox? Mail is blocked from coming in also.

    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 Exchange 2007 to Exchange 2013 - Coexistence

    Existing Exchange 2007 SP3 1 MBX, 2 CAS/HT, 2 ET servers.
    I have added an Exchange 2013 server with MBX/CAS role.
    Email will flow from Ex2013 server no problem.  Mail from Ex2007 systems cannot deliver to Ex2013 boxes, it dies in queue with a 4.4.7 expired message after issuing a delay message.
    I can telnet to ports 25, 587,717,465,475, and 2525 from Ex2007 HT role to new Exchange 2013 server.  I can send email from Ex2007 HT role server to new Exchange 2013 server using telnet to port 25.
    A ‘get-mailbox’ from the Ex2007 HT role server returns the server and database properly on the test users on Exchange 2013 server.
    The only strange thing I am seeing is from the Ex2007 systems, a ‘get-exchange server’ command shows the new Ex2013 server as role ‘16439’ which looks to perhaps be normal.
    Why is email not flowing to the new users on Exchange 2013?

    You should have exchange server authentication ticked in Default Receive connector in Exchange2007.
    Exchange 2007 and Exchange 2013 in the same subnet/network. if not please check any spam agent running between the networks. Are you running antispam on Exchange2013 ?
    MAS

  • Cannot Send Email from SAP Business One

    Hi Experts
    I have configured SAP Email Services from the Mailer Service and Customer can send emails all the while,
    Now I have an Issue for One User,
    Iam using the Same Machine, Same Database with Manager Login, I can send Email from SAP with Attachments
    But When I use another Super user the system is not delivering the Email and it Goes to the Sent box (but not delivered)
    Have anyone encountered the Issue before
    Please hep to solve this issue permanently
    Thanks and Regards
    Vinodh Kumar Mohan

    Hi Vinodh Kumar Mohan,
    If the email can be found in Sent box, it must be delivered already.
    The problem could be on the email recipient side. It may go to the junk mail.
    Thanks,
    Gordon

Maybe you are looking for

  • Can't get Content Aware Extend to work

    Read all the tutorials but when I make a selection and select content aware extend it just moves the selection without extending it.  Need to find some way get it to actually extend? After making a selection, the "move" and "extend" options appear to

  • Logitech 550 remote is affecting iTunes when using apple tv

    How do I stop my Logitech 550 remote from working iTnes when Im using my Apple TV?

  • Unable to start IFS Servermanager (ocijdbc8)

    Can anyone help with this? I'm trying to get IFS 1.0 up and running on Oracle Enterprise Edition 8.1.6 on Windows 2000 server. The oracle database is pretty much a clean install and was installed using the 'typical' option. IFS installs ok, creates t

  • Wiki haven't how to login to lxde with kdm.

    I have installed lxdm, but can't find to login to lxdm with kdm in Wiki. I search in google and find this solution. https://bbs.archlinux.org/viewtopic.php?id=72595 Xabre wrote: There allready has been theme about this.. Just copy /usr/share/xsession

  • Flicker when updating jTable

    I have an application using a jTable. When updating this jTable with a new row there is some annoing flicker - especially if i have many rows in my table. Seems like when swing is repainting i have the last marked line twice in the table, both on top