Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fucntion to send mail in outlook works fine in qtpcode but does not work in .vbs
#3
Solved: 11 Years, 3 Months, 2 Weeks ago
Hi,

Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
  Dim strSubject As String
  strSubject = Item.Subject
  If Len(strSubject) = 0 Then
      Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
      If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
              Cancel = True
      End If
  End If
End Sub
Sub GetFormPassword()
    Dim objApp As Application
    Dim objInsp As Inspector
    Dim objFD As FormDescription


    Set objApp = CreateObject("Outlook.Application")
  
    Set objInsp = objApp.ActiveInspector
    If Not objInsp Is Nothing Then
        Set objFD = objInsp.CurrentItem.FormDescription

        MsgBox _
          Prompt:="The password for the " & _
                  Chr(34) & objFD.MessageClass & _
                  Chr(34) & " form is:" & _
                  vbCrLf & vbCrLf & objFD.Password, _
          Title:="Get Form Password"


    Else

        MsgBox _
          Prompt:="Please open an item using " & _
                  "the desired form before you " & _
                  "run the GetFormPassword macro.", _
          Title:="Get Form Password"

    End If
End Sub
Private Sub Application_NewMail()
    
    Dim m As MailItem
    Dim f As MAPIFolder
    Dim a As Attachment
    Set m = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items.GetLast
    Debug.Print m.Subject
    For Each a In m.Attachments
        a.SaveAsFile "C:\Documents and Settings\206954\My Documents\Mails\Attachments\" & a.DisplayName
    Next
    
End Sub

Code:
Function TestSendMail(SendTo,Subject, Body, Attachment)

   Set ol=CreateObject("Outlook.Application")
   Set Mail=ol.CreateItem(0)
   Mail.to=SendTo

   Mail.Subject=Subject
   Mail.Body=Body
   If (Attachment <> "") Then
       Mail.Attachments.Add(Attachment)
   End If
   Mail.Send

   ol.Quit

   Set Mail = Nothing
   Set ol = Nothing
End Function



Or


Happy Tester,
Byzoor,
9597711082
Reply


Messages In This Thread
RE: fucntion to send mail in outlook works fine in qtpcode but does not work in .vbs - by byzoor - 06-13-2011, 09:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP integration to build frame-works devries 2 3,422 03-02-2015, 10:50 AM
Last Post: prit deo
  Security Warning in Outlook automation priyaang 2 3,925 02-19-2014, 01:50 PM
Last Post: priyaang
  Not able to send spacebar with End Key to TE nbansal 1 3,627 02-08-2013, 11:31 PM
Last Post: coolguy
  How can I send variable value to html property for descriptive programming in QTP ritugoyal 13 22,443 11-26-2012, 12:55 PM
Last Post: binny318
  vbs funcion to create run time test set log frebuffi 0 2,408 08-27-2012, 07:13 PM
Last Post: frebuffi

Forum Jump:


Users browsing this thread: 1 Guest(s)