Add Fax functionality to your VBA programs

Send free faxes from your VBA programs using web APIs.

A very simple call to WebserviceX.net's free fax API lets you send simple faxes for free to a number of countries. You are limited in the amount of text you can send, but it's worth it for the price if your target area code is supported. The function returns True if the fax was sent.

Function SendFax(fromEmail As String, subject As String, faxNumber As String, _
  bodyText As String, toName As String) As Boolean
' See http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=23
' for coverage and detailed usage instructions

Dim xml As Object
Dim result As String

  Set xml = CreateObject("MSXML2.XMLHTTP")

  xml.Open "GET", _
      "http://www.webservicex.net/fax.asmx/SendTextToFax?FromEmail=" & _
      fromEmail & "&Subject=" & subject & "&FaxNumber=" & faxNumber & _
      "&BodyText=" & bodyText & "&ToName=" & toName, False
  xml.Send

  result = xml.responsetext
 
  ' parse response for msg
 If InStr(result, "Your Message has sent successfully") > 0 Then
    SendFax = True
  End If

End Function

Sample usage

Pass the following parameters to the function above. Can be used in any VBA-supported program.

  • Your email address
  • The subject of the fax
  • The fax number (no leading zeros, dashes or spaces)
  • The text of the fax
  • Your name
Sub TestSendFax()

MsgBox SendFax("your_email@somewhere.com", "Your subject", "12121234567", "Your Body Text", "Your Name")

End Sub

Site last updated July 26, 2010 @ 8:14 pm