Wednesday, April 9, 2008

Sending fax-emails through RightFax using the COM API...

Captris RightFax is a very funky document delivery system. It will handle the conversion of documents to and from "Fax" ready formats (e.g. TIFF) and send them on. My experience with it has been extremely limited but from what I have seen I am duly impressed. It is built in a modular format so additional modules can be purchased/ignored depending on your particular needs. For instance there is an additional OCR component that can be purchased (albeit for quite a hefty price tag) and snapped into the installation for use. However, I only had the immediate need of only one of the basic features and that was to send a "fax" through the API to an email address.

Using the object model its very simple. Fill in the required email address, add the attachments, and send. This seems to work a treat, however, I was stymied when all the emails I had sent, ended staying in the "Waiting to send" status indefinitely. At first I thought this had to be a setup issue, but using their client, emails could flow fast and furious. I then consulted the documentation for the API which, while it semi-explains everything (its better than nothing I guess), it didn't answer any of the questions I had about anything relevant. I tried every permutation of the sending code as I could think of.

Finally, I stumbled upon the solution out of pure frustration. Here it is in c#:

//assume server is the RightFax server object, and userID is a valid RightFax user
Fax fax = (Fax) server.get_CreateObject2(userID, CreateObjectType.coFax);

fax.IsINLJob = BoolType.True;
fax.ToEmailAddress = "bill@gates.com";
fax.EmailSubject = "RightFax Fax Email...";

fax.IsProductionFax = BoolType.True; // <--- critical
fax.Send(); // <--- critical

The critical two items here, seem to be that you have to set the .IsProductionFax property to BoolType.True and you have to send the fax with the .Send() method. There is a .Save() method that takes a BoolType as a parameter that can be used to perform a similar action to the straight out .Send(). It works with normal faxes, but in the case of an email - no dice.  For the life of me, I can't imagine why these two small things would make a difference nor why its not mentioned in the documentation. And speaking about documentation... this is quoted directly from the official documentation regarding the .IsProductionFax property.

"IsProductionFax
Data type: Boolean Read/Write
Specifies whether or not the fax was generated by the RightFax Production module."

And that's it. Nothing else in the entire document. Not even a *hint* there.

At least I don't feel stupid for missing it the first couple of times around... ;)

No comments: