Micro Focus QTP (UFT) Forums
Outlook using QTP - 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: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Outlook using QTP (/Thread-Outlook-using-QTP)

Pages: 1 2


RE: Outlook using QTP - deeps_aj - 09-23-2008

Hello,
I used the same script, but i'm getting error msg as "The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available"

plz tel me wats the problem... thanX in adv... Waiting for ur reply

Thanks and Regards
Deepika


RE: Outlook using QTP - srivania - 09-25-2008

Hi,

try this,

Code:
Public Function SendMail(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

       Set Mail = nothing
       Set ol = nothing
      
End Function



RE: Outlook using QTP - venkatbatchu - 10-20-2009

Please find the below code u would be able to send the mail through qtp


'Email generation VB Script snipet.
'venkat batchu
'Pre requisite: MS Outlook apllication up running on the desktop
'----------------------------------------------------------------------------------

Code:
Dim ToAddress
Dim Subject
Dim Body
Dim Attachment
Dim oUtlookApp, nAmeSpace, newMail

'SystemUtil.Run "C:\Program Files\Microsoft Office\Office11\OUTLOOK.EXE" 'This line should be enabled if the Outlook on the desktop is not running

ToAddress = "venkat.batchu@xxxx.com" ' Message recipient Address

Set oUtlookApp = CreateObject("Outlook.Application")

Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")

Set newMail = oUtlookApp.CreateItem(0)

Subject = "Test Results of Login and Signoff" 'Message Subject you can update

Body = "To view the test results of login and signoff. " 'Message body you can update

newMail.Subject = Subject

newMail.Body = Body & vbCrLf

newMail.Recipients.Add(ToAddress)

newMail.Attachments.Add("C:\Documents and Settings\venkat.batchu\Desktop\Results\Log\LogFile.html") 'You can update attachment file name

newMail.Send

Set nAmeSpace = Nothing

Set oUtlookApp = Nothing

'end of the email generation code
===================================================================


Enjoy by sending mails through qtp..