Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.0.0+

Send an MMS with Twilio using a media URL

See more Twilio Examples

Send an image and an optional caption from an MMS-capable Twilio number. Supply an MMS-supported destination in E.164 format and replace the example media URL with an HTTPS URL Twilio can fetch. The host must handle HEAD and GET and return the correct Content-Type for the file.

Live send. With live credentials and valid inputs, this request submits a billable message. Save the Message SID to check delivery later. Supported media types and size limits.

Twilio Messages API reference

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Assumes Chilkat is unlocked. See Global Unlock Sample.
set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.BasicAuth = 1
'  Load the owning Account SID and an API key from application configuration.
accountSid = "YOUR_ACCOUNT_SID"
http.Login = "YOUR_API_KEY_SID"
http.Password = "YOUR_API_KEY_SECRET"
set url = Server.CreateObject("Chilkat.StringBuilder")
success = url.Append("https://api.twilio.com/2010-04-01/Accounts/")
success = url.Append(accountSid)
success = url.Append("/Messages.json")

'  Add raw field values. Chilkat form-encodes them, including the + in a phone number.
set req = Server.CreateObject("Chilkat.HttpRequest")
req.HttpVerb = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.AddParam "From","YOUR_MMS_ENABLED_NUMBER"
req.AddParam "To","RECIPIENT_E164_NUMBER"
'  Supply a URL for the file itself so Twilio can retrieve the media.
req.AddParam "MediaUrl","https://media.example.com/photo.jpg"
req.AddParam "Body","Photo attached."

set resp = Server.CreateObject("Chilkat.HttpResponse")
set reply = Server.CreateObject("Chilkat.JsonObject")
success = http.HttpReq(url.GetAsString(),req,resp)
If (resp.StatusCode = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Response.End
End If

parsed = reply.Load(resp.BodyStr)
If ((success <> 1) Or (resp.StatusCode <> 201)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "HTTP " & resp.StatusCode) & "</pre>"
    If ((parsed = 1) And (reply.HasMember("code") = 1)) Then
        Response.Write "<pre>" & Server.HTMLEncode( "Twilio error " & reply.IntOf("code") & ": " & reply.StringOf("message")) & "</pre>"
    End If

    Response.End
End If

If (parsed <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response.") & "</pre>"
    Response.End
End If

If ((reply.JsonTypeOf("sid") <> 1) Or (reply.JsonTypeOf("status") <> 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The create response is missing the message SID or status.") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Message SID: " & reply.StringOf("sid")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Initial status: " & reply.StringOf("status")) & "</pre>"

%>
</body>
</html>