Sign in to follow this  
Followers 0
TMXOD

Help with COM Objects

9 posts in this topic

I started work on a Email-to-Fax gateway powered by Mozilla Thunderbird+Attachment Extractor, PDFCreator, and AutoIt. The general flow of the program is as following:

(Client side)

  • User types in destination fax number
  • User types in destination name
  • user types the file whose contents are to be faxed
  • user types in notification email address
  • File is converted to PDF using PDFCreator using the following constraints (to allow for weird files, like CAD drawings or propietary image formats, which the server may not be able to decode):

    • Color: Grayscale
    • Paper Size: Letter
    • Resolution 200dpi
  • fax descriptor file is created

    • file name to fax
    • destination name
    • destination number
    • notification email address
    • installation-unique confirmation code (avoid spam)
  • fax descriptor and PDF files are attached to an email message containing a specially-crafted subject (avoid accidentally sending spam through fax)
  • message is sent using MAPI

(server side, when a message is received)

  • if the message has the specific subject, continue; else abort
  • extract attached PDF and fax descriptor from received email
  • read information from file descriptor, abort if confirmation code invalid
  • fax is sent using local COM Object
  • user is emailed when fax is sent or an error occurs

I'm having problems with the actual sending of the fax. I'm going from what I found at this page. The VBScript works, when adapted to my test, but what I think is an accurate translation to AutoIt does not. The code is:

Dim $faxServer = ObjCreate("FAXCOMEX.FaxServer")
If @error <> 1 And IsObj($faxServer) Then
  $faxServer.Connect ("")
  Dim $faxDoc = ObjCreate("FAXCOMEX.FaxDocument")
  If @error <> 1 And IsObj($faxDoc) Then
    With $faxDoc
      .Body = @ScriptFullPath
      .DocumentName=@ScriptName & " source"
      .Recipients.Add("5555555555") ; hiding actual destination phone number
      .Sender.Email="root@localhost.com" ; hiding actual email address
      .Sender.Name="ME" ; hiding actual name
      .Sender.FaxNumber="5555555555" ; hiding actual home phone number
    EndWith
    $faxServer.Folders.OutgoingQueue.Branding=False
    $faxServer.Folders.OutgoingQueue.Save()
    Dim $jobid=$faxdoc.ConnectedSubmit($faxServer) ;<--AHK
    ConsoleWrite("Finished -- JOB ID: " & $jobid & @CRLF)
  EndIf
EndIf

The error occurs in line 16 (the one marked as "<--AHK"). The error message is "The requested action with this object has failed." I think the problem is how I'm passing one object as the parameter to ConnectedSubmit. Am I doing this right? or do I need to do this differently?

Share this post


Link to post
Share on other sites



I'd try taking all the Dims out of there and see if that helps...

Share this post


Link to post
Share on other sites

I started work on a Email-to-Fax gateway powered by Mozilla Thunderbird+Attachment Extractor, PDFCreator, and AutoIt. The general flow of the program is as following:

(Client side)

  • User types in destination fax number
  • User types in destination name
  • user types the file whose contents are to be faxed
  • user types in notification email address
  • File is converted to PDF using PDFCreator using the following constraints (to allow for weird files, like CAD drawings or propietary image formats, which the server may not be able to decode):

    • Color: Grayscale
    • Paper Size: Letter
    • Resolution 200dpi
  • fax descriptor file is created

    • file name to fax
    • destination name
    • destination number
    • notification email address
    • installation-unique confirmation code (avoid spam)
  • fax descriptor and PDF files are attached to an email message containing a specially-crafted subject (avoid accidentally sending spam through fax)
  • message is sent using MAPI

(server side, when a message is received)

  • if the message has the specific subject, continue; else abort
  • extract attached PDF and fax descriptor from received email
  • read information from file descriptor, abort if confirmation code invalid
  • fax is sent using local COM Object
  • user is emailed when fax is sent or an error occurs

I'm having problems with the actual sending of the fax. I'm going from what I found at this page. The VBScript works, when adapted to my test, but what I think is an accurate translation to AutoIt does not. The code is:

Dim $faxServer = ObjCreate("FAXCOMEX.FaxServer")
If @error <> 1 And IsObj($faxServer) Then
  $faxServer.Connect ("")
  Dim $faxDoc = ObjCreate("FAXCOMEX.FaxDocument")
  If @error <> 1 And IsObj($faxDoc) Then
    With $faxDoc
      .Body = @ScriptFullPath
      .DocumentName=@ScriptName & " source"
      .Recipients.Add("5555555555") ; hiding actual destination phone number
      .Sender.Email="root@localhost.com" ; hiding actual email address
      .Sender.Name="ME" ; hiding actual name
      .Sender.FaxNumber="5555555555" ; hiding actual home phone number
    EndWith
    $faxServer.Folders.OutgoingQueue.Branding=False
    $faxServer.Folders.OutgoingQueue.Save()
    Dim $jobid=$faxdoc.ConnectedSubmit($faxServer) ;<--AHK
    ConsoleWrite("Finished -- JOB ID: " & $jobid & @CRLF)
  EndIf
EndIf

The error occurs in line 16 (the one marked as "<--AHK"). The error message is "The requested action with this object has failed." I think the problem is how I'm passing one object as the parameter to ConnectedSubmit. Am I doing this right? or do I need to do this differently?

It looks straight to me. The DIM's are irrelevant (I would prefer just declaring GLOBAL's at the top, but that's just preference). Add a COM Error handler as under the OBJ/COM Reference section of the help file. That will get you more detail on the error.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You may also want to look for a working example in another language (like VBScript) to use as a template. If you have such a thing you can also post it here for reference.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You may also want to look for a working example in another language (like VBScript) to use as a template. If you have such a thing you can also post it here for reference.

Dale

I think he did. I've never used that object so I Googled "FAXCOMEX.FaxServer" and compared his AutoIt code to the VBScript examples that showed up. I can't see any problem with his translation just by visual inspection.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Ah, of course... I missed that link.

How about adding a COM error handeler to see if you can get more info from the erro object? An easy way to do this is to add this to your code:

#include <IE.au3>

_IEErrorHandlerRegister()

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I'm having the same problem. Any solution yet?

Share this post


Link to post
Share on other sites

I'm having the same problem. Any solution yet?

We never got an answer from the OP after asking him (twice!) to try it with a COM error handler to get more details. Did you try that? What results did you get?

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I'm not sure this is how it works... but I attached the error handler, and it spat out...

Number is: 80020009

Windescription is: No application is associated with the specified file for this operation.

Of course if it could be done from a per-user basis, like mine... I would assume you guys would have already done that.

Since I'm usually wrong, I'd also assume this is a 'personal' user-based error... :P I don't have the app that works with that Object...

If I was no help, I was bored and gave it a shot, please don't yell... :D

If that helped, +1 to boredom... :unsure:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0