sending_20an_20html_20email_20with_20optional_20attachments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sending_20an_20html_20email_20with_20optional_20attachments [2018/03/31 13:19] – external edit 127.0.0.1sending_20an_20html_20email_20with_20optional_20attachments [2024/01/05 00:21] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 //by Richard Russell, April 2014, corrected August 2015//\\ \\  In the article [[/Sending%20an%20email%20with%20attachments|Sending an email with attachments]] the procedure **PROCsendmailattach()** automatically sends an email using the SOCKLIB library. Listed below is a procedure which performs the same function except that you can send the body of the email as **HTML** instead of (or preferably as well as) **plain text**. The procedure might be called as follows:\\  //by Richard Russell, April 2014, corrected August 2015//\\ \\  In the article [[/Sending%20an%20email%20with%20attachments|Sending an email with attachments]] the procedure **PROCsendmailattach()** automatically sends an email using the SOCKLIB library. Listed below is a procedure which performs the same function except that you can send the body of the email as **HTML** instead of (or preferably as well as) **plain text**. The procedure might be called as follows:\\ 
 +<code bb4w>
         INSTALL @lib$+"SOCKLIB"         INSTALL @lib$+"SOCKLIB"
  
Line 16: Line 17:
  
         PROCsendmailhtmlattach(SMTP$,From$,To$,"","",Subject$,ReplyTo$,Plain$,HTML$,Attach$)         PROCsendmailhtmlattach(SMTP$,From$,To$,"","",Subject$,ReplyTo$,Plain$,HTML$,Attach$)
 +</code>
 The calling program should first check that the attached file(s) actually exist, because if not **PROCattach()** will abort with an error and not terminate the SMTP transaction; this could leave the server 'in limbo'. **Note that if an attached file path contains spaces or punctuation characters you must enclose it in quotes**.\\ \\  You should not assume that the receiving email client can necessarily render HTML, therefore ideally you should always include a **plain-text** message body as well as an **HTML** message body.\\ \\  Here is **PROCsendmailhtmlattach()**; like **PROCsendmail()** it cannot be used if authentication is required so in practice that probably means that your ISP's SMTP server must be used:\\  The calling program should first check that the attached file(s) actually exist, because if not **PROCattach()** will abort with an error and not terminate the SMTP transaction; this could leave the server 'in limbo'. **Note that if an attached file path contains spaces or punctuation characters you must enclose it in quotes**.\\ \\  You should not assume that the receiving email client can necessarily render HTML, therefore ideally you should always include a **plain-text** message body as well as an **HTML** message body.\\ \\  Here is **PROCsendmailhtmlattach()**; like **PROCsendmail()** it cannot be used if authentication is required so in practice that probably means that your ISP's SMTP server must be used:\\ 
 +<code bb4w>
         DEF PROCsendmailhtmlattach(smtp$,from$,rcpt$,cc$,bcc$,subject$,replyto$,plain$,html$,attach$)         DEF PROCsendmailhtmlattach(smtp$,from$,rcpt$,cc$,bcc$,subject$,replyto$,plain$,html$,attach$)
         LOCAL D%, S%, skt%, comma%, reply$, file$         LOCAL D%, S%, skt%, comma%, reply$, file$
Line 158: Line 161:
         CLOSE #F%         CLOSE #F%
         ENDPROC         ENDPROC
 +</code>
sending_20an_20html_20email_20with_20optional_20attachments.1522502380.txt.gz · Last modified: 2024/01/05 00:16 (external edit)