Question

Sending PDF through fax with C#

  • 25 August 2019
  • 2 replies
  • 3353 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

There are many way to do this with C# is to use (alpha) SDK which is available on Nuget and GitHub:

Check these reference: https://forums.developers.ringcentral.com/questions/8025/can-we-insert-a-pdf-document-to-a-fax-using-c.html

https://forums.developers.ringcentral.com/questions/1196/internal-server-error-sending-multiple-fax-c-net.html

https://forums.developers.ringcentral.com/idea/332/new-webhooks-and-fax-demos.html

Userlevel 1

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);

Reply