I am trying to attach a pdf to a fax that i am sending using code below
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
Stream rs = wr.GetRequestStream();
StreamReader sr = new StreamReader(filepath);
byte[] fileStream = ReadFully(sr.BaseStream);
rs.Write(fileStream, 0, fileStream.Length);
sr.Close();
public static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[20 * 1024];
using (MemoryStream ms = new MemoryStream())
{
if (input != null)
{
int read;
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
}
return ms.ToArray();
}
}
I get back the response that Fax was Queued, but when I receive fax it is only default cover page. This mean the binary data was not attached. What am I missing?