Forum Discussion

raskenny's avatar
raskenny
Occasional Contributor
13 years ago

Sending emails with outlook






I am having trouble getting the sample code provided for outlook.js to work. I keep getting the exception  "unable to initialize outlook" . I have office 2007 installed and as soon as i run the script outlook seems to be loading on the task bar but execution stops. Does anyone have the sample script working for them ?

Thanks

7 Replies


  • Hi Kenneth,





    As I understand, you're talking about the sample shipped with TestComplete. If so, try changing the following code in the script file:



    try

    {

      MsOutlook = Sys.OleObject("Outlook.Application");

    }

    catch(exception)

    {

      MsOutlook = Sys.OleObject("Outlook.Application.11"); // <== Use "Outlook.Application.12" instead of "Outlook.Application.11" here

    }







    Does this help?


  • raskenny's avatar
    raskenny
    Occasional Contributor
    Hi Allen

    I still get the same message

    "Unable to initialize MS Outlook"

    "Unable to initialize MS Outlook or its Folders"


  • Hi Kenneth,





    It looks as if the Outlook COM object is not registered properly in your system. Please run regedit.exe via Start | Run... and let me know the value of your HKEY_CLASSES_ROOT\Outlook.Application\CurVer\ registry key.


  • raskenny's avatar
    raskenny
    Occasional Contributor
    I have attached the screen shot for how the outlook Application folder looks like in the registry editor



    Thanks
  • raskenny's avatar
    raskenny
    Occasional Contributor
    Hi, got it to work. All i needed to do was change to the correct folder on my outlook

    From this

    ContactFldr = NS.Folders("Public Folders").Folders("Contacts"); // Original code

    To This

    ContactFldr = NS.Folders("Mailbox - Kenneth Rock").Folders("Contacts"); // Working code




  • sarlcool's avatar
    sarlcool
    Occasional Contributor
    i kind of have the same problem. how did you locate your folders? it seems i cant locate my folders.

    Log.Message(ContactFldr);

    i added that code. but it seems it doesnt show anything.
  • ganadi_k's avatar
    ganadi_k
    New Contributor
    Same Problem I am also facing... Out look is not  initializing ...


    Thanks in advance