it is impossible that there is a programming language that cannot send an email in html format.
How to send an email as html?
How to send an email as html?
How to send an email as html (v.5.73 !!! )
it is impossible that there is a programming language that cannot send an email in html format.



it is impossible that there is a programming language that cannot send an email in html format.
Re: How to send an email as html?
Hm ...
if I look at C, it can do nearly nothing.
It all depends on libraries.
If you can nothing find here in the forum, simply choose a library of your choice and write a wrapper.
if I look at C, it can do nearly nothing.
It all depends on libraries.
If you can nothing find here in the forum, simply choose a library of your choice and write a wrapper.
Re: How to send an email as html?
Or you can use the 'inbuild' libcurl
viewtopic.php?p=591235
An example:
https://curl.se/libcurl/c/smtp-mime.html
Or more simple:
https://curl.se/mail/lib-2012-01/0121.html
viewtopic.php?p=591235
An example:
https://curl.se/libcurl/c/smtp-mime.html
Or more simple:
https://curl.se/mail/lib-2012-01/0121.html
Last edited by infratec on Sun Nov 13, 2022 4:14 pm, edited 1 time in total.
Re: How to send an email as html?
what does it mean?:infratec wrote:Hm ...
if I look at C, it can do nearly nothing.
It all depends on libraries.
If you can nothing find here in the forum, simply choose a library of your choice and write a wrapper.
Code: Select all
#PB_Mail_Custom : Add customs fields (can be multi-line).Re: How to send an email as html?
Send yourself a plaintext email saying Hello, then send yourself a HTML version of the same. Compare the differences and it becomes obvious
Re: How to send an email as html?
such suggestions are ...Keya wrote:Send yourself a plaintext email saying Hello, then send yourself a HTML version of the same. Compare the differences and it becomes obvious
...
I know exactly how the structure should look like, but how do I send it in PB ???
Question:
Will the following notation work in PB 5.73:
Code: Select all
SetMailBody (0, "MIME-Version: 1.0" + # CRLF $ +
"Content-Type: multipart / alternative; boundary = '-------'" + # CRLF $ +
"Content-Language: en" + # CRLF $ +
"This is a multi-part message in MIME format." + # CRLF $ +
"---------" + # CRLF $ +
"Content-Type: text / plain; charset = utf-8; format = flowed" + # CRLF $ +
"Content-Transfer-Encoding: 7bit" + # CRLF $ +
"non html" + # CRLF $ +
"---------" + # CRLF $ +
"Content-Type: text / html; charset = utf-8" + # CRLF $ +
"Content-Transfer-Encoding: 8bit" + # CRLF $ +
"<html>" + # CRLF $ +
"<head>" + # CRLF $ +
"<meta http-equiv = 'content-type' content = 'text / html; charset = UTF-8'>" + # CRLF $ +
"<title> topic </title>" + # CRLF $ +
"</head>" + # CRLF $ +
"<body>" + # CRLF $ +
"<p> As <font size = '+ 2'> sss </font> <br>" + # CRLF $ +
"</p>" + # CRLF $ +
"</body>" + # CRLF $ +
"</html>" + # CRLF $ +
"-----------")Or maybe this:
Code: Select all
SetMailAttribute (#Mail, #PB_Mail_Custom,
"MIME-Version: 1.0" + # CRLF $ +
"Content-Type: multipart / alternative; boundary = '-------'" + # CRLF $ +
"Content-Language: en" + # CRLF $ +
"This is a multi-part message in MIME format." + # CRLF $ +
"---------" + # CRLF $ +
"Content-Type: text / plain; charset = utf-8; format = flowed" + # CRLF $ +
"Content-Transfer-Encoding: 7bit" + # CRLF $ +
"non html" + # CRLF $ +
"---------" + # CRLF $ +
"Content-Type: text / html; charset = utf-8" + # CRLF $ +
"Content-Transfer-Encoding: 8bit")
If it used to work (in previous versions), why did it suddenly stop?
Re: How to send an email as html?
As written ...
it will not work with te e-mail functions of PB, since the original Content-Type is still present.
At the moment you can not replace it, you can only add an additional one.
I already added a feature request about this:
viewtopic.php?f=3&t=72187
You have to use the way I showed you with libcurl.
it will not work with te e-mail functions of PB, since the original Content-Type is still present.
At the moment you can not replace it, you can only add an additional one.
I already added a feature request about this:
viewtopic.php?f=3&t=72187
You have to use the way I showed you with libcurl.
Last edited by infratec on Wed Mar 10, 2021 11:20 am, edited 1 time in total.
Re: How to send an email as html?
POLINK: error: Unresollved external symbolinfratec wrote:As written ...
You have to use the way I showed you with libcurl.
'_curl_easy_strerror'.
POLINK: fatal error: 1 unresolved external(s).
Re: How to send an email as html?
By the way:
... returns NONZERO if the mail was sent correctly and zero otherwise
but
Result=1 ==> NONZERO, but "Can't sent the mail !"
Why ???
Code: Select all
SendMail(#Mail, Smtp$ [, Port [, Flags [, User$, Password$]]])but
Code: Select all
If CreateMail(0, "senderMail", "Subject: Hello !")
SetMailBody(0, "Hello !")
AddMailRecipient(0, "mailTO", #PB_Mail_To)
Result = SendMail(0, "smtpserver", 465, #PB_Mail_Asynchronous, "user", "password")
Debug "Result="+Str(Result)
Repeat
Progress = MailProgress(0): Delay(300)
Until Progress = #PB_Mail_Finished Or Progress = #PB_Mail_Error
If Progress = #PB_Mail_Finished
MessageRequester("Information", "Mail correctly sent !")
Else
MessageRequester("Error", "Can't sent the mail !")
EndIf
EndIfWhy ???
Re: How to send an email as html?
"Daddy, I'll run faster, then it is not so far..."
Re: How to send an email as html?
From where is your used libcurl.pbi?Johanson wrote:POLINK: error: Unresollved external symbolinfratec wrote:As written ...
You have to use the way I showed you with libcurl.
'_curl_easy_strerror'.
POLINK: fatal error: 1 unresolved external(s).
Which OS are you using?
Re: How to send an email as html?
Win10 x64infratec wrote:From where is your used libcurl.pbi?Johanson wrote:POLINK: error: Unresollved external symbolinfratec wrote:As written ...
You have to use the way I showed you with libcurl.
'_curl_easy_strerror'.
POLINK: fatal error: 1 unresolved external(s).
Which OS are you using?
Re: How to send an email as html?
I tried
I remind you: I have version 5.73
Re: How to send an email as html?
I added the mime stuff in my libcurl.pbi
viewtopic.php?p=591235
This code works:
Of course you have to adust the server and user stuff.
viewtopic.php?p=591235
This code works:
Code: Select all
;
; LibCurl e-mail with html body
;
EnableExplicit
IncludeFile "libcurl.pbi"
#MailServer = "smtp://mail.example.com"
#FROM = "<sender@example.org>"
#To = "<addressee@example.net>"
#SMTP_User = ""
#SMTP_Password = ""
;#SKIP_PEER_VERIFICATION = #True
;#SKIP_HOSTNAME_VERIFICATION = #True
Define.i curl, i, res
Define.curl_slist *recipients, *headers, *slist
Define.curl_mime *mime, *alt
Define *part
Define inline_text$, inline_html$
Dim HeaderArray$(5)
HeaderArray$(0) = "Date: Wed, 10 Mar 2021 06:30:29 +0200"
HeaderArray$(1) = "To: "+ #TO
HeaderArray$(2) = "From: " + #FROM + " (Example User)"
HeaderArray$(3) = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>"
HeaderArray$(4) = "Subject: example sending a MIME-formatted message"
inline_text$ = "This is the inline text message of the e-mail." + #CRLF$
inline_text$ + #CRLF$
inline_text$ + "It could be a lot of lines that would be displayed in an e-mail" + #CRLF$
inline_text$ + "viewer that is not able to handle HTML." + #CRLF$
inline_html$ = "<html>" + #CRLF$
inline_html$ + " <body>" + #CRLF$
inline_html$ + " <p>This is the inline <b>HTML</b> message of the e-mail.</p>" + #CRLF$
inline_html$ + " <br />" + #CRLF$
inline_html$ + " <p>It could be a lot of HTML data that would be displayed by e-mail viewers able To handle HTML.</p>" + #CRLF$
inline_html$ + " </body>" + #CRLF$
inline_html$ + "</html>" + #CRLF$
curl = curl_easy_init()
If curl
If #SMTP_User <> ""
; Set username And password
curl_easy_setopt_str(curl, #CURLOPT_USERNAME, #SMTP_User)
curl_easy_setopt_str(curl, #CURLOPT_PASSWORD, #SMTP_Password)
EndIf
If Left(#MailServer, 5) = "smtps"
; If you want To connect To a site who isn't using a certificate that is
; signed by one of the certs in the CA bundle you have, you can skip the
; verification of the server's certificate. This makes the connection
; A LOT LESS SECURE.
;
; If you have a CA cert For the server stored someplace Else than in the
; Default bundle, then the CURLOPT_CAPATH option might come handy For
; you.
CompilerIf Defined(SKIP_PEER_VERIFICATION, #PB_Constant)
CompilerIf #SKIP_PEER_VERIFICATION
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
CompilerEndIf
CompilerEndIf
; If the site you're connecting to uses a different host name that what
; they have mentioned in their server certificate's commonName (or
; subjectAltName) fields, libcurl will refuse To connect. You can skip
; this check, but this will make the connection less secure. */
CompilerIf Defined(SKIP_HOSTNAME_VERIFICATION, #PB_Constant)
CompilerIf #SKIP_HOSTNAME_VERIFICATION
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
CompilerEndIf
CompilerEndIf
EndIf
; This is the URL for your mailserver
curl_easy_setopt_str(curl, #CURLOPT_URL, #MailServer)
curl_easy_setopt_str(curl, #CURLOPT_MAIL_FROM, #FROM)
*recipients = curl_slist_append(*recipients, #To)
curl_easy_setopt(curl, #CURLOPT_MAIL_RCPT, *recipients)
; Build and set the message header list.
For i = 0 To ArraySize(HeaderArray$()) - 1
*headers = curl_slist_append(*headers, HeaderArray$(i))
Next i
curl_easy_setopt(curl, #CURLOPT_HTTPHEADER, *headers)
; Build the mime message.
*mime = curl_mime_init(curl)
; The inline part is an alternative proposing the html and the text versions of the e-mail.
*alt = curl_mime_init(curl)
; HTML message.
*part = curl_mime_addpart(*alt)
curl_mime_data(*part, inline_html$, #CURL_ZERO_TERMINATED)
curl_mime_type(*part, "text/html")
; Text message.
*part = curl_mime_addpart(*alt)
curl_mime_data(*part, inline_text$, #CURL_ZERO_TERMINATED)
; Create the inline part.
*part = curl_mime_addpart(*mime)
curl_mime_subparts(*part, *alt)
curl_mime_type(*part, "multipart/alternative")
*slist = curl_slist_append(#Null, "Content-Disposition: inline")
curl_mime_headers(*part, *slist, 1)
; Add the current source program As an attachment.
; *part = curl_mime_addpart(*mime)
; curl_mime_filedata(*part, "EMailWithHTML.pb")
curl_easy_setopt(curl, #CURLOPT_MIMEPOST, *mime)
; Send the message
res = curl_easy_perform(curl)
; Check For errors
If res <> #CURLE_OK
Debug "curl_easy_perform() failed: " + curl_easy_strerror(res)
EndIf
; Free multipart message.
curl_mime_free(*mime)
; Free lists.
curl_slist_free_all(*headers)
curl_slist_free_all(*recipients)
curl_easy_cleanup(curl)
EndIf
Last edited by infratec on Sun Nov 13, 2022 4:15 pm, edited 1 time in total.
Re: How to send an email as html?
Define.curl_mime *mime, *altinfratec wrote:I added the mime stuff in my libcurl.pbi
https://www.von-der-salierburg.de/downl ... urldll.zip
This code works:Of course you have to adust the server and user stuff.Code: Select all
; ; LibCurl e-mail with html body ; EnableExplicit IncludeFile "libcurl.pbi" #MailServer = "smtp://mail.example.com" #FROM = "<sender@example.org>" #To = "<addressee@example.net>" #SMTP_User = "" #SMTP_Password = "" ;#SKIP_PEER_VERIFICATION = #True ;#SKIP_HOSTNAME_VERIFICATION = #True Define.i curl, i, res Define.curl_slist *recipients, *headers, *slist Define.curl_mime *mime, *alt Define *part Define inline_text$, inline_html$ Dim HeaderArray$(5) HeaderArray$(0) = "Date: Wed, 10 Mar 2021 06:30:29 +0200" HeaderArray$(1) = "To: "+ #TO HeaderArray$(2) = "From: " + #FROM + " (Example User)" HeaderArray$(3) = "Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@rfcpedant.example.org>" HeaderArray$(4) = "Subject: example sending a MIME-formatted message" inline_text$ = "This is the inline text message of the e-mail." + #CRLF$ inline_text$ + #CRLF$ inline_text$ + "It could be a lot of lines that would be displayed in an e-mail" + #CRLF$ inline_text$ + "viewer that is not able to handle HTML." + #CRLF$ inline_html$ = "<html>" + #CRLF$ inline_html$ + " <body>" + #CRLF$ inline_html$ + " <p>This is the inline <b>HTML</b> message of the e-mail.</p>" + #CRLF$ inline_html$ + " <br />" + #CRLF$ inline_html$ + " <p>It could be a lot of HTML data that would be displayed by e-mail viewers able To handle HTML.</p>" + #CRLF$ inline_html$ + " </body>" + #CRLF$ inline_html$ + "</html>" + #CRLF$ curl = curl_easy_init() If curl If #SMTP_User <> "" ; Set username And password curl_easy_setopt_str(curl, #CURLOPT_USERNAME, #SMTP_User) curl_easy_setopt_str(curl, #CURLOPT_PASSWORD, #SMTP_Password) EndIf If Left(#MailServer, 5) = "smtps" ; If you want To connect To a site who isn't using a certificate that is ; signed by one of the certs in the CA bundle you have, you can skip the ; verification of the server's certificate. This makes the connection ; A LOT LESS SECURE. ; ; If you have a CA cert For the server stored someplace Else than in the ; Default bundle, then the CURLOPT_CAPATH option might come handy For ; you. CompilerIf Defined(SKIP_PEER_VERIFICATION, #PB_Constant) CompilerIf #SKIP_PEER_VERIFICATION curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0) CompilerEndIf CompilerEndIf ; If the site you're connecting to uses a different host name that what ; they have mentioned in their server certificate's commonName (or ; subjectAltName) fields, libcurl will refuse To connect. You can skip ; this check, but this will make the connection less secure. */ CompilerIf Defined(SKIP_HOSTNAME_VERIFICATION, #PB_Constant) CompilerIf #SKIP_HOSTNAME_VERIFICATION curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0) CompilerEndIf CompilerEndIf EndIf ; This is the URL for your mailserver curl_easy_setopt_str(curl, #CURLOPT_URL, #MailServer) curl_easy_setopt_str(curl, #CURLOPT_MAIL_FROM, #FROM) *recipients = curl_slist_append(*recipients, #To) curl_easy_setopt(curl, #CURLOPT_MAIL_RCPT, *recipients) ; Build and set the message header list. For i = 0 To ArraySize(HeaderArray$()) - 1 *headers = curl_slist_append(*headers, HeaderArray$(i)) Next i curl_easy_setopt(curl, #CURLOPT_HTTPHEADER, *headers) ; Build the mime message. *mime = curl_mime_init(curl) ; The inline part is an alternative proposing the html and the text versions of the e-mail. *alt = curl_mime_init(curl) ; HTML message. *part = curl_mime_addpart(*alt) curl_mime_data(*part, inline_html$, #CURL_ZERO_TERMINATED) curl_mime_type(*part, "text/html") ; Text message. *part = curl_mime_addpart(*alt) curl_mime_data(*part, inline_text$, #CURL_ZERO_TERMINATED) ; Create the inline part. *part = curl_mime_addpart(*mime) curl_mime_subparts(*part, *alt) curl_mime_type(*part, "multipart/alternative") *slist = curl_slist_append(#Null, "Content-Disposition: inline") curl_mime_headers(*part, *slist, 1) ; Add the current source program As an attachment. ; *part = curl_mime_addpart(*mime) ; curl_mime_filedata(*part, "EMailWithHTML.pb") curl_easy_setopt(curl, #CURLOPT_MIMEPOST, *mime) ; Send the message res = curl_easy_perform(curl) ; Check For errors If res <> #CURLE_OK Debug "curl_easy_perform() failed: " + curl_easy_strerror(res) EndIf ; Free multipart message. curl_mime_free(*mime) ; Free lists. curl_slist_free_all(*headers) curl_slist_free_all(*recipients) curl_easy_cleanup(curl) EndIf
==> 'Structure not found: curl_mime'


