Sending an email with an image attachment

Hello
Basicly I want to send an email with an image as attachment.
The image is taken by the user in the same app.
It is an android app
This is the code i've got so far.
http://pastebin.com/wVDZsgHx
can anyone help me please
I've found out that you have to do it server side with php, but I have no idea how to begin with it.

Hmmm, Permissions are messed up somewhere!?
Can you open to pic say in Preview, select All, Copy, 7 Paste into Mail?

Similar Messages

  • CRM ONLINE 2013: On Approval Of Quotation, Run Report, Generate PDF and Send an Email With PDF as attachment

    Hi,
    I am using CRM ONLINE 2013.
    How to automate below process?
    1. On Approval Of Quotation, Run Report.
    2. Generate PDF.
    3. Send an Email With PDF as attachment.
    As i have gone through many forums for this topic, but creating a plugin code for generating Report PDF is not possible in CRM ONLINE.
    So, What is the alternate way to do this..?
    Thanks.

    This is my entire code mentioned below:-
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
        <script type="text/javascript">
            if (typeof (SDK) == "undefined")
            { SDK = { __namespace: true }; }
            SDK.JScriptRESTDataOperations = {
                _context: function () {
                    if (typeof GetGlobalContext != "undefined")
                    { return GetGlobalContext(); }
                    else {
                        if (typeof Xrm != "undefined") {
                            return Xrm.Page.context;
                        else { return new Error("Context is not available."); }
                _getServerUrl: function () {
                    var serverUrl = this._context().getServerUrl()
                    if (serverUrl.match(/\/$/)) {
                        serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                    return serverUrl;
                _ODataPath: function () {
                    return this._getServerUrl() + "/XRMServices/2011/OrganizationData.svc/";
                _errorHandler: function (req) {
                    return new Error("Error : " +
      req.status + ": " +
      req.statusText + ": " +
      JSON.parse(req.responseText).error.message.value);
                _dateReviver: function (key, value) {
                    var a;
                    if (typeof value === 'string') {
                        a = /Date\(([-+]?\d+)\)/.exec(value);
                        if (a) {
                            return new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
                    return value;
                Create: function (object, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 201) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send(JSON.stringify(object));
                Retrieve: function (id, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("GET", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 200) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                Update: function (id, object, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.setRequestHeader("X-HTTP-Method", "MERGE");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 204 || this.status == 1223) {
                                successCallback();
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send(JSON.stringify(object));
                Delete: function (id, type, successCallback, errorCallback) {
                    var req = new XMLHttpRequest();
                    req.open("POST", this._ODataPath() + type + "Set(guid'" + id + "')", true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.setRequestHeader("X-HTTP-Method", "DELETE");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 204 || this.status == 1223) {
                                successCallback();
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                RetrieveMultiple: function (type, filter, successCallback, errorCallback) {
                    if (filter != null) {
                        filter = "?" + filter;
                    else { filter = ""; }
                    var req = new XMLHttpRequest();
                    req.open("GET", this._ODataPath() + type + "Set" + filter, true);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                    req.onreadystatechange = function () {
                        if (this.readyState == 4 /* complete */) {
                            if (this.status == 200) {
                                successCallback(JSON.parse(this.responseText, SDK.JScriptRESTDataOperations._dateReviver).d.results);
                            else {
                                errorCallback(SDK.JScriptRESTDataOperations._errorHandler(this));
                    req.send();
                __namespace: true
        </script>
        <script type="text/javascript">
            //Create Email and link it with Order as Regarding field
            var Xrm;
            var email = new Object();
            var ownerID = "";
            var CustomerId = "";
            if (window.opener) { Xrm = window.opener.Xrm; }
            else if (window.parent) { Xrm = window.parent.Xrm; }
            //Get ownerid who send email of quotation to customer
            function GetOwnerID() {
                var owner = Xrm.Page.getAttribute("ownerid").getValue();
                ownerID = owner[0].id;
                var ownerName = owner[0].name;
                var entityType = owner[0].entityType;
                GetToEmailGUID();
            //Get customerid who receive email of quotation from owner
            function GetToEmailGUID() {
                var Customer = Xrm.Page.getAttribute('customerid').getValue();
                CustomerId = Customer[0].id;
                var CustomerName = Customer[0].name;
                var entityType = Customer[0].entityType;
                //if CustomerId is type of "Account" then get Primary Contact id of that account
                if (entityType == "account") {
                    var contact = Xrm.Page.getAttribute("customerid").getValue();
                    if (contact === null) return;
                    var serverUrl = Xrm.Page.context.getClientUrl();
                    var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/AccountSet(guid'" + contact[0].id + "')?$select=PrimaryContactId";
                    var req = new XMLHttpRequest();
                    req.open("GET", oDataSelect, false);
                    req.setRequestHeader("Accept", "application/json");
                    req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
                    req.onreadystatechange = function () {
                        if (req.readyState === 4) {
                            if (req.status === 200) {
                                var retrieved = JSON.parse(req.responseText).d;
                                CustomerId = retrieved.PrimaryContactId.Id;
                            else {
                                alert(this.statusText);
                    req.send();
            function CreateEmail() {
                GetOwnerID();
                email.Subject = "Email with Report Attachment";
                //Set The current order as the Regarding object
                email.RegardingObjectId = {
                    Id: Xrm.Page.data.entity.getId(),    //Get the current entity Id , here OrderId
                    LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be “salesOrder”
                //Create Email Activity
                SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });
            // Email Call Back function
            function EmailCallBack(result) {
                email = result; // Set the email to result to use it later in email attachment for retrieving activity Id
                var activityPartyFrom = new Object();
                // Set the From party of the ActivityParty to relate an entity with Email From field
                activityPartyFrom.PartyId = {
                    Id: CustomerId, //"79EBDD26-FDBE-E311-8986-D89D6765B238",  // id of entity you want to associate this activity with.        
                    LogicalName: "contact"
                // Set the "activity" of the ActivityParty
                activityPartyFrom.ActivityId = {
                    Id: result.ActivityId,
                    LogicalName: "email"
                // Now set the participation type that describes the role of the party on the activity).
                activityPartyFrom.ParticipationTypeMask = { Value: 2 }; // 2 means ToRecipients
                // Create the from ActivityParty for the email
                SDK.JScriptRESTDataOperations.Create(activityPartyFrom, "ActivityParty", ActivityPartyFromCallBack, function (error) { alert(error.message); });
                var activityPartyTo = new Object();
                // Set the From party of the ActivityParty to relate an entity with Email From field
                activityPartyTo.PartyId = {
                    Id: ownerID, //"79EBDD26-FDBE-E311-8986-D89D6765B238",  // id of entity you want to associate this activity with.        
                    LogicalName: "systemuser"
                // Set the "activity" of the ActivityParty  
                activityPartyTo.ActivityId = {
                    Id: result.ActivityId,
                    LogicalName: "email"
                // Now set the participation type that describes the role of the party on the activity).    
                activityPartyTo.ParticipationTypeMask = { Value: 1 }; // 1 means Sender
                // Create the from ActivityParty
                SDK.JScriptRESTDataOperations.Create(activityPartyTo, "ActivityParty", ActivityPartyToCallBack, function (error) { alert(error.message); });
            //ActivityParty From Callback
            function ActivityPartyFromCallBack(result) {
            //ActivityParty To Callback
            function ActivityPartyToCallBack(result) {
                GetReportId('ABM_Infotech_SalesQuote');
            //Create attachment for the created email
            function CreateEmailAttachment() {
                //get reporting session and use the params to convert a report in PDF
                var params = getReportingSession();
                //Email attachment parameters
                var activitymimeattachment = Object();
                activitymimeattachment.ObjectId = Object();
                activitymimeattachment.ObjectId.LogicalName = "email";
                activitymimeattachment.ObjectId.Id = email.ActivityId;
                activitymimeattachment.ObjectTypeCode = "email",
                    activitymimeattachment.Subject = "File Attachment";
                activitymimeattachment.Body = encodePdf(params);
                activitymimeattachment.FileName = "Report1.pdf";
                activitymimeattachment.MimeType = "application/pdf";
                //Attachment call
                SDK.JScriptRESTDataOperations.Create(activitymimeattachment, "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, function (error) { alert(error.message); });
            //ActivityMimeAttachment CallBack function
            function ActivityMimeAttachmentCallBack(result) {
                var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";
                var width = "800px";
                var height = "600px";
                window.open(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", features);
                // To open window which works in outlook and IE both
                //openStdWin(Xrm.Page.context.getServerUrl() + "main.aspx?etc=" + 4202 + "&pagetype=entityrecord&id=" + email.ActivityId, "_blank", width,
    height, features);
            //This method will get the reportId based on a report name that will be used in            getReportingSession() function
            function GetReportId(reportName) {
                var oDataSetName = "ReportSet";
                var columns = "ReportId";
                var filter = "Name eq '" + reportName + "'";
                retrieveMultiple(oDataSetName, columns, filter, onSuccess);
            function retrieveMultiple(odataSetName, select, filter, successCallback) {
                var serverUrl = Xrm.Page.context.getServerUrl();
                var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
                var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName + "?";
                if (select) {
                    odataUri += "$select=" + select + "&";
                if (filter) {
                    odataUri += "$filter=" + filter;
                $.ajax({
                    type: "GET",
                    contentType: "application/json; charset=utf-8",
                    datatype: "json",
                    url: odataUri,
                    beforeSend: function (XMLHttpRequest) {
                        XMLHttpRequest.setRequestHeader("Accept", "application/json");
                    success: function (data) {
                        if (successCallback) {
                            if (data && data.d && data.d.results) {
                                successCallback(data.d.results);
                            else if (data && data.d) {
                                successCallback(data.d);
                            else {
                                successCallback(data);
                    error: function (XmlHttpRequest, errorThrown) {
                        if (XmlHttpRequest && XmlHttpRequest.responseText) {
                            alert("Error while retrieval ; Error – " + XmlHttpRequest.responseText);
            function onSuccess(data) {
                reportId = data[0].ReportId.replace('{', ").replace('}', ");
                CreateEmailAttachment(); // Create Email Attachment
            //Gets the report contents
            function getReportingSession() {
                var pth = Xrm.Page.context.getServerUrl() + "/CRMReports/rsviewer/reportviewer.aspx";
                var retrieveEntityReq = new XMLHttpRequest();
                var Id = Xrm.Page.data.entity.getId();
                var quotationGUID = Id.replace('{', ""); //set this to selected quotation GUID
                quotationGUID = quotationGUID.replace('}', "");
                var reportName = "ABM_Infotech_SalesQuote"; //set this to the report you are trying to download
                var reportID = "751089AA-74B8-E211-B52F-D8D3855B253B"; //set this to the guid of the report you are trying to download
                var rptPathString = ""; //set this to the CRMF_Filtered parameter
                var strParameterXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'><entity name='quote'><all-attributes /><filter type='and'><condition
    attribute='quoteid' operator='eq' uitype='quote' value='" + quotationGUID + "' /> </filter></entity></fetch>";
                retrieveEntityReq.open("POST", pth, false);
                retrieveEntityReq.setRequestHeader("Accept", "*/*");
                retrieveEntityReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                rptPathString = "id=%7B" + reportID + "%7D&uniquename=" + Xrm.Page.context.getOrgUniqueName() + "&iscustomreport=true&reportnameonsrs=&reportName="
    +
                                reportName + "&isScheduledReport=false&p:ABMFilteredQuote=" + strParameterXML;
                //remove the part starting from &p:salesorderid if your report has no parameters
                retrieveEntityReq.send(rptPathString);
                var x = retrieveEntityReq.responseText.indexOf("ReportSession=");
                var ret = new Array();
                ret[0] = retrieveEntityReq.responseText.substr(x + 14, retrieveEntityReq.responseText.indexOf("&", x) - x - 14); //the session id
                x = retrieveEntityReq.responseText.indexOf("ControlID=");
                ret[1] = retrieveEntityReq.responseText.substr(x + 10, retrieveEntityReq.responseText.indexOf("&", x) - x - 10); //the control id
                return ret;
            var bdy = new Array();
            var bdyLen = 0;
            function concat2Bdy(x) {
                bdy[bdyLen] = x;
                bdyLen++;
            function encodePdf(params) {
                bdy = new Array();
                bdyLen = 0;
                var retrieveEntityReq = new XMLHttpRequest();
                var pth = Xrm.Page.context.getServerUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + params[0] +
                "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + params[1] +
                "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
                retrieveEntityReq.open("GET", pth, false);
                retrieveEntityReq.setRequestHeader("Accept", "*/*");
                retrieveEntityReq.send();
                BinaryToArray(retrieveEntityReq.responseBody);
                return encode64(bdy);
            var StringMaker = function () {
                this.parts = [];
                this.length = 0;
                this.append = function (s) {
                    this.parts.push(s);
                    this.length += s.length;
                this.prepend = function (s) {
                    this.parts.unshift(s);
                    this.length += s.length;
                this.toString = function () {
                    return this.parts.join('');
            var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
            function encode64(input) {
                var output = new StringMaker();
                var chr1, chr2, chr3;
                var enc1, enc2, enc3, enc4;
                var i = 0;
                while (i < input.length) {
                    chr1 = input[i++];
                    chr2 = input[i++];
                    chr3 = input[i++];
                    enc1 = chr1 >> 2;
                    enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                    enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                    enc4 = chr3 & 63;
                    if (isNaN(chr2)) {
                        enc3 = enc4 = 64;
                    } else if (isNaN(chr3)) {
                        enc4 = 64;
                    output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
                return output.toString();
        </script>
        <script type="text/vbscript">
        Function BinaryToArray(Binary)
               Dim i
               ReDim byteArray(LenB(Binary))
               For i = 1 To LenB(Binary)
                     byteArray(i-1) = AscB(MidB(Binary, i, 1))
                     concat2Bdy(AscB(MidB(Binary, i, 1)))
             Next
              BinaryToArray = byteArray
       End Function     
        </script>
    </head>
    <body>
        <input type="button" onclick="CreateEmail();" value="Attach Report" />
    </body>
    </html>

  • Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tell me that the file is being used even when  it is not. How can I fix this issue?

    Why can I not attach a document to an email? Every time I want to send an email with a document attached to it, an error notice pops out. It tells me that the file is being used even when  iall other programs are closed. How can I fix this issue?

    Thanks Jeff, I was not aware that a template could be multi-page.  (All the existing templates were 1 page)
    But it worked, saving me some steps.  When I was finished I renamed the document, and locked it.
    Then tried to save it but  could not because it was locked.  I closed it, went to my Spread Sheet Folder ,
    to find it, it was not there.  The Finder could not find it either.
    So I start over again.
    I opened up Numbers and it showed my personal Numbers template folder, it contained both my new 
    original 4 page template and the vanished saved document!
    I tried to delete the template containing these document data and could not - I had to go to the Library/Application Support/Numbers to physically remove it from this folder. Then I started over again.  I Finally found out how to make it work: I can now "save as", and then lock, and it will go to place where I want it to be saved and locked.
    The secret is: Click on the document title in the menu bar, and it opens up  "Save as...", which works the same as in OS 10.4.11, and you can pick the place you want for saving.  Once done that, you can then lock the document in the same pull down menu, and then close it.
    I also found later that I can delete a template from its folder, by letting Numbers open the templates,
    clicking on the one I want to remove, then go to the "Numbers Menu/File/Move to...", select "Desktop"
    and from there the selected template can then be thrown into the Trash from there.
    It appears now that the real fault of the Numbers software is that the "Save as" command is not available in the "Edit" or "File" pull-down menus, but hidden behind the title of the document.

  • Please help, I'm unable to send an email with a pdf attachment

    We have Windows 8 Pro on the pc, I have been trying to send a pdf document that my husband needs to his work and no matter how I try to send it (either from reader or directly from my email with the attachment it just will not send.  Can anyone please help?

    No worries.  But it is strange that you cannot even send email with a PDF attachment from Microsoft Mail.  At this point, no PDF viewers (e.g. Microsoft Reader, Adobe Reader Touch) are involved because you are not viewing PDF files.
    Instead of saying "It won't send", you need to describe exactly what you see on the screen for every step. Where does the problem start? 
    Step 1: Attaching a PDF file to new email in Microsoft Mail
    Are you able to find the PDF file and attach it to new email?
    Step 2: Sending email with a PDF attachment
    What happens when you click the Send button?  Does it hang forever?  Does it show an error message? Could you confirm that you can send email with other type of attachments (e.g. text file, Word file) from Microsoft Mail from the same PC?
    You can provide the details to Microsoft for troubleshooting.
    Alternatively, you can try to send email with the PDF attachment from other accounts like Gmail (Google Mail) or Yahoo Mail via the web browser (Internet Explorer) interface.
    Sometimes, rebooting your system solves "mysterious" problems, too.
    Good luck!

  • FM to send an email with a PDF attachment

    Hello All,
        Please suggest me some FMs to send an email along with PDF attachment.
    Thanks,

    DATA: i_otf       TYPE itcoo OCCURS 0 WITH HEADER LINE,
          i_tline     TYPE TABLE OF tline WITH HEADER LINE,
          i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
          i_record    LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    * Objects to send mail.
          i_objpack   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          i_objtxt    LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_objbin    LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_reclist   LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    **************Work Area declarations***********************
          w_objhead   TYPE soli_tab,
          w_ctrlop    TYPE ssfctrlop,
          w_compop    TYPE ssfcompop,
          w_return    TYPE ssfcrescl,
          w_doc_chng  TYPE sodocchgi1,
          w_data      TYPE sodocchgi1,
          w_buffer    TYPE string."To convert from 132 to 255
    data:     v_len_in     TYPE sood-objlen,
         v_len_out    TYPE sood-objlen,
         v_len_outn   TYPE i,
         v_lines_txt  TYPE i,
         v_lines_bin  TYPE i.
    start-of-selection.
      w_ctrlop-getotf    = gv_abaptrue.
      w_ctrlop-no_dialog = gv_abaptrue.
      w_compop-tdnoprev  = gv_abaptrue.
    PERFORM call_smartform.
      PERFORM convert_to_otf_format.
      PERFORM pdf_formatting.
      PERFORM build_mail_format.
      PERFORM send_mail.
    form call_smartform.
    DATA:fm_name  TYPE rs38l_fnam.
      DATA:formname TYPE tdsfname VALUE 'ZSD_CRM_PROFORMA_INVOICE_001'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = formname
        IMPORTING
          fm_name  = fm_name.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION fm_name
        EXPORTING
          control_parameters = w_ctrlop
          output_options     = w_compop
          user_settings      = ' '
          v_vbeln            = v_vbeln
          v_erdat            = gv_dat
          wa_custaddr        = gw_zcustaddr
          v_stceg            = gw_kna1-stceg
          v_total            = gv_total
          vbak               = vbak
          v_lifnr            = gw_kna1-lifnr
          vbrp               = vbrp
          v_head             = gv_heading
          v_taxtext          = gv_text
          v_tax              = gv_tax
          v_gtotal           = gv_gtot
        IMPORTING
          job_output_info    = w_return
        TABLES
          it_det             = gt_items
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      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.
    form convert_to_otf_format.
      i_otf[] = w_return-otfdata[].
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = v_len_in
        TABLES
          otf                   = i_otf
          lines                 = i_tline
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      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.
    form pdf_formatting.
    * Convert PDF from 132 to 255.
      LOOP AT i_tline.
    * Replacing space by ~
        TRANSLATE i_tline USING ' ~'.
        CONCATENATE w_buffer i_tline INTO w_buffer.
      ENDLOOP.
    * Replacing ~ by space
      TRANSLATE w_buffer USING '~ '.
      DO.
        i_record = w_buffer.
    * Appending 255 characters as a record
        APPEND i_record.
        SHIFT w_buffer LEFT BY 255 PLACES.
        IF w_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    endform.     
    FORM build_mail_format .
    DATA:lv_dash(1)         TYPE c VALUE '-'.
      DATA:lv_xtn(4)          TYPE c VALUE '.pdf'.
      CONSTANTS:lv_esacpe     TYPE so_escape  VALUE 'U'.
      CONSTANTS:lv_so_obj_tp  TYPE so_obj_tp  VALUE 'PDF'.
      CONSTANTS:lv_so_obj_tp1 TYPE so_obj_tp  VALUE 'RAW'.
      CONSTANTS:lv_so_obj_sns TYPE so_obj_sns VALUE 'F'.
    * Get Email ID's
      SELECT * INTO TABLE gt_address[] FROM adr6
      WHERE addrnumber = gw_kna1-adrnr.
      REFRESH:i_reclist,
              i_objtxt,
              i_objbin,
              i_objpack.
      CLEAR w_objhead.
    * Object with PDF.
      i_objbin[] = i_record[].
      DESCRIBE TABLE i_objbin[] LINES v_lines_bin.
    * Object with main text of the mail.
      i_objtxt = text-002.
      APPEND i_objtxt.
      DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    * Document information.
      w_doc_chng-obj_name = text-005.
      w_doc_chng-expiry_dat = sy-datum + 10.
      IF gw_flg = 'T'.
        w_doc_chng-obj_descr = text-003.
      ELSE.
        w_doc_chng-obj_descr = text-004.
      ENDIF.
      CONCATENATE w_doc_chng-obj_descr lv_dash v_vbeln INTO w_doc_chng-obj_descr.
      w_doc_chng-sensitivty = lv_so_obj_sns. "Functional object
      w_doc_chng-doc_size = v_lines_txt * 255.
    * Pack to main body as RAW.
    * Obj. to be transported not in binary form
      CLEAR i_objpack-transf_bin.
    * Start line of object header in transport packet
      i_objpack-head_start = 1.
    * Number of lines of an object header in object packet
      i_objpack-head_num = 0.
    * Start line of object contents in an object packet
      i_objpack-body_start = 1.
    * Number of lines of the object contents in an object packet
      i_objpack-body_num = v_lines_txt.
    * Code for document class
      i_objpack-doc_type = lv_so_obj_tp1.
      APPEND i_objpack.
    * Packing as PDF.
      i_objpack-transf_bin = gv_abaptrue.
      i_objpack-head_start = 1.
      i_objpack-head_num = 1.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = lv_so_obj_tp.
      i_objpack-obj_name = text-005.
      CONCATENATE w_doc_chng-obj_descr lv_xtn INTO i_objpack-obj_descr.
      i_objpack-doc_size = v_lines_bin * 255.
      APPEND i_objpack.
    * Document information.
      CLEAR i_reclist.
    * e-mail receivers.
      LOOP AT gt_address INTO gw_adr6.
        i_reclist-receiver = gw_adr6-smtp_addr.
        i_reclist-express =  gv_abaptrue.
        i_reclist-rec_type = lv_esacpe. "Internet address
        APPEND i_reclist.
      ENDLOOP.
    endform.
    FORM send_mail .
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_chng
          put_in_outbox              = ' '
        TABLES
          packing_list               = i_objpack[]
          object_header              = w_objhead[]
          contents_bin               = i_objbin[]
          contents_txt               = i_objtxt[]
          receivers                  = i_reclist[]
        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.
      COMMIT WORK.
    ENDFORM.  
    hi this is a program for sending smartform as pdf attachment.
    make the necessary modifications in the OTF part and use it
    Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM
    Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM

  • Send HTML Email with Embedded Images and CSS

    Hi All,
    I have a html page. I want to send that html page(not with attachment) with all images and css. i search and try but I cant find a good solution. can any one help... plz..........
    Thank You.....

    If you want to send the html page and have it
    reference the images and css files on your web
    site, that's pretty easy. Just create a message
    with text/html content that is your html page.
    If you want to include all the images and css files
    in your message along with the html page, you'll
    need to create a multipart/related message and
    you'll need to change all the html to reference the
    images and css files using "cid:" references.

  • Urgent: Sending an Email with Excel sheet attachment

    Hi All,
    I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
    the below mentioned is my code.
    i_texts-line = c_stern.
      i_texts-line+254(1) = c_newline.
      APPEND i_texts.
      LOOP AT i_texc.
        i_att_line-line = i_texc.
        APPEND i_att_line.
      ENDLOOP.
      DATA: wa_doc_chng LIKE sodocchgi1.
      DATA: w_tab_lines LIKE sy-tabix.
      STATICS: c_body_start TYPE i VALUE '1'.
      CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
                 lc_atthead(30)  TYPE c VALUE 'Manually released invoices'.
      DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: w_doc_name(30) TYPE c.
      DATA: l_text1(15),
            l_text2(12),
            l_text3(15),
            l_text4(15),
            l_text5(14),
            l_text6(17),
            l_text7(10),
            l_text8(20),
            l_text9(19),
            l_text10(19),
            l_text11(19),
            l_text12(16),
            l_text13(20),
            l_text14(19),
            l_text15(19),
            l_text16(30).
      DATA: DATE(10),
            DT(2),
            MON(3),
            YR(4),
            lc_final(50).
      CLEAR: i_texts, i_reci,i_att_line.                "i_bname,
      REFRESH: i_texts, i_reci,i_att_line.              "i_bname,
      WRITE sy-datum TO w_datex.
      WRITE sy-uzeit TO w_timex.
      l_text1 = text-003.
      l_text2 = text-004.
      l_text3 = text-005.
      l_text4 = text-006.
      l_text5 = text-007.
      l_text6 = text-008.
      l_text7 = text-009.
      l_text8 = text-010.
      l_text9 = text-011.
      l_text10 = text-012.
      l_text11 = text-013.
      l_text12 = text-014.
      l_text13 = text-015.
      l_text14 = text-016.
      l_text15 = text-017.
      l_text16 = text-026.
      CONCATENATE
      l_text1
      l_text2
      l_text3
      l_text4
      l_text5
      l_text6
      l_text7
      l_text8
      l_text9
      l_text10
      l_text11
      l_text12
      l_text13
      l_text14
      l_text15
      l_text16
      INTO i_texts SEPARATED BY
      c_horz_tab.
      i_texts-line+254(1) = c_newline.
      APPEND i_texts.
      CLEAR  i_texts.
      LOOP AT i_texc.
        i_att_line-line = i_texc.
        APPEND i_att_line.
      ENDLOOP.
      LOOP AT so_rec.
        i_reci-receiver = so_rec-low.
        i_reci-express = 'X'.
        i_reci-rec_type = 'U'.
        APPEND i_reci.
      ENDLOOP.
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      READ TABLE i_texts INDEX w_tab_lines.
      wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
      wa_obj_name   = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
      DT  = SY-DATUM+6(2).
      MON = SY-DATUM+4(2).
      YR  = SY-DATUM+0(4).
      CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
      CONCATENATE lc_atthead date into lc_final separated by ' '.
      MOVE lc_final
                   TO wa_obj_descr .
      wa_doc_chng-obj_name  = wa_obj_name.
      wa_doc_chng-obj_descr = wa_obj_descr.
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 0.
      i_objpack-body_num = w_tab_lines.
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
      APPEND LINES OF i_att_line TO i_texts.
      LOOP AT i_arseg INTO wa_arseg.
        i_xmplt_d-belnr = wa_arseg-belnr.
        i_xmplt_d-budat = wa_arseg-budat.
        i_xmplt_d-bukrs = wa_arseg-bukrs.
        i_xmplt_d-lifnr = wa_arseg-lifnr.
        i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
        i_xmplt_d-wrbtr = wa_arseg-wrbtr.
        i_xmplt_d-waers = wa_arseg-waers.
        i_xmplt_d-ebeln = wa_arseg-ebeln.
        i_xmplt_d-ebelp =  wa_arseg-ebelp.
        i_xmplt_d-reason = wa_arseg-reason.
        i_xmplt_d-dmeng = wa_arseg-dmeng.
        i_xmplt_d-dwert = wa_arseg-dwert.
        i_xmplt_d-bname = wa_arseg-bname.
        i_xmplt_d-name_text = wa_arseg-name_text.
        i_xmplt_d-udate = wa_arseg-udate.
        i_xmplt_d-comment =  wa_arseg-comment.
        APPEND i_xmplt_d.
      ENDLOOP.
      LOOP AT i_xmplt_d.
        CONCATENATE i_xmplt_d-belnr
                    i_xmplt_d-budat
                    i_xmplt_d-bukrs
                    i_xmplt_d-lifnr
                    i_xmplt_d-name1_lifnr
                    i_xmplt_d-wrbtr
                    i_xmplt_d-waers
                    i_xmplt_d-ebeln
                    i_xmplt_d-ebelp
                    i_xmplt_d-reason
                    i_xmplt_d-dmeng
                    i_xmplt_d-dwert
                    i_xmplt_d-bname
                    i_xmplt_d-name_text
                    i_xmplt_d-udate
                    i_xmplt_d-comment
                    INTO i_texts SEPARATED
                    BY c_horz_tab.
        i_texts-line+254(1) = c_newline.
        APPEND i_texts.
        CLEAR i_texts.
      ENDLOOP.
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      READ TABLE i_texts INDEX w_tab_lines.
      wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      i_objpack-transf_bin = ' '.
      i_objpack-head_start = 0.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = w_tab_lines.
      i_objpack-doc_type = 'XLS'.
      i_objpack-obj_name = 'Attachment'.
    i_objpack-obj_descr = w_doc_name.
      i_objpack-obj_descr = lc_filename.
      i_objpack-doc_size = w_tab_lines * 255.
      APPEND i_objpack.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
        TABLES
          packing_list               = i_objpack
          contents_txt               = i_texts
          receivers                  = i_reci
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc = 0.
        COMMIT WORK.
      ELSE.
        WRITE: / 'Error in send E-Mail' .
      ENDIF.
    please revert me asap. It is very urgent to me. thanks in advance.
    Bye

    hI
    Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
    * End of Selection Event : Displaying the selected data                *
    END-OF-SELECTION.
        PERFORM EMAIL_EXCEL_ATTACHMENT.
    ******///form
    FORM EMAIL_EXCEL_ATTACHMENT .
    * Populate table with detaisl to be entered into .xls file
      PERFORM BUILD_XLS_DATA_TABLE.
    * 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 S_EMAIL
                                          TEXT-042
                                          C_XLS
                                          'filename'
                                 CHANGING GD_ERROR
                                          GD_RECIEVER.
    *   Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
    ENDFORM.                    " EMAIL_EXCEL_ATTACHMENT
    ********///form BUILD_XLS_DATA_TABLE
    FORM BUILD_XLS_DATA_TABLE .
      DATA :    LV_NETWR(20)     TYPE C,
                LV_BOL_DATE(20)  TYPE C,
                LV_KAWRT(20)     TYPE C,
                LV_FKDAT(20)     TYPE C,
                LV_WAERK(20)     TYPE C,
                LV_KURRF(20)     TYPE C,
                LV_SHIPDATE(20)  TYPE C,
                LV_DEPTDATE(20)  TYPE C.
      CONSTANTS:
          CON_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
          CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.  "#EC *
      DATA STR TYPE STRING.
    **********/ this parameter concatenate to get headers
      CONCATENATE STR
      'SLNO'
      'OWNER'
      'SERIAL NO'
      'FROM'
      'DESTINATION'
      'INVOICE VALUE'
      'DESCRIPTION'
      'CUSTOMER NAME'
      'BL NUMBER'
      'BL DATE'
      'VESSEL NAME/AIRLINE DETAILS'
      'MODE OF TRANSIT'
      'SHIPPING MARKS'
      'DUTY SUM INSURED'
      'FLAG'
      'OPEN COVERNO'
      'INVOICE DATE'
      'INVOICE NO'
      'LC WORDING'
      'QUANTITY'
      'PACKAGING DETAILS'
      'BASIS OF VALUATION'
      'EXCLUDE WAR SRCC'
      'CURRENCY'
      'EXCHANGE RATE'
      'ADDRESS'
      'VESSEL BUILT YEAR'
      'VESSEL FLAG'
      'VOYAGE NO'
      'SHIPMENT DATE'
      'DEPARTURE DATE'
      'SURVEYOR COUNTRY'
      'SURVEYOR CITY'
      'SURVEYOR AGENT'
      'SURVEYOR ADDRESS'
      'EXPORT CONSIGNMENT'
      'CONTAINER DETAILS'
      CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
      LOOP AT IT_FINAL.
    *******/ this is to pass body / row data
        WRITE : IT_FINAL-NETWR    TO LV_NETWR,              "#EC UOM_IN_MES
                IT_FINAL-BOL_DATE TO LV_BOL_DATE,
                IT_FINAL-KAWRT    TO LV_KAWRT,              "#EC UOM_IN_MES
                IT_FINAL-FKDAT    TO LV_FKDAT,
                IT_FINAL-WAERK    TO LV_WAERK,
                IT_FINAL-KURRF    TO LV_KURRF,
                IT_FINAL-SHIPDATE TO LV_SHIPDATE,
                IT_FINAL-DEPTDATE TO LV_DEPTDATE.
        CONCATENATE
               STR
               IT_FINAL-SLNO
               IT_FINAL-OWNER
               IT_FINAL-SRNO
               IT_FINAL-PORT_LOAD
               IT_FINAL-PORT_DSCHR
               LV_NETWR
               IT_FINAL-DESCRIP
               IT_FINAL-CUSTNAME
               IT_FINAL-BOL_NUM
               LV_BOL_DATE
               IT_FINAL-VESSELNAME
               IT_FINAL-SHP_TYPE
               IT_FINAL-SHP_MARK
               LV_KAWRT
               IT_FINAL-FLAG
               IT_FINAL-OPEN_CONO
               LV_FKDAT
               IT_FINAL-VBELN
               IT_FINAL-LC_WORD
               IT_FINAL-QUANT
               IT_FINAL-PACKDETL
               IT_FINAL-INCO1
               IT_FINAL-EXCWSR
               LV_WAERK
               LV_KURRF
               IT_FINAL-ADDPAY
               IT_FINAL-VESSBYR
               IT_FINAL-VESSFLG
               IT_FINAL-VOY_FLY_NO
               LV_SHIPDATE
               LV_DEPTDATE
               IT_FINAL-SURCOUNT
               IT_FINAL-INCO2
               IT_FINAL-EXPORT_CON
               IT_FINAL-SURAGT
               IT_FINAL-SURADD
               IT_FINAL-CONTRNO
       CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
      ENDLOOP.
      CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
        EXPORTING
          TEXT      = STR
        TABLES
          FTEXT_TAB = IT_ATTACH.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    ******// form POPULATE_EMAIL_MESSAGE_BODY
    FORM POPULATE_EMAIL_MESSAGE_BODY .
      REFRESH IT_MESSAGE.
      IT_MESSAGE = TEXT-043.  " Please find attached Insurance Certificate details
      APPEND IT_MESSAGE.
    ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
    *******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       text
    *      -->PIT_MESSAGE           text
    *      -->PIT_ATTACH            text
    *      -->P_EMAIL               text
    *      -->P_MTITLE              text
    *      -->P_FORMAT              text
    *      -->P_FILENAME            text
    *      -->P_ATTDESCRIPTION      text
    *      -->P_SENDER_ADDRESS      text
    *      -->P_SENDER_ADDRES_TYPE  text
    *      -->P_ERROR               text
    *      -->P_RECIEVER            text
    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.       "#EC *
      DATA: LD_ERROR    TYPE SY-SUBRC,                          "#EC *
    *        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.                         "#EC *
    *  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.
      DESCRIBE TABLE IT_ATTACH LINES W_CNT.
      READ TABLE IT_ATTACH INDEX W_CNT.
      W_DOC_DATA-DOC_SIZE =
         W_CNT * 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.
      LOOP AT S_EMAIL.
        T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
        T_RECEIVERS-REC_TYPE = 'U'.
        T_RECEIVERS-COM_TYPE = 'INT'.
        T_RECEIVERS-NOTIF_DEL = 'X'.
        T_RECEIVERS-NOTIF_NDEL = 'X'.
        APPEND T_RECEIVERS.
      ENDLOOP.
      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.                    " SEND_FILE_AS_EMAIL_ATTACHMENT
    *******/form
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       text
    *  -->  p1        text
    *  <--  p2        text
    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
    *********end of code to trigger mail in excel format....
    If any other help please let me know......
    I am sure this example code will help you to resolve your problem...
    please analyse above code for your requirement...
    In my scenario the message you said is not displaying.....
    Reward Points

  • Problems sending an email with a field attached.

    Hi everyone,
    I’m having problems with sending an e-mail (with a field attached) to an external e-mail address.
    I’m using the followings functions:
    <b>'SO_DOCUMENT_INSERT'
    'SO_OBJECT_UPLOAD'
    'SO_ATTACHMENT_INSERT'
    'SO_OBJECT_SEND'</b>
    Everything goes well (the functions are executed well), but the message stacks and it isn’t be sent.
    I can see it with the transaction SBWP, it is in the folder Exit/Documents with status: “Waiting communication service” .
    Then I can send it from there clicking at the button send. And then it is sent.
    Have anyone any clue about what I’ve missed to do.
    I really appreciate your help; I need to solve this problem as soon as possible.
    Kind regards.

    Hai
    report zemail no standard page heading line-size 220.
    data: message_content like soli occurs 10 with header line,
            receiver_list like soos1 occurs 5 with header line,
            w_object_hd_change like sood1.
    start-of-selection.
    Receivers
    receiver_list-recextnam = '[email protected]'.
    receiver_list-recesc = 'E'.
    receiver_list-sndart = 'INT'
    receiver_list-sndpri = '1'.
    append receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    w_object_hd_change-file_ext = 'HTM'. "<--this is important
    Mail subject
    w_object_hd_change-objdes = 'HTML from SAP/ABAP'.
    Mail body
    append 'Message content' to message_content.
    append '<b>How''s this for sending HTML E-mail from SAP?</b>' to
    message_content.
    append '<p>New paragraph</p>' to message_content.
    append '<p>Apostrophe&#8217s</p>' to message_content.
    Call function to send email - SAPConnect needs to be configured
    call function 'SO_OBJECT_SEND'
      exporting
          object_hd_change = w_object_hd_change
          object_type = 'RAW'
          owner = sy-uname
      tables
          objcont = message_content
          receivers = receiver_list.
    2)
    ABAP CODE
    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.
    3)
    DATA: OBJPACK   LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
      DATA: OBJHEAD   LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
      DATA: OBJBIN    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: OBJTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: RECLIST   LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
      DATA: DOC_CHNG  LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
      DATA L_NUM(3).
    Creation of the document to be sent
    File Name
      DOC_CHNG-OBJ_NAME = 'SENDFILE'.
    Mail Subject
      DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
    Mail Contents
      OBJTXT = 'Object text'.
      APPEND OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    Creation of the document attachment
      LOOP AT ITAB_DATA.
        CONCATENATE ITAB_DATA-PRODUCTOR
                    ITAB_DATA-VBELN
                    ITAB_DATA-POSNR
                    ITAB_DATA-MATNR INTO OBJBIN.
        APPEND OBJBIN.
      ENDLOOP.
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = 'ORDERS'.
      APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM   = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM   = TAB_LINES.
      OBJPACK-DOC_TYPE   = 'TXT'.
      OBJPACK-OBJ_NAME   = 'WEBSITE'.
      OBJPACK-OBJ_DESCR  = 'ORDERS.TXT'.
      OBJPACK-DOC_SIZE   = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
    target recipent
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      RECLIST-EXPRESS  = 'X'.
      RECLIST-REC_TYPE = 'U'.
      APPEND RECLIST.
    copy recipents
      clear RECLIST.
      RECLIST-RECEIVER = '[email protected]'.
      RECLIST-EXPRESS  = 'X'.
      RECLIST-REC_TYPE = 'U'.
      RECLIST-COPY     = 'X'.
      APPEND RECLIST.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = DOC_CHNG
           TABLES
                PACKING_LIST               = OBJPACK
                OBJECT_HEADER              = OBJHEAD
                CONTENTS_BIN               = OBJBIN
                CONTENTS_TXT               = OBJTXT
                RECEIVERS                  = RECLIST
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
    ENDFORM.                    " SEND_MAIL
    Thanks & Regards
    Sreeni

  • Sending an email with an XSTRING attachment

    How can I send an email from ABAP with an Attachment that is stored in an XSTRING?
    Regards,
    Javier

    Hi Raja,
    I got a similar requirement.
    I have an ALV report which shows more than 255 characters. I mean, my internal table row contains more than 500 chars.
    I want send the report as Excel attachment in the similar format.
    I was trying but, the table length to send email is 255 per row.. So I did not get about how to do it.
    Can you suggest about how to do it?
    Thanks,
    Sreekanth

  • Sending a email with the form attached but no submit Button

    Hi experts,
    I have designed a form in ABAP using the t-code SFP. i Have a button "accept", in the form.
    Now i am calling this form from an executable program and send it to mail with the form attached.
    I am successfully receiving the mail with the form attach.
    Now my requirement is when i open the attached form and click on ACCEPT button, again a mial shud be triggered with the same form attached but no ACCEPT button shud appear on the form.
    I am able to trigger the mail on click of the ACCEPT button and mail is also sent withj the form attached , but the ACCEPT button still exists.
    I have written the following code on click of the button.
    this.presence = "invisible";
    event.target.submitForm();
    Please some expert help me in solving this problem as soon as possible.
    Thanks and Regards,
    Madhu

    Did you get my point hwta i have mentioned? The steps which I have suggested will solve your problem.
    Please add one dummy attribute (One Char length) to the Form interface.
    In the form add one hidden field - SubmitFlag and bind this to the dummy attribute of the interface. Before submit set this flag to Y.
    On form Load check if Submit Flag is Y or not. if it is then hide the button agin.
    This will work fine for you.
    If after implementing this it will not work, send it to my Id [email protected]
    But first i will suggest to try yourself.
    Cheers
    Satya

  • UTL_SMTP send HTML email with embedded image?

    Hi, I can use UTL_SMTP to send an HTML email ok, but does anyone have an example of how to include an inline embedded image in the email? Thanks!

    If you want to send the html page and have it
    reference the images and css files on your web
    site, that's pretty easy. Just create a message
    with text/html content that is your html page.
    If you want to include all the images and css files
    in your message along with the html page, you'll
    need to create a multipart/related message and
    you'll need to change all the html to reference the
    images and css files using "cid:" references.

  • Send a email with a csv attachment - extension not working!!! please help!!

    DataSource fileDataSource = new FileDataSource(SystemServices.REPORTS_LOC+"mortgage/"+"mortgageleads"+sDF.format(yesterdayDate.getTime())+".csv") {
                public String getContentType() {
                   return "text/csv";
    attachmentList.add(fileDataSource);When the file comes into the email box it comes thru as a .txt file which isnt what i want. could someone help me and tell me how u send it as .csv

    the answer
                                            MimeBodyPart attachmentPart = new MimeBodyPart();
                                DataSource fileDataSource = new FileDataSource(fileLocation);
                             attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                             attachmentPart.setFileName(filename);seems setting the name auto sets the mime type!

  • Want to send a email with images and text in the body of email in iOS

    In iOS, we have written a code to send an email,  with embedded images and text in the body of the email ( not attachment) using mail composer. It works well with iOS devices like iPhone and iPad, but does not work in window based OS. Can anybody help. The code is

    Thanks James !, do you have an idea how to  find the window resource which I belive will be included in our appllication pack.
    In above  I have missed to copy the code,below is the code. This might help you to help me.
    NSMutableString *imgContent = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
    UIImage *imageData = [UIImage imageNamed:@"Midhun.png"];
    NSData *imageDataInBase64 = [NSData dataWithData:UIImagePNGRepresentation(imageData)];
    NSString *base64String = [imageDataInBase64 base64EncodedString];
    [imgContent appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
    [imgContent appendString:@"</body></html>"];
    MFMailComposeViewController *emailWin = [[MFMailComposeViewController alloc] init];
    [emailWin setMessageBody:imgContent isHTML:YES];

  • Can you send an email with multiple photos from iPhoto in reduced size?

    I want to send an email with multiple photos attached with a reduced size. How do I accomplish this?

    Hi Igmatteson,
    If you are using regular Mac Mail, and you are on Mountain Lion, this is what I can do:
    1. Go into Mail, and start a new message
    2. At the top, you will see 4 icons - the third one over brings up the Photo Browser from iPhoto
    3. Go through your pics and select the one you want and drag it onto the mail page
    4. Once you have done that, a small bar on the right-hand side will show up that will allow you to select whether you want the image size to be small, medium, or large. Once you select a size, all photos you add will be that same size.
    Hope this works for you!
    Cheers,
    GB

  • One email with iPhone pic attachment is received multiple times

    Searched the discussions and couldn't find this one. Problem is this:
    My wife takes a picture with her iPhone and goes back to her camera roll to view it. While viewing the picture, she clicks to email the photo. She sends it out to her recipients (one time!), who are happy to get the picture the first time, but not the 3, 4 or 5 times following!
    Any thoughts on what the issue here is? Recipient email addresses are in both Yahoo and AOL, so it can't be blamed on the recipient email server.
    Why are these leaving the outbox multiple times?
    Also, no "multiple sent" issues with emails that don't have pix attached.
    Thanks! -Steve

    I have this exact same problem. After trying to send an email with a picture attached, the person receives it multiple times and then i will get an error on my device, stating that the email did not deliver, when in fact it did, and keeps on sending it a few more times. Between 2 and 5 times each time i send an email with a picture. This was not happening if a picture was not attached.

Maybe you are looking for