Attaching file to an email using CL_CRM_EMAIL_DATA

Hi experts, I am new in abap, I am trying to attach a rar file to an email in oop using class CL_CRM_EMAIL_DATA. However, I don't seem to get it right since the attached file seems to be empty.
Here is my sample code below:
REPORT  ztestmailoop.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
      def_filename     = p_file
      mode             = 'O'
      title            = 'Upload File'(078)
    IMPORTING
      filename         = p_file
    EXCEPTIONS
      inv_winsys       = 1
      no_batch         = 2
      selection_cancel = 3
      selection_error  = 4
      OTHERS           = 5.
*- Data Declaration
DATA: lr_mail_data       TYPE REF TO CL_CRM_EMAIL_DATA.
DATA: lv_to              TYPE CRMS_EMAIL_RECIPIENT.
DATA: lv_from            TYPE CRMS_EMAIL_RECIPIENT.
DATA: ls_struc_mail      TYPE CRMS_EMAIL_MIME_STRUC.
DATA: lv_send_request    TYPE SYSUUID_X.
*- create mail object
CREATE OBJECT lr_mail_data.
*- Email subject
lr_mail_data->subject = 'Some subject'.
*- To recipient (may be more)
lv_to-address = <insert email address>.
lv_to-name = <insert email address>.
APPEND lv_to TO lr_mail_data->to.
*- From recipient
MOVE 'SAP CRM <insert email address>' TO lv_from-address.
MOVE 'SAP CRM <insert email address>' TO lv_from-name.
MOVE 'SAP CRM <insert email address>' TO lv_from-id.
lr_mail_data->from = lv_from.
*- Email Body (HTML)
MOVE 'text/html' TO ls_struc_mail-mime_type.
MOVE 'body.htm' TO ls_struc_mail-file_name.
MOVE '<br>Some HTML text<br><br>cool?<br>' TO ls_struc_mail-content_ascii.
APPEND ls_struc_mail TO lr_mail_data->body.
CLEAR ls_struc_mail.
MOVE 'application/x-rar-compressed' TO ls_struc_mail-mime_type.
MOVE p_file TO ls_struc_mail-file_name.
MOVE 'X' TO ls_struc_mail-is_attachment.
APPEND ls_struc_mail TO lr_mail_data->body.
*- Send Email
lv_send_request = CL_CRM_EMAIL_UTILITY_BASE=>SEND_EMAIL( iv_mail_data = lr_mail_data ).
Thanks in advance.

Did you find an answer to this ?

Similar Messages

  • I am having problems attaching files to my email using the latest Firefox 13.0.1, Comcast is my internet provider, but I did not have problem with Safari.

    Why am I having problems attaching files to my email using Firefox 13.0.1.?
    I am using a MAC, OS 10.6.8, and have Comcast as my internet provider. I noticed after I upgraded to Firefox 13.0.1 that I am having problems attaching files to my email. I do not experience the same problem with Safari, but I prefer to use Firefox, as all of my bookmarks and passwords are saved there. I just like the way Firefox works better than Safari.
    I am a free-lance graphic designer and rely on my internet connection to my customers. I need this resolved ASAP!

    Could you start by resetting the zoom level on the page? To do that, you can either:
    * Press Ctrl+0 (that's a zero) on the keyboard
    * View menu > Zoom > Reset
    You also can use zoom to increase/decrease the size from there. This article describes the various mouse, keyboard, and menu methods: [[Font size and zoom - increase the size of web pages]].
    Any luck?

  • Attach File to New Email (Thunderbird)

    It's easy to attach a file to an email using Apple Mail, but I use Thunderbird. How do I get it to work with Thunderbird using automator?

    I don't use Thunderbird, but at last check it wasn't accepting attachments passed on the mailto: URI, so whether it's set to your default mail app or not won't make much difference. The latest release does support, however, passing attachments on the command line:
    /Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -compose attachment='/path/to/attachment'
    But I can't see how to make this useful without having to quit and re-start the app each time your script runs. This was discussed with more detail in a recent thread.

  • Why can't I attach files to my emails in Mac Mail?

    I've messed with the .webarchive and .mailsignature to create myself an HTML email signature. After completing that, which worked, I can now no longer attach files to my emails in Mac Mail. I can click the attachment button, browse to the attachment and hit okay, but it shows nothing in the email and seems to freeze up. I have since replaced those .webarchive and .mailsignature files with the originals from Apple and restarted the computer but still am not able to attach files to my emails. Any help?
    Thank you.

    Except for the first response, all of you are unhelpful. The email was configured. Apple contacted me about the issue and said that the iPad cannot attach multiple docs to a single email regardless of whether the docs are located on the iCloud, in Pages, or a dropbox. It's operating system is not designed to do so (a stupid error if they are promoting the use of iPads for business and productivity, or even fields like architecture, design, and marketing, or even as an office alternative for remote use in meetings...which they are in professional consultations with offices). It also cannot do this through an alternate email site like a university server, yahoo, gmail, etc via Safari. Apple also cannot recommend a third party App that can do so. What they recommended, and there seems to be a lot of buzz about this being a problem with the iPad on the Internet, is that people go to their website, go to product feedback and go to enhancement requests and request the capacity to attach different types of files other than photos, and the capacity to attach multiple documents to an email. Basic functions...any email user would want. One of the Apple techs even thought it was implausible that they hadn't integrated this function ALREADY, when I called to set up the appointment.

  • Can't attach file in icloud webmail using firefox from windows or mac. any ideas?

    anyone else having trouble attaching file in icloud webmail using firefox or internet explorer from windows or mac. i was able to get it to work from safari on a mac, so i guess it must be a browser thing, only enabled or working in safari?

    I had the same problem since last Thursday.  I have tried and re-tried all of the settings suggested by the support posts but I can not get email to go out of me Outbox.

  • Why can't I attach files in an email instead of having them embedded?

    Can't figure out how to attach files in an email. They always come up embedded. I need to send files to someone to edit them. Help please.
    I'm sure this is an easy fix.
    Using Leopard on a MacBook Pro and Iphoto 08
    Thanks in advance.

    Welcome to the Apple Discussions. You can. Control-click on the embedded photo and select View as Icon from the menu.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto (iPhoto.Library for iPhoto 5 and earlier) database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 6 and 7 libraries and Tiger and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Can't read attached files to older emails in Outlook 2010

    Hello,
    I have Outlook 2010 connected with MS Exchange.
    I can’t read attached files to older emails than 3 months. In attached elements there are only small files and I’m not able to open them (size in Bytes!) - double click doesn't work. I've tried different solutions:
    1. https://social.technet.microsoft.com/Forums/en-US/dd2869cb-5e53-4852-b0bb-15de6653db0c/dont-see-attachments-in-old-emails-on-outlook-2013?forum=outlook
    2. https://social.technet.microsoft.com/Forums/office/en-US/cbd420f1-ec7f-44ae-8f78-c7613e2eabb6/unable-to-retrieve-attach-document-for-older-emails-in-outlook-2010?forum=outlook
    3. Clear cache in Advanced Settings of Forms and clear C:\Users\%username%\AppData\Local\Microsoft\FORMS
    None of them works
    Thanks in advance

    Hi,
    Can you read the attachments if we logon in OWA? If attachments can be read in OWA, we may try to delete the original OST file and restart Outlook to sync a new one to see the result. If still no luck, we can create a new mail profile in Control Panel to
    check the result. See:
    http://support.microsoft.com/kb/829918
    If same issue continues in OWA, you may need to recover the data from the backup you create before.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • I cannot view any attached files on my email on iphone 4s. I cant see any pdf files or videos. plse help

    I cannot view any attached files on my email on iphone 4s. I cant see any pdf files or videos. plse help. My phone is updated with the latest software.

    Try deleting the account from the phone and then readding it back, Make sure  if it is not a Yahoo, Gmail, iCloud, or Outlook, account. to get the correct incoming and outgoing server information

  • How to attach file with an email in travel and expenses

    Hi Experts,
    I am new to sap cloud application studio.
    We have requirement that need to attach any type of files in the mail,
    I have gone through this : How to send an email with attachments in SAP Cloud Application Studio
    But compilation error at import AP.FO.ACTIVITY.GLOBAL., so not able to work with that lines of code.
    I am using these lines of code to send email.
    EMailUtilities.SendEMail(lang, bcc, cc, toAddress, htmlContent, from name, subject);
    So am not able to getting how to attach file with this code.
    Please help me regarding this.
    Thanks & Regards,
    Preethi Ande

    Hi Preethi,
         I am trying to send mail from custom BO in Travel on Demand System.I am getting  compilation error.please look into the attached screenshot for the code.
    Please assist me on this,                                Thanks in advance
    regards,
    Sendhilazhagan

  • Distribute file to multiple emails using ssis

    I want to send an email to multiple email recipients.  The list of all the email recipients are present in a Flat File.  My SSIS package should get the list of email recipients from the Flat File, and send an email to all of them. 
    All the recipients would receive the same message.  How do I do this.

    Hi,
    Thanks for your reply and It is working fine for me however, it is not meeting my exact requirement.
    Let me put more details here. My file structure is 'Email','FileName'. File Name is to attach to that email address.
    I have managed to use Record Set Destination and For Each Loop but when I pass the Email variable to 'ToLine' it is not showing any To email address and the email task is in Error mode,... I can able to display the value of the Email variable in Script task
    and can see the email address but when I use the same variable in Script task, it is not working for me. Please guide me in right direction.
    Thanks.
    Did you map the variable to the To property of Sent Mail Task as I suggested. It should be done in the expression tab of the Sent Mail Task. Also the variable used for setting email address value as well as the To property of Sent Mail Task should be set
    to test value which should be in valid email format. Otherwise it will show a warning unless you set delay validation to true
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Attaching files to an email in icloud

    Is there anyway to reset the window size of the file window that pops up when you are adding a file to an email in icloud?  My window only shows minimal information and I have to manually resize it every time I want to attach a file.

    Use Mail's menu to check:  Edit > Attachments > Always Send Windows-Friendly Attachments.
    You will see the photo as an embedded image on your Mac, but the Windows folks you are sending the email to will see it properly.

  • I am not able to attach files in my email

    When I try to attach a file to my email I am not able to.

    I'm having the same problem with FF19.02 using Yahoo mail. Just as of 4/4/2013 we have not been able to attatch any type of a file. Don't want to go back to IE9 where it is working. C'mon FF. You're wise enogh and should be able to solve this problem ASAP. No one wants to go backwards to IEx.x. We need you

  • Why can't i attach multiple attachments on email using iPad

    Using the iPad, in the apple mail app you can't attach documents only photos and videos, why is that? Especially trying to attach PDF files from iBooks  you can't from the mail app. Even if I go to iBooks and try to attach multiple pdf's on one email I can't.
    please help with this.
    Thank you.

    There are Apps like GoodReader which allow attaching multiple documents to emails including multiple PDFs.
    See here: https://itunes.apple.com/us/app/goodreader-for-ipad/id363448914?mt=8

  • TS1506 Click for attach file to the email

    Hope to see a new click for attach file in email in the coming iOS. It is extremely useful when reply email as i can't find a way to do this at this iOS version.
    Many Thanks.

    This is a user to user forum; Apple doesn't read these posts.  But you can give them your suggestions here:
    http://www.apple.com/feedback/iphone.html.

  • Very slow attaching files to Yahoo Emails and Browser Plus will not set up.

    Very slow uploading attachments to my Yahoo Emails. I tried their "Attach files more easily", but "Browser Plus" hangs at "Almost done...(You don't need to do anything) " screen. I have Windows XP, Firefox 3.6.6 and only use Yahoo for emails. Yahoo are no help, could it be browser settings?
    == This happened ==
    Every time Firefox opened
    == About a week ago.

    Walter2323,  Sorry to learn that you are having this issue and welcome to the HP forums,
    Have try using this tool to install the printer GO HERE  give it a try please let me know if you encounter any errors.
    Another Step that I will take is to disable all securtiy applications before installing the printer this will ensure that one of this application is not blocking a critical process needed to properly install the printer.
    Are able to print from the computer via usb and/or wireless?
    Hope this helps and let me know if I can assist you any further;
    RobertoR
    You can say THANKS by clicking the KUDOS STAR. If my suggestion resolves your issue Mark as a "SOLUTION" this way others can benefit Thanks in Advance!

Maybe you are looking for