Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
When using the visual basic macro to send e-mails via outlook, how can I insert line breaks into the text of the e-mail message so that they appear when the e-mail is sent? When I try and do it by pressing return in the macro, that part of it turns red and does not send. Can you help please? Thanks! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi
Dim strbody As String strbody = "Hi there" & vbNewLine & vbNewLine & _ "This is line 1" & vbNewLine & _ "This is line 2" & vbNewLine & _ "This is line 3" & vbNewLine & _ "This is line 4" Or try this if you want to use cell values Dim cell As Range Dim strbody As String For Each cell In ThisWorkbook.Sheets("Sheet1").Range("C1:C60") strbody = strbody & cell.Value & vbNewLine Next Dim strbody As String With ThisWorkbook.Sheets("Sheet1") strbody = "Hi there" & vbNewLine & vbNewLine & _ .Range("A1") & vbNewLine & _ .Range("A2") & vbNewLine & _ .Range("A3") & vbNewLine & _ .Range("A4") End With Change the Body line to .Body = strbody to use the string. See also http://www.rondebruin.nl/sendmail.htm -- Regards Ron de Bruin http://www.rondebruin.nl "G and (ajk)" wrote in message ... Hi, When using the visual basic macro to send e-mails via outlook, how can I insert line breaks into the text of the e-mail message so that they appear when the e-mail is sent? When I try and do it by pressing return in the macro, that part of it turns red and does not send. Can you help please? Thanks! |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Ron,
I knew you would have the answer to that one. Would using "& Chr(13)" work as well? Thanks, Paul "Ron de Bruin" wrote in message ... Hi Dim strbody As String strbody = "Hi there" & vbNewLine & vbNewLine & _ "This is line 1" & vbNewLine & _ "This is line 2" & vbNewLine & _ "This is line 3" & vbNewLine & _ "This is line 4" Or try this if you want to use cell values Dim cell As Range Dim strbody As String For Each cell In ThisWorkbook.Sheets("Sheet1").Range("C1:C60") strbody = strbody & cell.Value & vbNewLine Next Dim strbody As String With ThisWorkbook.Sheets("Sheet1") strbody = "Hi there" & vbNewLine & vbNewLine & _ .Range("A1") & vbNewLine & _ .Range("A2") & vbNewLine & _ .Range("A3") & vbNewLine & _ .Range("A4") End With Change the Body line to .Body = strbody to use the string. See also http://www.rondebruin.nl/sendmail.htm -- Regards Ron de Bruin http://www.rondebruin.nl "G and (ajk)" wrote in message ... Hi, When using the visual basic macro to send e-mails via outlook, how can I insert line breaks into the text of the e-mail message so that they appear when the e-mail is sent? When I try and do it by pressing return in the macro, that part of it turns red and does not send. Can you help please? Thanks! |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi Paul
Would using "& Chr(13)" work Yes Sub test() Dim strbody As String strbody = "Hi there" & Chr(13) & Chr(13) & _ "This is line 1" & Chr(13) & _ "This is line 2" & Chr(13) & _ "This is line 3" & Chr(13) & _ "This is line 4" MsgBox strbody End Sub You can also send a range or sheet or info you have in a txt file in the body See my site for more info -- Regards Ron de Bruin http://www.rondebruin.nl "PCLIVE" wrote in message ... Hi Ron, I knew you would have the answer to that one. Would using "& Chr(13)" work as well? Thanks, Paul "Ron de Bruin" wrote in message ... Hi Dim strbody As String strbody = "Hi there" & vbNewLine & vbNewLine & _ "This is line 1" & vbNewLine & _ "This is line 2" & vbNewLine & _ "This is line 3" & vbNewLine & _ "This is line 4" Or try this if you want to use cell values Dim cell As Range Dim strbody As String For Each cell In ThisWorkbook.Sheets("Sheet1").Range("C1:C60") strbody = strbody & cell.Value & vbNewLine Next Dim strbody As String With ThisWorkbook.Sheets("Sheet1") strbody = "Hi there" & vbNewLine & vbNewLine & _ .Range("A1") & vbNewLine & _ .Range("A2") & vbNewLine & _ .Range("A3") & vbNewLine & _ .Range("A4") End With Change the Body line to .Body = strbody to use the string. See also http://www.rondebruin.nl/sendmail.htm -- Regards Ron de Bruin http://www.rondebruin.nl "G and (ajk)" wrote in message ... Hi, When using the visual basic macro to send e-mails via outlook, how can I insert line breaks into the text of the e-mail message so that they appear when the e-mail is sent? When I try and do it by pressing return in the macro, that part of it turns red and does not send. Can you help please? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
link to combobox | Excel Discussion (Misc queries) | |||
Compiling macro based on cell values | Excel Discussion (Misc queries) | |||
Mail Merge macro | Excel Discussion (Misc queries) | |||
Closing File Error | Excel Discussion (Misc queries) | |||
Highlight Range - wrong macro, please edit. | Excel Worksheet Functions |