Consulting

Results 1 to 7 of 7

Thread: Need add text Wrap in Mail Body Message in current VBA code

  1. #1

    Need add text Wrap in Mail Body Message in current VBA code

    Hi

    Attached here Mail_Outlook_ xlam file. This macro works fine.But in Message Column when i entered wrap text still it comes in single line for example; If I write in Message
    Hi

    Please find attached here credit memo.

    Thanks

    When i run macro it creates a single Line like : Hi Please find attached here credit memo. Thanks

    Can you please do the changes in it it will be veryhelpful

    Thanks
    ---------------------------
    Attached Files Attached Files

  2. #2
    you could try
    .HTMLBody = replace(.Body & RangetoHTML(rngToCopy), vbcrlf, "<br>")

  3. #3
    The best way to handle this is to access the body of the message directly. The attached is modified to do that. Then the conversion of data to HTML and the need to faff around with signatures, when the signature was already in the message body before you started to process the message, is no longer required.

    You can either write the content of the required cells directly or you can copy and paste it into a range, thereby leaving the signature in place. The multi-line cell needs no further processing when using this method, though you can treat it exactly as you would process a Word document from VBA

    As your workbook didn't have the data range to be inserted (apart from the message you quoted) it was not possible to test the insertion of that, but it should be equally straightforward e.g. after the line

    oRng.collapse 0 'collapse end

    you could identify the range to be copied and paste it into the message range. This will insert the table as it is formatted in Excel. e.g.

    Range("N2:O4").Copy
    oRng.Paste
    Attached Files Attached Files
    Last edited by gmayor; 09-20-2014 at 05:08 AM.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  4. #4
    Hi Graham


    Thanks For your help.

    VBA Express always rocks


    Thanks
    ------------------------

  5. #5
    VBAX Newbie
    Joined
    Sep 2023
    Posts
    3
    Location

    Please help to edit my code

    Hello gmayor, thanks for your reply. I am not able to run the macro, got some error in the coding. Can you help? I put some data for your testing.
    Attached Images Attached Images
    Attached Files Attached Files

  6. #6
    I have tested your workbook and it works for me.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  7. #7
    VBAX Newbie
    Joined
    Sep 2023
    Posts
    3
    Location
    its work for me like charms! thanks sooo much for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •