paarmann-ara
6 years agoContributor
send mail via script
Good Day,
I try send mail via script, but I get error.
def SendEmail(Message): try: useSSL = 'True' schema = "http://schemas.microsoft.com/cdo/configuration/" mConfig = Sys.OleObject["CDO.Configuration"] mConfig.Fields.Item[schema + "sendusing"] = 2 mConfig.Fields.Item[schema + "smtpserver"] = outlook.office365.com mConfig.Fields.Item[schema + "smtpserverport"] = 587 mConfig.Fields.Item[schema + "sendusername"] = MyEmailAddress mConfig.Fields.Item[schema + "sendpassword"] = MyEmailPassword mConfig.Fields.Item[schema + "smtpauthenticate"] = 1 mConfig.Fields.Item[schema + "STARTTLS"] = True mConfig.Fields.Item[schema + "smtpconnectiontimeout"] = 30; mConfig.Fields.Update() mMessage = Sys.OleObject["CDO.Message"] mMessage.Configuration = mConfig mMessage.From = MyEmailAddress mMessage.To = MyEmailAddress mMessage.Subject = 'TestComplete Result' mMessage.HTMLBody = Message mMessage.Send(); except Exception as exp: Log.Error('E-mail cannot be sent', str(exp)) return False Log.Message('Message was successfully sent') return True def test (): SendEmail('Hi')
Wht is wrong in my code?
Yes that is a known issue in automation for Excel
Opening a 2013 file in 2016, even you if don't change anything, will cause Excel to bring up a box stating that the you have to accept that the file will be saved in the new 2016 format.
My recommendation is to save the files as 2016 files once before you start the COM automation with Excel from inside of TestComplete
Cheers
-Lino