Forum Discussion

DevaV's avatar
DevaV
Contributor
14 years ago

Sending mail from java script

Hi,

I want to send mail from java-script and I use the following code in test-complete it throws exception while creating ActiveXObject for Outlook.Appliction. Code is given below



function SendMail()

{

    var theApp   

    var theMailItem

    var subject = "Email Using JavaScript"

    var msg = "This is a test mail,sent to you using javascript by kushan thakershy"

    try

    {

         var theApp = new ActiveXObject("Outlook.Application")

            

    var theMailItem = theApp.CreateItem(0)

    theMailItem.to = "deva.vgd@gmail.com"

    theMailItem.Subject = (subject);

    theMailItem.Body = (msg);

    theMailItem.display()

    }

    catch(err)

    {

    Log.Message(err)

    }

}





Kindly give some suggestions for this.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Have you tried using the BuiltIn.SendMail function?  You might not need to create a whole new function for it.



    http://smartbear.com/support/viewarticle/13276/



    Also, since there is already a "SendMail" function, could you perhaps be running the risk of having two functions with the same name?  I'm not sure if that will create the error you're reporting but it's possible that there's a conflict between the two.