help with compile error : syntax error in visual basic I am trying to put a few paragraphs in the body of an outlook email pop up

bleeet

Board Regular
Joined
May 11, 2009
Messages
208
Office Version
  1. 2013
Platform
  1. Windows
hi

i want to put a few paragraphs in the body of an oulook email pop up i created but i get an error once i reach the end of the line. I there a code i have to input to have the top line connect with the bottom line?

for example I have this so far

.body = then i wrote a paragraph to the end oh the line. how do continue on to the next line with out getting the error? i can't put .body= under it like

.body=
.body=

i hope you understand what I am asking

thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
it probably doesn't make sense

but i will try to clarify I created a button to use to pop up the outlook email and I have a few paragraphs i want to have automatically pop up in the body of the email the problem is i get a syntax error once I fill up the line beside the code .body= how can I add more words in the body of the email?

so when I add a lot of words to the .body= line I am unable to type words that go under it to continue my paragraph is there a way i can do it?

for exmaple

.body= words-----------------------------------------------------------------------------------------------------------if I some words here under .body= to continue i get an error

is there a code I have to enter for each line to allow me to add a lot of words in the body of the email?

I hope that helps
 
Upvote 0
Can't you post the actual code?

One way you could do it is to construct the message like this.
Code:
strMsg = "words----------------------------------------------------------------------------------------------------------. " & vbCrLF
strMsg = strMsg & "more words. "
'...
.Body = strMsg

If you don't want a new line don't use vbCrLf.

You could also do this but it can get a bit messy.
Code:
.Body = "words----------------------------------------------------------------------------------------------------------" & _
            "more words."
 
Upvote 0
Can't you post the actual code?

One way you could do it is to construct the message like this.
Rich (BB code):
strMsg = "words----------------------------------------------------------------------------------------------------------. " & vbCrLF
strMsg = strMsg & "more words. "
'...
.Body = strMsg

If you don't want a new line don't use vbCrLf.

You could also do this but it can get a bit messy.
Rich (BB code):
.Body = "words----------------------------------------------------------------------------------------------------------" & _
            "more words."

sorry here is a sampel of the code

Rich (BB code):
With Destwb        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
        On Error Resume Next
        With OutMail
            .SentOnBehalfOfName = "Closing Centre "
        .to = Range("a11").Value
        .CC = ""
        .BCC = ""
        .Subject = "ACTION REQUIRED**
        .Body = I have a lot to write here so when it gets to the next line
                         like this I get that syntax error


            .Attachments.Add Destwb.FullName
            'You can add other files also like this
            '.Attachments.Add ("C:\test.txt")
            .Display   'or use .Send

i hope this helps
 
Upvote 0
Did you try either of my suggestions?
Code:
.Body = "I have a lot to write here so when it gets to the next line " & _
             "like this I get that syntax error"
 
Upvote 0
Did you try either of my suggestions?
Code:
.Body = "I have a lot to write here so when it gets to the next line " & _
             "like this I get that syntax error"

thanks this works perfect :)

but one problem how do I space the words after the "& _" because the words are connected when i put it in after the code
 
Last edited:
Upvote 0
Put space(s) in the string(s).
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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