Word Wrapping as though and normal email

irishr_ram

New Member
Joined
Jul 16, 2013
Messages
10
Hi All,

I have some VBA which sends a report via email using the below code but unlike a normal email you have this one does not wrap the text when the email window in outlook is reduced or increased in size.

Code:

With ActiveSheet.MailEnvelope
.Item.To = "xxx@xxx.com"
.Item.Cc = "xxx@xxx.com"
.Item.Subject = Worksheets("Dashboard Data").Range("C2").Value & " - " & Worksheets("Dashboard Data").Range("C3").Value & " - " & Worksheets("Dashboard Data").Range("C5").Value & " - " & "Weekly Report"
.Item.Send
End With

Is there a way to get the email sent through (which is just text and not any fancy boxes or formatting etc) so that is will auto adjust the text to fit the outlook email window size for example when viewing on a phone or laptop etc?

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I have never used MailEnvelope and it may only be capable of sending HTML mail, which means it will use fixed sized tables for the data.

If it has the ability to send a text format mail that should work.

Failing that If you have Outlook then you could try the following basic code to see if that suits:
.Body sends the mail as Text and you may need to enter a vbNewline between each range otherwise the content of the 3 ranges is all in one single line (wrapped of course)

Code:
Sub Mail_test()

MailBody = Worksheets("Dashboard Data").Range("C2").Text & " - " & Worksheets("Dashboard Data").Range("C3").Text & " - " & Worksheets("Dashboard Data").Range("C5").Text & " - " & "Weekly Report"

   Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(o)
        With OutMail
            .Subject = EmailSubject
            .To = "EmailTo"
            .Cc = ccTo
            .Body = MailBody
            .Display 'Change to .Send once tested to your satisfaction
End With

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top