OT: Getting HTML text into an email message

Sivakatirswami katir at hindu.org
Fri Nov 28 21:34:42 EST 2008


If you are running on OSX, then you can also (assuming you are into this 
kind of thing)

* Enable PostFix on your box
* Build your own multi-part email
* send it thru using Shell to your mail server

Pros:

-- You completely bypass all mail client caveats
-- Content is fully under your control

Cons: a bit nerdy; you have to know how to build the email

But if you are doing this regularly, once set up, its very sweet.

I have chunks in fields that serve as the requisite headers and breaks
and then the actual body of the msg can be simple HTML.

If you want the full script, let me know... Assuming you have Post 
script enabled and
your fill email is in a variable ready to send then

 
On createFinalEmailAndSendIt

#build your multi-part email from pre-set fields and body from
# your html field and put it into tMsg


put cr & "." & cr after tMsg ## You have your multi-part email in tMsg

## deal with Sendmail line length caveat....
 
  # fix endlines to unix and then save to file
  replace numtochar(13) WITH numtochar (10) in tMsg
 
  put ($HOME &"/Desktop/temp.txt") into tPath
  put tMsg into url ("binfile:" & tPath) # save him to file in case you 
need him later
 
  # introduce line breaks at the end of sentences into lines longer that 
990 chars
  # and two such breaks in the case of lines longer than 1980 chars.
  # will break lines up to 2970. Lines longer than (very unlikely) will 
be broken by Sendmail at 990
  REPEAT FOR each line tLine in tMsg
    SWITCH
    CASE len(tLine)<990
      put tLine & cr after tWrappedMsg
      next REPEAT
      break
    CASE len(tLine)>1980
      set the itemdel to "."
      put round(the number of items of tLine/3) into tBreakPoint
      put cr before item (tBreakPoint+1) of tLine
      put cr before item (tBreakPoint*2) of tLine
      put tLine & cr after tWrappedMsg
      next REPEAT
      break
    CASE len(tLine)>990
      set the itemdel to "."
      put round(the number of items of tLine/2) into tBreakPoint
      put cr before item (tBreakPoint+1) of tLine
      put tLine & cr after tWrappedMsg
      next REPEAT
      break
    END SWITCH
  END REPEAT
 
  set the itemdel to "," # just in case!
 
  put tWrappedMsg into tMsg
  replace cr WITH "\n" in tMsg
  put tMsg into  $DailyHPIEmail
  --put tMsg; exit to top # testing

  # Do shell stuff and send mail
  # disable these two lines and nothing happens
 
  set the shellcommand to "/bin/sh"
  put "echo -e $DailyHPIEmail | sendmail -f hpi.list at hindu.org " & (fld 
"to" of cd "staticText")  into tCmd
 
 
  --put "cat " & quote & tPath & quote & " | sendmail -f 
hpi.list at hindu.org " & (fld "to" of cd "staticText")  into tCmd
 
  # for Testing shell cmds and only  sending the email to a specific 
address, not the list
 
  --put "echo -e $DailyHPIEmail | sendmail -f katir at hindu.org " & 
"katir at hindu.org,whoever at Yourdomain.com"  into tCmd
  --put "echo -e $DailyHPIEmail > "  & quote & tPath & quote   into tCmd
  --put tCmd # use this to grab the output string and test from terminal
  --exit to top
 
  # check on status and inform user or comment to run silent
--  -- put shell(tCmd)  into tResult
--  -- IF tResult is empty THEN
--    answer "Mail was sent...." WITH "OK"
--  ELSE
--    answer tResult WITH "OK"
--  END IF
 
 
 --delete file tPath # uncomment if you want to wipe the temp failsafe 
file at end of sessions
 
 
END createFinalEmailAndSendIt






Ken Ray wrote:
> Since no one responded to this, I'll take a stab...
>
>   
>> But what is the magic? Is there a way in Run Rev to convert an HTML
>> page directly for email?
>>     
>
> The problem here is that as soon as you leave the realm of plain text, you
> enter the world of "what does the specific email client support"? That is,
> assuming you want Mail to be the email client here that will be sending the
> message, you need to then play in Mail's sandbox using whatever AppleScript
> is supported in Mail to do this (more on this later). But of course whatever
> you do will only work with Mail; if you want to send an HTML-formatted email
> from Entourage or from Outlook (PC), etc. you'll need to do something
> totally different.
>
> The other alternative (if you don't want to use a third-party email client),
> is to have Rev send SMTP-based email itself, and if you're interested in
> that avenue, there are a couple of libraries out there to help you send SMTP
> email.
>
> Back to Mail... since you're sending a formatted field, I'm assuming it's
> not pictures, so one way to do what you're looking for would be to
> AppleScript the mail message by styling the text in the same way the field
> is styled in Rev... there may be others, but this is the one I'm aware of...
>
> Ken Ray
> Sons of Thunder Software, Inc.
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>   




More information about the use-livecode mailing list