Skip to main content
Question

Sending PDF through fax with C#

  • August 25, 2019
  • 2 replies
  • 3496 views

Hi,

I am exploring ringcentral fax. I want to send PDF file attachment with rc fax through C# code.

Any example or pointer will be a great help

Thanks

2 replies


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • August 25, 2019

Instead of using the c-sharp SDK, which is obsolete, I recommend you to use the latest .Net SDK. And follow the example code below to send a fax.

// set the last param to true for production
RestClient rc = new RestClient("clientId", "clientSecret", false);
await rc.Authorize("username", "extensionNum", "password");
if (rc.token.access_token.Length > 0)
{
  var requestParams = new CreateFaxMessageRequest();
  var attachment = new Attachment { fileName = "test.jpg", contentType = "image/jpeg", bytes = System.IO.File.ReadAllBytes("test.jpg") };
  var attachments = new Attachment[] { attachment };
  requestParams.attachments = attachments;
  requestParams.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = RECIPIENT } };
  requestParams.faxResolution = "High";
  requestParams.coverPageText = "This is a demo Fax page from C#";
  var resp = await rc.Restapi().Account().Extension().Fax().Post(requestParams);
  Console.WriteLine("Fax sent. Message status: " + resp.messageStatus);