title: How can I send a fax for a pdf from a Windows Service using FAXCOMEXLib?
body: <p>I've seen this question asked before, but I have not seen any definite answers, and definitely not any answers that solve my problem. I created a windows service to send faxes (semi-automatically) using the FAXCOMEXLib library. So far, my service has been successful at sending text files (.txt). But when I try to send pdf, jpg, or tif files, I get the &quot;Operation failed&quot; error. In SO, I've seen a lot of discussion about the permissions of the user that the service is running under. I've tried a lot of different options (Local Service, Local User, custom user with admin privileges, allow service to interact with desktop). But nothing seems to make a difference. It seems that the service does not have permissions to open the appropriate app to &quot;print&quot; the pdf, jpg, or tif file. But I am only speculating. Has anyone been successful in sending a fax through FAXCOMEXLib in a Windows service? Here is my code that sends the fax:</p>
  <pre><code>fileName = @&quot;D:\temp\FaxTest.txt&quot;; //THIS WORKS
  //fileName = @&quot;D:\temp\FaxTest.pdf&quot;; //Operation failed
  //fileName = @&quot;D:\temp\FaxTest.tif&quot;; //Operation failed
  faxDoc.Sender.Name = faxRec.From;
  faxDoc.Sender.Company = faxRec.From;
  faxDoc.Body = fileName;
  faxDoc.Subject = faxRec.ReferenceId;
  faxDoc.DocumentName = faxRec.ReferenceId;
  var to = &quot;xxxxxxxxxx&quot;;
  faxDoc.Recipients.Add(to, &quot;Some Name&quot;);
  var serverName = Environment.MachineName;
  string[] returnVal = faxDoc.Submit(serverName);
  </code></pre>
  <p>In case you're wondering, yes, those files do exist on the server with those names, and they are valid files (I can open them up in Adobe Reader and Picture Viewer). And this also works just fine if I run this locally on my dev machine. And of course, the appropriate viewer pops up before sending (on my local machine). My guess is that for some reason the service cannot open the viewer. Has anyone been successful sending a PDF this way in a Windows service?</p>