How to break the line in a string in VBA?

Asked

Viewed 7,301 times

0

I’m having a hard time putting a line break inside an automated email text by macro.

I create the e-mail with the following Cód:

    "Necessitamos dos extratos do mês de " & Format((Month(Now) - 1), "mmm") & " das seguintes contas: " & vbNewLine & _
    vbNewLine & "  Empresa: " & empresa1 & "  CNPJ: " & cnpj1 & vbNewLine & _
    tipoConta & vbNewLine & "  Conta: " & conta1 & "  Agência:  " & agencia1 & _
    vbNewLine & "  Empresa: " & empresa2 & "  CNPJ: " & cnpj2 & vbNewLine & _
    tipoConta & " : " & vbNewLine & "  Conta: " & conta2 & "  Agência:  " & agencia2 & _
    vbNewLine & _
    vbNewLine & _
    vbNewLine & _
    "<FONT SIZE = 1.1><b>Essa mensagem foi gerada automáticamente e pode conter dados privados.</p></b>" & vbNewLinee & _
    "<FONT SIZE = 1><b>E-mail gerado por Amadeu Gustavo | 55 5555-5555</p></b>"

I put the key after the line break to better visualize

and the generated email respects only one of the line break commands: inserir a descrição da imagem aqui

  • Is your email being sent as? HTML or Text? If it is with .HtmlBody, you should use html line breaks, such as <br>

  • worked well! if it is in text, I use the command vbnewline?

  • I’ve never done it in text, but I think it would work. Or use Chr(10) which is the vbLf or the Chr(13) which is the vbCr

  • beauty! thank you!

1 answer

-4

Use the tag <br> for line breaking because email accepts simple html. Another alternative is to use ansi code "essa parte nao sei se vai funcionar" chr(13) which is equal to enter.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.