Micro Focus QTP (UFT) Forums
Function works fine in QTP but when i put it in vbs file it throws syntax error - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Function works fine in QTP but when i put it in vbs file it throws syntax error (/Thread-Function-works-fine-in-QTP-but-when-i-put-it-in-vbs-file-it-throws-syntax-error)



Function works fine in QTP but when i put it in vbs file it throws syntax error - Rashmi - 08-13-2008

Hi All,
The following function works fine in QTP but when i paste the same code .vbs file, it throws mismatch error and states that vbs file has an incorrect syntax

Code:
Call SendMail("x","y","z","a","C:\a.xls")

Public Function SendMail(SendTo,SendCC,Subject,Body,Attachment)
    Dim olApp
    Dim olNs
    Dim olMail
    Set olApp = GetObject(, "Outlook.Application")
    On Error GoTo 0
    Set olMail = olApp.CreateItem(olMailItem)
    With olMail
        .To = SendTo
        .CC = SendCC
        .Subject = Subject
        .Body = Body
        .Attachments.Add(Attachment)
        .Display
    .Send
    End With
    Set olMail = Nothing
    Set olApp = Nothing
End Function