Micro Focus QTP (UFT) Forums
Send Mail Errors - 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: Send Mail Errors (/Thread-Send-Mail-Errors)



Send Mail Errors - tmahender12 - 05-16-2011

Hi

Iam using below code in qtp to send myautomation results
my problem here is, when i open outlook the code is working fine
but when i close outlookand run the code its giving general run time error.
at Mail.send, i think basically its not able to choose the profile.

can you please help how to open the profile using qtp code.


Code:
Call fnSendMail()


Public Function fnSendMail()

    Set oUtlookApp=CreateObject("Outlook.Application")
    Set Mail= oUtlookApp.CreateItem(0)
    Mail.to= gstrEmailAddress
    Mail.Subject=gstrEmailSubject
    Mail.Body=gstrEmailBody
'   Mail.Attachments.Add(gstrResultFileName)
    Mail.Send
    'oUtlookApp.Quit
    Set oUtlookApp = Nothing
    Set Mail = Nothing

End Function



RE: Send Mail Errors - surya_7mar - 05-24-2011

your code is trying to send email without logging, it only works when you a Outlook opened in your machine so that it will be authenticated automatocally.

Please authenticate your user please sending email