2

I want to know that how I can send formated messages through twilio .net api

Using .net library

So my requirements are like. also can I make use of html tags?

TwilioRestClient client;
            client = new TwilioRestClient(accountSID, authToken);
            string msg="Hi dalvir,
//line break

Welcome to my website.....
....


//line break

Thanks
<b>Support Team<b>


";
            // Send an SMS message.
            Message result = client.SendMessage(....);
Cœur
  • 37,241
  • 25
  • 195
  • 267
Dalvir Singh
  • 423
  • 3
  • 11
  • 25

2 Answers2

1

Use %0a

For example:

"Body=Here is my first line%0aHere is my second line"

When sending outbound messages via the REST API without using a helper library, it is best to encode a new line character using URL encoding. In URL encoding, a new line character is encoded as %0a.

Here’s an example cURL script:

curl -XPOST https://api.twilio.com/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages.json \
-d "To=+13105551234" \
-d "From=+12125555555" \
-d "Body=Here is my first line%0aHere is my second line" \
-u 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token' 

This example sends an outbound message from the sender (212) 555-1234 (+12125551234) to the recipient at (310) 555-5555 (+13105555555), and includes the following message:

Here is my first line
Here is my second line

WLM2020
  • 36
  • 2
0

Twilio developer evangelist here.

You can absolutely add line breaks in SMS messages. You can do so in the way you would normally include line breaks within .NET.

SMS messages do not support HTML tags though, so making text bold is not possible.

philnash
  • 70,667
  • 10
  • 60
  • 88