Send Email Sample using MSOutlook failed to initialize
I tried the MSOutlook sample, I got exception "Unable to initialize MS Outlook".
My register key for 'HKEY_CLASSES_ROOT\Outlook.Application\CurVer' has 'Default'='Outlook.Application.15'
I have changed the script to 'MsOutlook = Sys.OleObject("Outlook.Application.15");' in function 'InitializeOutlook()'
Hi,
Try below code (VBScript) it is working.
Sub SendEmail
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(0)
'Set the email properties
objMailItem.To = "ravik.ngk@email.com"
objMailItem.CC = "test@email.com"
'objMailItem.BCC = "" 'If BCC is not required, then this line can be omitted
objMailItem.Subject = " Test Execution Status using TestComplete"
objMailItem.Body= "PFA Test Execution Result" &chr(13)&chr(13)&"Thanks & Regards,"&chr(13)& Sys.UserName
FileName = Project.ConfigPath & "ExportedLog\TC Execution Status Or Result.mht"
'Call Log.SaveResultsAs(Filename, lsMHT)
objMailItem.Attachments.Add(FileName) 'TC log File Attached
objMailItem.Send
Set objMailItem = Nothing
Set objOutlook = Nothing
End Sub
Note - This code is export the Test log and send attachement of log (If log size is more, then outlook error may appear)