Michiel78 Posted April 12, 2011 Share Posted April 12, 2011 (edited) Hi,I am currently working on a script that can send an e-mail to a list of recipients, using the _InetSmtpMail and _InetSmtpMailCOM() functions. Everything works perfectly, but now I wonder how to send an e-mail in both html and plain text, so that the e-mailclient of the recipient decides which one to display? Sort of what they often use for online newsletters.I believe it is called multipart/alternative in MIME and I searched for it on the autoit forums, but I could only find one topic. There they referred to _InetSmtpMailCOM(), but I can't seem to figure out how to manage it with this function. I would like to do exactly what LOULOU said in his topic:LOULOU, on Jul 9 2006, 08:26 PM, said:In fact here is what i want to do :'Content-Type: multipart/alternative;boundary="----=_NextPart_000_000A_01C6A396.0B0D9820"' & @CRLF & _"------=_NextPart_000_000A_01C6A396.0B0D9820" & @CRLF & _'Content-Type: text/plain;charset="iso-8859-1"' & @CRLF & _"Content-Transfer-Encoding: quoted-printable" & @CRLF & _Here the text in plain format"------=_NextPart_000_000A_01C6A396.0B0D9820" & @CRLF & _'Content-Type: text/html;charset="iso-8859-1"' & @CRLF & _'Content-Transfer-Encoding: quoted-printable' & @CRLF & _And here the text in html format"------=_NextPart_000_000A_01C6A396.0B0D9820--" & @CRLF & _@CRLFAnybody knows how to achieve this? Edited April 13, 2011 by Michiel78 Link to comment Share on other sites More sharing options...
Michiel78 Posted April 13, 2011 Author Share Posted April 13, 2011 Hi, I am currently working on a script that can send an e-mail to a list of recipients, using the _InetSmtpMail and _InetSmtpMailCOM() functions. Everything works perfectly, but now I wonder how to send an e-mail in both html and plain text, so that the e-mailclient of the recipient decides which one to display? Sort of what they often use for online newsletters. I believe it is called multipart/alternative in MIME and I searched for it on the autoit forums, but I could only find one topic. There they referred to _InetSmtpMailCOM(), but I can't seem to figure out how to manage it with this function. I would like to do exactly what LOULOU said in his topic: Anybody knows how to achieve this? Already found a way to make it work! $TextBody $HTMLBody ;replace $as_Body with a text and html body $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $TextBody, $HTMLBody, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) ;add the new $TextBody and $HTMLBody to the $rc string Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_TextBody = "", $as_HTMLBody = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance="Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0) ;also add them both to the _InetCOM ;Replace in the _InetCOM: If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf ;With: $objEmail.HTMLBody = $as_HTMLBody $objEmail.Textbody = $as_TextBody & @CRLF Ryzen 1 Link to comment Share on other sites More sharing options...
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