Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: 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

  1. #1
    Board Regular
    Join Date
    May 2009
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default 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

    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

  2. #2
    Board Regular
    Join Date
    May 2009
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 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

    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

  3. #3
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    74,492
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    3 Thread(s)

    Default Re: 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

    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."
    If posting code please use code tags.

  4. #4
    Board Regular
    Join Date
    May 2009
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 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

    Quote Originally Posted by Norie View Post
    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."
    sorry here is a sampel of the code

    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

  5. #5
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    74,492
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    3 Thread(s)

    Default Re: 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

    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"
    If posting code please use code tags.

  6. #6
    Board Regular
    Join Date
    May 2009
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 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

    Quote Originally Posted by Norie View Post
    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 by bleeet; Jan 17th, 2013 at 10:06 AM.

  7. #7
    Board Regular
    Join Date
    May 2009
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: 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

    bump so you can hopefully see this Norie

  8. #8
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    74,492
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    3 Thread(s)

    Default Re: 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

    Put space(s) in the string(s).
    If posting code please use code tags.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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