Forum Discussion

Nikhil_Mcafee's avatar
Nikhil_Mcafee
New Contributor
13 years ago

email's are not getting sent. URGENT !!!!


Hi All



I am trying to send an email with an attachment using the script which in present in smartbear support artical, but the amils are not getting sent atall. The script executes successfully but no emails are getting sent.Please find the script below.




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





Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)

  Dim smtpServer, portNumber, userName, userPassword

  Dim useAutentification, useSSL, connectionTimeout

  Dim schema, mConfig, mMessage

  

  smtpServer = "smtp.gmail.com"

  smtpPort = 465

  userLogin = "XYZ@gmail.com" ' e.g. abc@gmail.com

  userPassword = "Password"

  autentificationType = 1 ' cdoBasic

  connectionTimeout = 30

  ' Required by GMail

  useSSL = True

  

  Err.Clear()

  On Error Resume Next

 

  schema = "http://schemas.microsoft.com/cdo/configuration/"

  Set mConfig = Sys.OleObject("CDO.Configuration")

  mConfig.Fields.Item(schema & "sendusing") = 2 ' cdoSendUsingPort

  mConfig.Fields.Item(schema & "smtpserver") = smtpServer

  mConfig.Fields.Item(schema & "smtpserverport") = smtpPort

  mConfig.Fields.Item(schema & "sendusername") = userLogin

  mConfig.Fields.Item(schema & "sendpassword") = userPassword

  mConfig.Fields.Item(schema & "smtpauthenticate") = autentificationType

  mConfig.Fields.Item(schema & "smtpusessl") = useSSL

  mConfig.Fields.Item(schema & "smtpconnectiontimeout") = connectionTimeout

  mConfig.Fields.Update() 

 

  Set mMessage = Sys.OleObject("CDO.Message")

  Set mMessage.Configuration = mConfig

  mMessage.From = mFrom

  mMessage.To = mTo

  mMessage.Subject = mSubject

  mMessage.HTMLBody = mBody

 

  If 0 < Len(mAttachment) Then

    mMessage.AddAttachment(mAttachment)

  End If

 

  mMessage.Send()

 

  If Err.Number > 0 Then

    Call Log.Error("E-mail cannot be sent", Err.Description)

    SendEMail = False

    Err.Clear()

  Else

    Log.Message("Message to <" & mTo & "> was successfully sent")

    SendEMail = True

  End If

End Function


With Regards

Nikhil C. Indurkar

12 Replies

  • Hi Support,



    I am not getting an email when the test is failed, i am getting emails when test is passed? here is the code i am using,




    'USEUNIT SendMail


    Sub Add_Node()


      'Runs the "TestedApp1" tested application.


      Call TestedApps.TestedApp1.Run


      'Enters 'UA[Tab]' in the 'e_user' object.


      Call Aliases.rmsgui.LoginDialog.frame.e_user.Keys("UA[Tab]")


      'Enters 'ua1234[Enter]' in the 'e_password' object.


      Call Aliases.rmsgui.LoginDialog.frame.e_password.Keys("ua1234[Enter]")


      'Clicks the 'FIRM' item in the 'Node Path' column of the 'nodeContainerWidget' tree.


      Call Aliases.rmsgui.MainWindow.centralwidget.splitter.widget.nodeContainerWidget.ClickItem("FIRM", "Node Path")


      'Clicks the 'FIRM' item in the 'Node Path' column of the 'nodeContainerWidget' tree with the right mouse button.


      Call Aliases.rmsgui.MainWindow.centralwidget.splitter.widget.nodeContainerWidget.ClickItemR("FIRM", "Node Path")


      'Moves the mouse cursor to the menu item specified and then simulates a single click.


      Call Aliases.rmsgui.Menu.QtMenu.Click("Create Account")


      'Drags from point (54, 10) of the 'LineEdit' object to offset (-134, -8).


      Call Aliases.rmsgui.AddBranchDialog.comboBox.LineEdit.Drag(54, 10, -134, -8)


      'Enters 'ACCT1[Enter]' in the 'comboBox' object.


      Call Aliases.rmsgui.AddBranchDialog.comboBox.Keys("ACCT1[Enter]")


      Call SendMail_Test


    End Sub



    It's generating mails only when test is passed. Please, advice or post me the approprieate code to generate e-mails on test failure.



    Thanks,

    Niladri