How we can send Emails to others by useing ABAP code

solve this

hi ,
check this this may be help ful for you.
Email ITAB structure
DATA: BEGIN OF EMAIL_ITAB OCCURS 10.
        INCLUDE STRUCTURE SOLI.
DATA: END OF EMAIL_ITAB.
DATA: T_EMAIL LIKE SOOS1-RECEXTNAM.  "EMail distribution list
CONSTANTS: C_EMAIL_DISTRIBUTION LIKE SOOS1-RECEXTNAM VALUE
           ‘[email protected],[email protected]’.
Initialization
REFRESH EMAIL_ITAB.
Populate data
EMAIL_ITAB-LINE = ‘Email body text 1’.
APPEND EMAIL_ITAB.
EMAIL_ITAB-LINE = ‘Email body text 2’.
APPEND EMAIL_ITAB.
T_EMAIL = C_EMAIL_DISTRIBUTION.
--- EMAIL FUNCTION ---------------------------------------------------
REQUIRMENTS:
1) The user running the program needs a valid email address in their
   address portion of tx SU01 under external comms -> SMTP -> internet
   address.
2) A job called SAP_EMAIL is running with the following parameters:
   Program: RSCONN01  Variant: INT   User: XXX
   This program moves mail from the outbox to the mail server using
   RFC destination: SAP_INTERNET_GATEWAY_SERVER
INTERFACE:
1) APPLICATION: Anything
2) EMAILTITLE:  EMail subject
3) RECEXTNAM:   EMail distribution lists separated by commas
4) TEXTTAB:     Internal table for lines of the email message
EXCEPTIONS:
Send OK = 0 otherwise there was a problem with the send.
    CALL FUNCTION 'Z_SEND_EMAIL_ITAB'
         EXPORTING
              APPLICATION = 'EMAIL'
              EMAILTITLE  = 'Email Subject'
              RECEXTNAM   = T_EMAIL
         TABLES
              TEXTTAB     = EMAIL_ITAB
         EXCEPTIONS
              OTHERS      = 1.
Function Z_SEND_EMAIL_ITAB
""Local interface:
*"       IMPORTING
*"             VALUE(APPLICATION) LIKE  SOOD1-OBJNAM
*"             VALUE(EMAILTITLE) LIKE  SOOD1-OBJDES
*"             VALUE(RECEXTNAM) LIKE  SOOS1-RECEXTNAM
*"       TABLES
*"              TEXTTAB STRUCTURE  SOLI
*- local data declaration
  DATA: OHD    LIKE SOOD1,
        OID    LIKE SOODK,
        TO_ALL LIKE SONV-FLAG,
        OKEY   LIKE SWOTOBJID-OBJKEY.
  DATA: BEGIN OF RECEIVERS OCCURS 0.
          INCLUDE STRUCTURE SOOS1.
  DATA: END OF RECEIVERS.
*- fill odh
  CLEAR OHD.
  OHD-OBJLA    = SY-LANGU.
  OHD-OBJNAM   = APPLICATION.
  OHD-OBJDES   = EMAILTITLE.
  OHD-OBJPRI   = 3.
  OHD-OBJSNS   = 'F'.
  OHD-OWNNAM   = SY-UNAME.
*- send Email
  CONDENSE RECEXTNAM NO-GAPS.
  CHECK RECEXTNAM <> SPACE AND RECEXTNAM CS '@'.
*- for every individual recipient send an Email
(see OSS message 0120050409/0000362105/1999)
  WHILE RECEXTNAM CS ','.
    PERFORM INIT_REC TABLES RECEIVERS.
    READ TABLE RECEIVERS INDEX 1.
    RECEIVERS-RECEXTNAM = RECEXTNAM+0(SY-FDPOS).
    ADD 1 TO SY-FDPOS.
    SHIFT RECEXTNAM LEFT BY SY-FDPOS PLACES.
    MODIFY RECEIVERS INDEX 1.
    PERFORM SO_OBJECT_SEND_REC
     TABLES TEXTTAB RECEIVERS
      USING OHD.
  ENDWHILE.
*- check last recipient in recipient list
  IF RECEXTNAM <> SPACE.
    PERFORM INIT_REC TABLES RECEIVERS.
    READ TABLE RECEIVERS INDEX 1.
    RECEIVERS-RECEXTNAM = RECEXTNAM.
    MODIFY RECEIVERS INDEX 1.
    PERFORM SO_OBJECT_SEND_REC
     TABLES TEXTTAB RECEIVERS
      USING OHD.
  ENDIF.
ENDFUNCTION.
      FORM SO_OBJECT_SEND_REC                                       *
FORM  SO_OBJECT_SEND_REC
TABLES  OBJCONT      STRUCTURE SOLI
        RECEIVERS    STRUCTURE SOOS1
USING   OBJECT_HD    STRUCTURE SOOD1.
  DATA:   OID     LIKE SOODK,
          TO_ALL  LIKE SONV-FLAG,
          OKEY    LIKE SWOTOBJID-OBJKEY.
  CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
            EXTERN_ADDRESS             = 'X'
            OBJECT_HD_CHANGE           = OBJECT_HD
            OBJECT_TYPE                = 'RAW'
            OUTBOX_FLAG                = 'X'
            SENDER                     = SY-UNAME
       IMPORTING
            OBJECT_ID_NEW              = OID
            SENT_TO_ALL                = TO_ALL
            OFFICE_OBJECT_KEY          = OKEY
       TABLES
            OBJCONT                    = OBJCONT
            RECEIVERS                  = RECEIVERS
       EXCEPTIONS
            ACTIVE_USER_NOT_EXIST      = 1
            COMMUNICATION_FAILURE      = 2
            COMPONENT_NOT_AVAILABLE    = 3
            FOLDER_NOT_EXIST           = 4
            FOLDER_NO_AUTHORIZATION    = 5
            FORWARDER_NOT_EXIST        = 6
            NOTE_NOT_EXIST             = 7
            OBJECT_NOT_EXIST           = 8
            OBJECT_NOT_SENT            = 9
            OBJECT_NO_AUTHORIZATION    = 10
            OBJECT_TYPE_NOT_EXIST      = 11
            OPERATION_NO_AUTHORIZATION = 12
            OWNER_NOT_EXIST            = 13
            PARAMETER_ERROR            = 14
            SUBSTITUTE_NOT_ACTIVE      = 15
            SUBSTITUTE_NOT_DEFINED     = 16
            SYSTEM_FAILURE             = 17
            TOO_MUCH_RECEIVERS         = 18
            USER_NOT_EXIST             = 19
            X_ERROR                    = 20
            OTHERS                     = 21.
  IF SY-SUBRC <> 0.
    RAISE OTHERS.
  ENDIF.
ENDFORM.
      FORM INIT_REC                                                 *
FORM INIT_REC TABLES RECEIVERS STRUCTURE SOOS1.
  CLEAR RECEIVERS.
  REFRESH RECEIVERS.
  MOVE SY-DATUM  TO RECEIVERS-RCDAT .
  MOVE SY-UZEIT  TO RECEIVERS-RCTIM.
  MOVE '1'       TO RECEIVERS-SNDPRI.
  MOVE 'X'       TO RECEIVERS-SNDEX.
  MOVE 'U-'      TO RECEIVERS-RECNAM.
  MOVE 'U'       TO RECEIVERS-RECESC.
  MOVE 'INT'     TO RECEIVERS-SNDART.
  MOVE '5'       TO RECEIVERS-SORTCLASS.
  APPEND RECEIVERS.
ENDFORM.

Similar Messages

  • I cannot send email - error message as follows : 'The sender address (my email address) was rejected by the server smtp.tiscali.co.uk.' I can send email from other apple devices, and the email settings are identical. Any ideas?

    For some reason I cannot send email - all was working fine, but now I get the following error message when I try to send email:
    'The sender address (my email address) was rejected by the server smtp.tiscali.co.uk'
    I can receive incoming mail ok and I can send email from other Apple devices. The problem seems confined to my Mac Book Pro.
    Ant ideas?

    Hello there, Pablo639.
    The following Knowledge Base article offers up some great steps for troubleshooting mail issues on your Mac:
    OS X Mail: Troubleshooting sending and receiving email messages
    http://support.apple.com/kb/TS3276
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • How do I send email with pictures attached, using PSE 9 and Windows 7 ?

    How do I send email with pictures attached, using PSE 9 and Windows 7 ?

    Try email attachment workflow in Organizer. http://tv.adobe.com/watch/learn-photoshop-elements-9/sharing-your-images-via-email/
    Thanks
    Andaleeb

  • How i can send email with attachment ?

    any body can help me ..............??????????????????

    Hello,
    please, use "Search" utility in the forum before ask something like this...
    I've just tried with :
    "send email with attachment"
    and ... you have the solution in the first result...
    Regards,
    Jose.

  • How I can send emails using the client object model?

    I have tried this, but I always get an exception with error message "A recipient must be specified.":
    string webUrl = "http://sharepoint.example.com/";
    EmailProperties properties = new EmailProperties();
    properties.To = new string[] { "[email protected]" };
    properties.Subject = "Test subject";
    properties.Body = "Test body";
    ClientContext context = new ClientContext(webUrl);
    Utility.SendEmail(context, properties);
    context.ExecuteQuery(); // ServerException thrown here
    context.Dispose();
    Server stack trace:
    at System.Net.Mail.SmtpClient.Send(MailMessage message)
    at Microsoft.SharePoint.Utilities.SPUtility.SendEmail_Client(EmailProperties properties)
    at Microsoft.SharePoint.ServerStub.Utilities.SPUtilityServerStub.InvokeStaticMethod(String methodName, XmlNodeList xmlargs, ProxyContext proxyContext, Boolean& isVoid)
    at Microsoft.SharePoint.Client.ServerStub.InvokeStaticMethodWithMonitoredScope(String methodName, XmlNodeList args, ProxyContext proxyContext, Boolean& isVoid)
    at Microsoft.SharePoint.Client.ClientMethodsProcessor.InvokeStaticMethod(String typeId, String methodName, XmlNodeList xmlargs, Boolean& isVoid)
    at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStaticMethod(XmlElement xe)
    at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElement xe)
    at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)
    at Microsoft.SharePoint.Client.ClientMethodsProcessor.Process()
    msdn link: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.utilities.utility.sendemail.aspx

    hi
    if you will check the code of SendEmail_Client(EmailProperties properties), you will find that it may only send emails to internal users. May be it was made intentionally in order to prevent spamming from client code. So let's see:
    internal static void SendEmail_Client(EmailProperties properties)
    if (properties.To.Count == 0)
    throw new SPException(SPResource.GetString(web.LanguageCulture, "SendEmailInvalidRecipients", new object[0]));
    AddressReader func = null;
    using (MailMessage mm = new MailMessage())
    func = delegate (MailAddress a) {
    mm.To.Add(a);
    ResolveAddressesForEmail(web, properties.To, func);
    new SmtpClient(SPAdministrationWebApplication.Local.OutboundMailServiceInstance.Server.Address).Send(mm);
    I.e. it adds recipient in ResolveAddressesForEmail() method. Now let's check this method:
    private static void ResolveAddressesForEmail(SPWeb web, IEnumerable<string> addresses, AddressReader func)
    if (addresses != null)
    foreach (string str in addresses)
    if (string.IsNullOrEmpty(str))
    continue;
    SPPrincipalInfo info = ResolvePrincipal(web, str, SPPrincipalType.All, SPPrincipalSource.All, null, false);
    if ((info != null) && (info.PrincipalId > 0))
    if (!string.IsNullOrEmpty(info.Email))
    try
    func(new MailAddress(info.Email, (info.DisplayName != null) ? info.DisplayName : "", Encoding.UTF8));
    catch (FormatException)
    continue;
    if ((string.IsNullOrEmpty(info.Email) && info.IsSharePointGroup) && web.DoesUserHavePermissions(SPBasePermissions.BrowseUserInfo))
    SPGroup byNameNoThrow = web.SiteGroups.GetByNameNoThrow(info.LoginName);
    if (byNameNoThrow == null)
    continue;
    foreach (SPUser user in byNameNoThrow.Users)
    if (!string.IsNullOrEmpty(user.Email))
    try
    func(new MailAddress(user.Email, (user.Name != null) ? user.Name : "", Encoding.UTF8));
    continue;
    catch (FormatException)
    continue;
    continue;
    I.e. at first it tries to resolve user using ResolvePrincipal() method. If it is not resolved (info == null) email is not sent. But if it is - it first checks that email is not empty. If it is not - it adds email to the MailMessage.To recipients list. If
    it is empty it checks whether the principal info represents Sharepoint group. If yes - it will send email to each member of the group.
    So it may be so that you try to send email to external user (which is not supported according to the code above), or resolved principal doesn't have email specified.
    Blog - http://sadomovalex.blogspot.com
    CAML via C# - http://camlex.codeplex.com

  • How do I send email to Czech Republic using Czech language ?

    I have relatives in Czech Republic and I want to send emails using their alphabet and fonts with the carats above some letters, etc. How do I change my Mac to use the Czech alphabet without changing everything on my computer? I don't speak Czech myself so I am lost if everything changes on my computer!
    I just want to change temporarily for the text in the email message itself.

    You go to system prefs/language & text/input sources and check the box for Czech, plus the box for Keyboard Viewer, plus the box for Show Input Menu in Menu Bar.  Then you select Czech in the "flag" menu at the top right of the screen and type.  Select Keyboard Viewer from the same menu to see which key does what.
    If you need a way to translate, I would recommend
    http://translate.google.com

  • How do i set up the eprint from my blackberry so i can send emails to my printer and print them off

    how do i set up eprint on my blackberry so i can send emails from my phone to the printer and print off

     Hi Tanya_Carroll,
    You can follow this link to set up ePrint. 
    http://h71028.www7.hp.com/hho/us/en/ep/articles/setting-up-mobile-printing.html
    Once ePrint is setup, you can send an email to the printer's email address.
    Be sure to use one of these email clients when sending to the printer.  If the Blackberry will not send using your original email address, setup a new email account on the Blackberry and try again.
    Hotmail, Yahoo! Mail, Gmail
    BlackBerry mail clien
    Although I am an HP employee, I am speaking for myself and not for HP.
    If I have resolved your issue, feel free to provide Kudos and make sure you mark this thread as solution provided.

  • Using AOL email how do I bring my SMTP password into line with my actual password so I can send email?

    Using AOL email how do I bring my SMTP password into line with my actual password so I can send email? Thanks.

    I'm trying to go from memory now when it happened to me, but try turning the server Off. See if that ungreys the setting so that you can enter the password and username. I believe on my one AOL account what I did was to select another SMTP server from the list below the primary server.

  • TS3899 How do I get my list of contacts from Gmail to my iPad2 so I can send email from the iPad?

    How do I get my list of contacts from Gmail to my iPad2 so I can send email from the iPad?

    Take a look at this help site that I found by using Google ...
    http://support.google.com/mobile/bin/answer.py?hl=en&answer=138740

  • TS3276 I can send emails with Mail but can no longer receive them. Yet I haven't altered anything.  How do I solve this problem. Thanks

    I can send emails with Mail but can no longer receive them. Yet I haven't altered anything.  How do I solve this problem. Thanks

    Who is your email provider? Have you set up your account manually or was it set up automatically?

  • TS3276 I cannot connect to my outgoing email server on my macBook pro, yet I can, for the same email account on my iPad. Also I can send emails from the other email account I have on my MacBook...really confused can anyone help?

    I cannot connect to my outgoing email server on my macBook pro, yet I can, for the same email account on my iPad. Also I can send emails from the other email account I have on my MacBook...really confused can anyone help?

    Sometimes deleting the account and then re-creating it can solve this issue
    Write down all the information in accounts before doing this
    Highlight the account on the left and click the minus button
    Then click the plus button to add the new account and follow the prompts

  • TS3899 I have set up two email accounts on my iphone4, one with tiscali, my ISP, and the other on gmail. I am able to receive emails on both accounts, and can send emails from my gmail account, but am "Unable to Send Email" from my tiscali (talktalk) acco

    I have set up two email accounts on my iphone4, one with tiscali, my ISP, and the other on gmail. I am able to receive emails on both accounts, and can send emails from my gmail account, but am "Unable to Send Email" from my tiscali (talktalk) account. I get the error message "A copy has been placed in your Outbox. The sender address "name"@tiscali.co.uk was rejected by the server".

    Hi apmichael,
    If you are having issues sending email from one of your mail accounts on your iPhone, you may find the following article helpful:
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    Regards,
    - Brenden

  • After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    My gmail, which is correctly configured for Mail with gmail SMTP and Google IMAP, works for awhile on Mail, which I leave open while working on other applications. But several times a day I get msg from Google: "We recently blocked a sign-in attempt to your Google Account" . . . and requiring me to verify my account details, re-enter passwords, confirm security settings (or change them from "disable" to "enable less secure methods" and so on). In Mail I also have tried "taking all accounts online", and re-entering my gmail password inside Mail account settings. These steps successfully re-set comms between gmail and Mail ... for awhile, then it happens again. Enough occurrences over a work day that I just quit Mail and revert to accessing gmail directly. Apple Care advisor and an Apple knowledge base article say that Apple can't deal with this, as gmail is third-party app, and they refer me to gmail, and so far I've found nothing helpful there.
    From today I also have several instances of a window saying "Mail has unexpectedly closed" and asking me to Re-open it.
    I also use Yahoo mail, which stops working with Mac Mail at the same time as gmail, but I do not receive notices to re-verify from Yahoo.
    I recently upgraded from Mavericks to Yosemite. The Mail problem happened occasionally with Mavericks but is far more frequent with Yosemite.

  • I can´t send my videos fom my PC to my Ipad because the videos are in the .MP4 format and not in the .mp4, is there other types of .mp4 and then how I can send my videos to my Ipad?

    Hello everybody!
    I have a problem with my videos, well first of all I took videos with a camera for my school proyects and then I want to send those videos to my Ipad but there is a problem because when I tried to send my videos it said that those videos could not be synced and then I checked the video´s properties and it says that the format of those videos are .MP4 instead of the .mp4 format and i want to ask the community if there are other types of .mp4 formats and how I can send my videos?
    Please reply because I really need those videos for my school proyect.
    (sorry if my english is bad I dont use to speak english)

    Please upload the distmgr.log and PkgXferMgr.log to Skydrive and post the link here.
    Juke Chou
    TechNet Community Support

  • Hotmail shows inbox but cannot open emails shown but can send email, it works on other browsers and I did the latest update on firefox

    Firefox brings up my Hotmail web page and shows emails but I cannot open them or delete them. I can send emails however. Other browsers like Opera and Chrome work the Hotmail fine. I have downloaded the latest Firefox update as late as today!
    This is a new problem and it worked fine for years. I have Windows 7 operating system on my desktop.

    This problem has been ongoing for months for some users.
    I managed to fix my issue by completely uninstalling FF and then reinstalling the newest version which is 6.0-something.
    I was previously running on 3.0 and my automatic updates had not told me there was a newer version.
    I don't know if that will fix everybody's problem though. I assume a lot of people were already running on FF 6 when they had their problems.

Maybe you are looking for