cancel
Showing results for 
Search instead for 
Did you mean: 

Send Email Sample using MSOutlook failed to initialize

SOLVED
Frequent Visitor

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()'

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

Re: Send Email Sample using MSOutlook failed to initialize

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)

 

1 REPLY 1
Super Contributor

Re: Send Email Sample using MSOutlook failed to initialize

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)

 

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors