PDA

View Full Version : [SOLVED:] Need add text Wrap in Mail Body Message in current VBA code



hemant.83son
09-19-2014, 05:46 AM
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:banghead: 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
---------------------------

westconn1
09-20-2014, 02:28 AM
you could try

.HTMLBody = replace(.Body & RangetoHTML(rngToCopy), vbcrlf, "<br>")

gmayor
09-20-2014, 04:09 AM
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

hemant.83son
09-21-2014, 11:35 PM
Hi Graham


Thanks For your help.

VBA Express always rocks


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

johara
09-15-2023, 08:47 AM
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.

gmayor
09-15-2023, 09:00 AM
I have tested your workbook and it works for me.

johara
09-15-2023, 04:39 PM
its work for me like charms! thanks sooo much for your help :clap::cloud9: