Sending html E-Mail

Juan Bofill juanbofillaba at gmail.com
Thu Jul 12 10:59:48 EDT 2018


Does it work with 4.2 on OSX ?

Thanks!

Juan

> On Jul 12, 2018, at 3:14 AM, Paul Mulroney <pmulroney at logicaldevelopments.com.au> wrote:
> 
> Hi Alan,
> 
> HTML formatted email in Omnis is straightforward.  Below is some sample code...
> 
> You should send the email with both HTML and plaintext versions.  pBodyHTML is the var which holds the formatted HTML, pBodyText is the same, but as plain text.
> 
> ;  - Format the email message.  Going to be in mime format.
> Set current list lTheList
> Define list {vnLevel,vsContentType,vsContentSubtype,vsFilename,vsCharacterData,vbBinaryData,vsCharacterSet,vsContentTransferEncoding}
> Do lTheList.$add(0,'multipart','alternative')
> Do lTheList.$add(1,'text','plain',,pBodyText,,'iso-8859-1','quoted-printable')    
> Do lTheList.$add(1,'text','html',,pBodyHTML,,'iso-8859-1','quoted-printable')     
> SMTPSend (lOutServer,lOutFrom,pSendTo,pTitle,lTheList,lCC,lBCC) Returns lTheStatus
> 
> If you want to embed images or attachments, it's a little harder.  This is an example of an email containing html, company logo (stored as a jpg in an Omnis binary field), and a PDF attachment:
> 
> Set current list vlWIP
> Define list {vnLevel,vsContentType,vsContentSubtype,vsFilename,vsCharacterData,vBinData,vsCharacterSet,vsContentTransferEncoding,vsContentDisposition}
> 
> ;  - HTML/Text alternative, embedded images
> Do vlWIP.$add(0,'multipart','mixed')     ;; This is a multi-layered MIME message.
> Do vlWIP.$add(1,'multipart','alternative')     ;; Next level down is the "alternative", which is where the email client can choose between Text and HTML formats
> Do vlWIP.$add(2,'text','plain',,vsBodyText,,'iso-8859-1','quoted-printable')     ;; Here's the text format first.  If they can parse html, the mail client won't show this
> Do vlWIP.$add(2,'multipart','related')     ;; This is the HTML part.  It has inline images, so it's a multipart/related setup.
> Do vlWIP.$add(3,'text','html',,vsBodyHTML,,'iso-8859-1','quoted-printable')     ;; Here's the body of the email in HTML format
> Calculate vbLogo as bytemid(LogoField,25,binlength(LogoField))     ;; Storing this in an Omnis field seems to add a header, so we need to strip this off first.
> Do vlWIP.$add(3,'image',con('jpg;',kCr,kLf,'Content-ID:<companylogo>'),'companylogo.jpg',,vbLogo,,,'inline')     ;; Embed logo into the email.  Stored in prefs.  Fake the Content-ID part
> 
> ;  - The attached PDF at the top level
> Do voFileOps.$openfile(psFileName)
> Do voFileOps.$readfile(vBinData)
> Do voFileOps.$closefile()
> Do FileOps.$splitpathname(psFileName,vsDrive,vsDir,vsFile,vsExt)
> Do vlWIP.$add(1,'application','octet-stream',con(vsFile,vsExt),,vBinData,,,'attachment')     ;; THREE commas! (not two, not four, five is RIGHT OUT)
> 
> Calculate vsLogging as 'oLogfile/$logging'     ;; The method to call for SMTP logging.  Must be a public method.
> SMTPSend (vsOutServer,vsOutFromAddress,pSendTo,psSubject,vlWIP,vsCC,vsBCC,vsOutFromName,vsLogging,'','','','',kFalse,kFalse) Returns vnStatus
> 
> In the HTML where you want to reference your embedded image, use <img src="cid:companylogo"/>     ;; The inline jpeg logo image.  "cid:" means use the Content-ID tag to identify this
> 
> Regards,
> Paul.
> 
> 
> 
>> On 12 Jul 2018, at 2:20 pm, Alan Grinberg <omnis at alangrinberg.com> wrote:
>> 
>> Is it possible to send html formatted e-mail from Omnis?
>> 
>> I don’t care what version, just interested in a general outline of how this can be done.
>> 
>> PS. How do I search the archives of this list? My old links no longer work.
>> 
>> Thanks.
>> - Alan
>> 
>> 
>> ----------------------------------------------------
>> Alan Grinberg
>> AG Systems/ZOO-INK
>> San Francisco, CA 
>> 
>> www.zoo-ink.com <applewebdata://B6FC07A5-CC98-4EB7-B36D-2320A51E9FFC>
>> www.perfectfit.net <http://www.perfectfit.net/>
>> alan at perfectfit.net <mailto:alan at perfectfit.net>
>> ----------------------------------------------------
>> 
>> 
>> 
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 
> 
> I bought my friend an elephant for his room. He said “Thanks” I said “Don’t mention it”
> -- 
> Paul W. Mulroney                                            We Don't Do Simple Pty Ltd 
> pmulroney at logicaldevelopments.com.au       Trading as Logical Developments
> www.logicaldevelopments.com.au                   ACN 161 009 374 
> Ph: +61 8 9458 3889                                       86 Coolgardie Street
>                                                                         BENTLEY  WA  6102
> 
> 
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 




More information about the omnisdev-en mailing list