NisHera
8 years agoValued Contributor
sending mail when outlook client closed
I was trying send test result using outlook using flowing functions
function InitOutlook(){ try{ try{ MsOutlook = Sys.OleObject("Outlook.Application"); } catch(exception){ MsOutlook = Sys.OleObject("Outlook.Application.11"); } NS = MsOutlook.GetNamespace("MAPI"); //ContacFldr = NS.Folders("Personal Folders").Folders("Contacts"); ContacFldr = NS.GetDefaultFolder(olFolderContacts); } catch(exception){ Log.Warning("Unable to initializa MS outlook ","generated from InitOutlook function"+exception, pmHigher); return false } return true ; }
and
function SendReport(FirstName,LastName,fileAttach){ var ObjItem, MI, i, CRLF; CRLF = "\n"; ObjItem = GetContactByName(FirstName,LastName ); if (ObjItem == null){Log.Error("User "+FirstName+" "+LastName+" Not found in the address book") } MI = MsOutlook.CreateItem(olMailItem); MI.Subject = "Test Results" MI.Body = " Hello..." + ObjItem.FirstName+CRLF+ " How are you fine thank you "; MI.To = ObjItem.Email1Address; Log.Message(ObjItem.Email1Address); MI.Attachments.Add(fileAttach,olByValue,MI.Body.length); MI.Display(); Delay(5000); MI.Send(); }
when I closed outlook application both working I could see new message open up with correct attachment and closed.
But never mail was sent. it stuck at out box, only will be sent when out look opens up.
If I keep outlook open it there would be error from first function " InitOutlook() " error message was "generated from InitOutlook functionError: Invalid class string: cannot obtain ClassID."
any idea?