none
Outlook.Application ActiveX - send() sometimes hangs long with hourglass turning and eventually fails RRS feed

  • Question

  • We have a JavaScript piece of code, that sends an email via Outlook.Application Active X, utilizing its Send() method. Sometimes it works lovely, and sometimes Send() hangs with windows hourglass turning for long time, eventually failing.

    There's no apparent reason to this behavior. Since it occurs within Send() method of this off the shelf Active X, and it hangs there waiting for long time, till it fails on this too long wait, there's no immediate error message that can reflect what happened.

    Can u pls advise how to find out why this happens ? Is there some technical log / debugging tool, we can use to probe the active x behavior for reasoning of such case ?


    • Edited by moital Monday, August 3, 2015 9:26 PM
    Monday, August 3, 2015 9:25 PM

Answers

  • Outlook Security Manager is a standalone software (library) which should be installed on the client PC (not an add-in). It can be used in add-ins and standalone software which automates Outlook.

    I don't see any other reasons that may cause the issue. Typically the Send method triggers security popups in Outlook when you automate it from external applications (out of process).

    Consider using another ways for sending emails. For example, you may consider using the server-side code which may use System.Net namespace classes instead.  

    • Marked as answer by moital Tuesday, August 4, 2015 10:39 AM
    Tuesday, August 4, 2015 9:03 AM

All replies

  • Hello,

    What code exactly do you use?

    Most probably you get a standard security prompt in Outlook. See Outlook "Object Model Guard" Security Issues for Developers for more information. 

    Monday, August 3, 2015 10:08 PM
  • Hi moital,

    What's the code are you developing with? As far as I test, the code below works well for me:

    function SendMail(to,body,sub) { var theApp var theMailItem var theApp = new ActiveXObject("Outlook.Application") var theMailItem = theApp.CreateItem(0) theMailItem.to = to theMailItem.Subject = (subject); theMailItem.Body = (msg);

    //theMailItem.display() theMailItem.send() }

    I suggest that you display the MailItem via the display method to see wheter is any message blog sending email.

    Reagrds & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 4, 2015 2:46 AM
    Moderator
  • Hi,

    Thank u for your response, attached pls find below, the JavaScript routine that sends the email. We can omit the attachments part cause not used in practice in specific case if that what' is causing the warning, also I see u use theMailItem.Body whereas we use SendMail.HTMLBody to be later filled with a string, any reason to use your selection in preference to ours ?

    Do u identify something that might trigger the warning ?

    Can u please send or refer me in any case, to an example code in JavaScript that disables/enables the warning on the active X ? The example u kindly referred to me are in C, VBA.

    Would appreciate also if u could refer me to some article or solution in general how to analyze a case where an off the shelf product hangs, with no apparent error. That could be beneficial for future events and general knowledge.

    Candid thx.

    /****************************************sendmail***********************/ 
    function SendMail(EmailFrom, FromName, EmailTo, Subject, HTMLBody, Path, FileName1, FileName2)
    {


    var olMailitem   = 0;
    var olByValue    = 1; 

      var OutLookApp = new ActiveXObject("Outlook.Application"); 
      var SendMail   = OutLookApp.CreateItem(olMailitem);
    SendMail.To      = EmailTo;
      SendMail.Subject = Subject;
      SendMail.HTMLBody    = "";
    //  SendMail.Attachments ;
      SendMail.Send();   
    }




    • Edited by moital Tuesday, August 4, 2015 5:22 AM
    Tuesday, August 4, 2015 5:01 AM
  • Hello,

    Try removing the Send method call from the code. Do you get any frozen state in that case? 

    I'd recommend trying to figure out the line of code which may cause the issue first. If it is the Send method - you get a standard security prompt in Outlook. It may not be visible, you can simply may get an exception in the code. All possible way for avoiding such issues are described in the Outlook "Object Model Guard" Security Issues for Developers article.

    Tuesday, August 4, 2015 7:03 AM
  • Hi,

    We've already debugged the code to find out that the frozen state occurs when the Send method is run, i.e. the problem is something to do with the send itself.

    We also noticed now that upon send a quick short notification appears in the windows tray, with an outlook icon and text implying that a program is holding outlook. It might be that the program is our send, maybe it is something else ?!

    As per your suggestion to implement outlook unnecessary security alert, before send and re-apply it afterwards, we'd love try but need code example in JavaScript. Can u pls provide us with such code (not in VBA . C#) ?

    Kind thx,

    Tuesday, August 4, 2015 7:39 AM
  • You may find the sample code on the Outlook Security Manager web site. I suppose you need to use the ActiveX edition.
    Tuesday, August 4, 2015 8:04 AM
  • It seems that Outlook Security Manager is an add-in that needs to be downloaded and installed on client, in order to use it. If so, we would need to install it on all our client computers. I personally can't find this add-in in the list of installed add-ins in my own outlook.

    Is this correct ? If so, what can we thus do to resolve the problem. ?

    Can it be that the frozen state results from something else ? Kindly let us know how to find out what causes the problem on the PC. We'd like to use some trace / log / etc... to pin point the problem.

    Tuesday, August 4, 2015 8:15 AM
  • Outlook Security Manager is a standalone software (library) which should be installed on the client PC (not an add-in). It can be used in add-ins and standalone software which automates Outlook.

    I don't see any other reasons that may cause the issue. Typically the Send method triggers security popups in Outlook when you automate it from external applications (out of process).

    Consider using another ways for sending emails. For example, you may consider using the server-side code which may use System.Net namespace classes instead.  

    • Marked as answer by moital Tuesday, August 4, 2015 10:39 AM
    Tuesday, August 4, 2015 9:03 AM
  • thank u kindly for your answer. we'll consider how to proceed and advise with u as relevant..
    • Edited by moital Tuesday, August 4, 2015 10:40 AM
    Tuesday, August 4, 2015 10:40 AM