amosrinat Posted July 16, 2020 Posted July 16, 2020 Hi, i have an AutoIT script that sends emails with two embedded images. When users get the email they don't see the images. How should I fix my code? Thank you for your support, Amos expandcollapse popupFunc fSendMail() $TemplateName = StringRegExpReplace($Template, "^.*\\|\..*$", "") $SmtpServer = "smtp.**.com" $FromName = "do-not-reply@*********" $FromAddress = "do-not-reply@******" $ToAddress = $MG1_Mgr & ";"& $Owner $Subject = "ACTION REQUIRED - " & $TemplateName $Body = $sBody5 $IPPort = 25 $ssl = 0 Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = fINetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $IPPort, $ssl) If @error Then MyErrFunc() EndIf EndFunc;fSendMail Func fINetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort $objEmail.Configuration.Fields.Update $objEmail.Fields.Update ;$objEmail.Send **************** If @error Then MyErrFunc() EndIf $objEmail = "" EndFunc;fINetSmtpMailCom
Developers Jos Posted July 16, 2020 Developers Posted July 16, 2020 I don't see any mentioning of embedded images in your posted code so it would help when you share an actual example that contains those. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
amosrinat Posted July 16, 2020 Author Posted July 16, 2020 (edited) Hi Jos, Attached is the html page that I load as $body and a snapshot. Amostest-message.html Edited July 19, 2020 by amosrinat
Developers Jos Posted July 16, 2020 Developers Posted July 16, 2020 That page doesn't have embedded images but rather linked images which point to a local file. Just download and safe the file and then open it. You will see the images aren't found as they point to ".\" ...eg: <IMG style="HEIGHT: 151px; WIDTH: 358px; Z-INDEX: 0" border=0 hspace=0 alt="" src=".\ILSILOGO.jpg" width=358 align=left height=152> Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
amosrinat Posted July 17, 2020 Author Posted July 17, 2020 I pointed to the location at which the script is. How should I embed the images? The files are part of the graphics. I don't want people to download them.
BigDaddyO Posted July 17, 2020 Posted July 17, 2020 You can convert images into base64 strings and embed them directly into the HTML code. I do it for some HTML reports but my code is very specific to my reports. Search for Base64 html images Maybe this one: Subz 1
amosrinat Posted July 19, 2020 Author Posted July 19, 2020 Problem solved by attaching the files. They appear in the body without showing as attachments. Thank you all, Amos
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now