How to insert line break for send whatsapp message using vb.net

Thisara Udayanga 21 Reputation points
2022-07-30T16:17:20.2+00:00

I want to send whatsapp message like below using VB.net

LAUNDRY HOMES
Invoice Number : 100006
Invoice Date : 07/30/2022

I have used following code but its not line breaking in whatsapp
Dim web As New WebBrowser

Dim strMessage As String

strMessage = LblCompany.Text & Environment.NewLine & "Invoice Number : " & txtInvoiceno.Text & Environment.NewLine & "Invoice Date : " & DtInvdate.Value.ToString("MM/dd/yyyy") & ""

web.Navigate("whatsapp://send?phone=" & txtcontact.Text & "&text=" & strMessage & "")

Help me how to do line break.

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,733 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Sreeju Nair 12,361 Reputation points
    2022-07-30T17:20:16.283+00:00

    To send the linebreak, try using %0a
    e.g.

    strMessage = LblCompany.Text & "%0a" & "Invoice Number : " & txtInvoiceno.Text & "%0a" & "Invoice Date : " & DtInvdate.Value.ToString("MM/dd/yyyy") & ""  
    web.Navigate("whatsapp://send?phone=" & txtcontact.Text & "&text=" & strMessage & "")  
    
    1 person found this answer helpful.

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. huraiz 0 Reputation points
    2024-08-02T14:16:40.0633333+00:00

    To add line breaks in your WhatsApp message via FM Whatsapp, use %0A instead of Environment.NewLine. Update your strMessage like this:

    vb

    Copy code

    strMessage = LblCompany.Text & "%0AInvoice Number : " & txtInvoiceno.Text & "%0AInvoice Date : " & DtInvdate.Value.ToString("MM/dd/yyyy")

    Then, use this updated message format in your web.Navigate method. This should correctly display the line breaks in the WhatsApp message.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.