Contributions
- 12 months agoPlace TestComplete QuestionsTestComplete Questions612Views0likes0Comments
How to use CDO objects to send email with .mht file as body but not as attachment
I am using CDO as below, to email the output .mht file upon execution of project as an attachment However I wish the contents of .mht file to be in email body. How can I do that? def SendEmail(mFrom, mTo, mSubject, mBody, mAttach): try: schema = "http://schemas.microsoft.com/cdo/configuration/" mConfig = Sys.OleObject["CDO.Configuration"] mConfig.Fields.Item[schema + "sendusing"] = 2 mConfig.Fields.Item[schema + "smtpserver"] = "something.com" mConfig.Fields.Item[schema + "smtpserverport"] = 25 mConfig.Fields.Update(); mMessage = Sys.OleObject["CDO.Message"] mMessage.Configuration = mConfig; mMessage.From = "someone@somewhere.com" mMessage.To = "anotherone@somewhere.com" mMessage.Subject = "Subject" mMessage.HTMLBody = "Body" mMessage.AddAttachment("file:///C:/Report.mht") mMessage.Attachments.Item[1].ContentMediaType="application/octet-stream" mMessage.Send(); except Exception as e: Log.Error("E-mail cannot be sent", str(e)) return False Log.Message("Message was sent successfully to anotherone@somewhere.com") return True12 months agoPlace TestComplete QuestionsTestComplete Questions629Views0likes7CommentsHow to use CDO objects to send email with .mht file as attachment but not as Outlook file
I am using CDO as below, to email the output .mht file upon execution of project. However my problem is that email is received with the attachment as output.mht.msg (Outlook item file) def SendEmail(mFrom, mTo, mSubject, mBody, mAttach): try: schema = "http://schemas.microsoft.com/cdo/configuration/" mConfig = Sys.OleObject["CDO.Configuration"] mConfig.Fields.Item[schema + "sendusing"] = 2 mConfig.Fields.Item[schema + "smtpserver"] = "something.com" mConfig.Fields.Item[schema + "smtpserverport"] = 25 mConfig.Fields.Update(); mMessage = Sys.OleObject["CDO.Message"] mMessage.Configuration = mConfig; mMessage.From = "someone@somewhere.com" mMessage.To = "anotherone@somewhere.com" mMessage.Subject = "Subject" mMessage.HTMLBody = "Body" mMessage.AddAttachment("file:///C:/Report.mht") mMessage.Send(); except Exception as e: Log.Error("E-mail cannot be sent", str(e)) return False Log.Message("Message was sent successfully to anotherone@somewhere.com") return True279Views0likes2Comments