Dear All,
is it possible to send the qtp generated report using email?
i m converting the report into html format. now i wamt to send this
report to my mail box.
i m using Microsoft Outlook Express 6 for mailing purpose
Thanks and Regards,
shweta
Try this code
Code:
Set olapp = CreateObject("Outlook.Application")
Set olns = olapp.GetNameSpace("MAPI")
olns.logon
Set objfolder=olns.getdefaultfolder(6)
objfolder.display
set msg = olapp.createitem(olMailitem)
Set rcp = msg.recipients.Add ("xxx@gmail.com")
msg.subject = "Automated mail from QTP - Result "
msg.body = "XXXXXXXXXXXXXXX"
msg.Attachments.Add ("Z:\Sample.xls")
msg.send
its giving error
screenshot attached.
Please select ActiveX Addin in Addin Manager
Active X is Already selected ...
still giving error....
Screenshot attached
It is CreateObject("Outlook.Application") not "Outlook.Express"
Not sure , y ur facing the error
From my side, the code which i posted is perfectly working.
Post ur complete script so that we can have a look at it
'Email generation VB Script snipet.
'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
SystemUtil.Run "C:\Program Files\Outlook Express\msimn.exe"
ToAddress = "xyz@gmail.com" ' Message recipient Address
Set oUtlookApp = CreateObject("Outlook.Application")
Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")
Set newMail = oUtlookApp.CreateItem(0)
Subject = "This is a test mail" 'Message Subject you can update
Body = "This the message for testing. " 'Message body you can update
newMail.Subject = Subject
newMail.Body = Body & vbCrLf
newMail.Recipients.Add(ToAddress)
newMail.Attachments.Add("D:\Automation\report\login.html") 'You can update attachment file name
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing
'end of the email generation code===================================================================
Try this, best of luck
Code:
Dim ToAddress
Dim Subject
Dim Body
Dim Attachment
Dim oUtlookApp, nAmeSpace, newMail
ToAddress = "xyz@gmail.com" ' Message recipient Address
Set oUtlookApp = CreateObject("Outlook.Application")
Set nAmeSpace = oUtlookApp.GetNamespace("MAPI")
nAmeSpace.logon
Set objfolder=olns.getdefaultfolder(6)
objfolder.display
Subject = "This is a test mail" 'Message Subject you can update
Body = "This the message for testing. " 'Message body you can update
newMail.Subject = Subject
newMail.Body = Body & vbCrLf
newMail.Recipients.Add(ToAddress)
newMail.Attachments.Add("D:\Automation\report\login.html") 'You can update attachment file name
newMail.Send
Set nAmeSpace = Nothing
Set oUtlookApp = Nothing