World: r3wp
[Rebol School] Rebol School
older newer | first last |
GiuseppeC 29-May-2010 [3212] | Just a question for REBOL School for me too: is there a way to send HTML emails with embedded images ? |
florin 29-May-2010 [3213] | I'm totally green to this. I've seen images imbedded into rebol source files. Could this be helpful? http://www.rebol.net/cookbook/recipes/0048.html |
amacleod 29-May-2010 [3214x2] | I do not think so...Images are always links in emails...one reason I avoid them as, like me, most clients require you to manually load them for security issues. The link above is just to embed them in a rebol script. I do not think there is a similar method for html... |
Correction...here is a link that might help: http://rifers.org/blogs/gbevin/2005/4/11/embedding_images_inside_html | |
Pekr 30-May-2010 [3216] | it is not true images rea always links in email - you can embedd images too .... postcard services do so ... |
Gabriele 30-May-2010 [3217] | Giuseppe, basically, you attach the image with the email, and use a normal <img> tag in the HTML with a cid: URL. i don't have an example at hand, unfortunately... |
Reichart 30-May-2010 [3218] | You should be able to take an HTML with an image in it, look at the source, and then spew that out of REBOL. |
BudzinskiC 30-May-2010 [3219] | What amacleoud suggested should work just fine. Although maybe not in all mail clients. I do know that Adobe Air for example doesn't allow data links (for security reasons IIRC) so maybe some email apps have deactivated that feature too. It does work fine on my iPod Touch's email client (which is the only client I could test this on since I usually just use Gmail's web interface). Here's a small rebol script that does the job (yeah, I was bored) REBOL [] imgfile: request-file/only encoded: enbase read/binary imgfile filetype: next to-string suffix? imgfile ; you can use this right in the browser as a web address datalink: rejoin [{data:image/} filetype ";base64," encoded] ; and this inside html source imglink: rejoin [{<img src="} datalink {"/>}] editor imglink |
amacleod 30-May-2010 [3220] | nice little script...i got errrors when I tried to copy and paste. Thanks. |
Gabriele 31-May-2010 [3221] | Reichart, actually, that is true only if the HTML comes from an email with an embedded image (as attachment, not as link to an external website), and you need to look at the whole message source rather than just the HTML to make sense of it. the cid: links are an email thing and have nothing to do with HTML itself. |
BudzinskiC 31-May-2010 [3222] | amacleod: Worked fine for me but I only tried it with a very small picture (the rebol logo actually), if you tried a big picture the resulting data link might be just too long for copy & paste actions (really long text almost always causes problems). Just replace the last line (editor imglink) with write %somefile.html imglink browse %somefile.html And it "should" work with bigger pictures. |
amacleod 31-May-2010 [3223x3] | Thanks BudzinskiC, Works for me in Outlook but not Google mail web interface.... but it works on my palm pre accessing my gmail account |
I was able to embed a picture using outlook and it worked in gmail web mail... What method does outlook use to embed images? | |
image is referenced in this code but where is the image? is it somehow attached but not seen as an attachment? <p class=MsoNormal><font size=2 face=Arial><span style='font-size:10.0pt; font-family:Arial'><img width=688 height=155 id="_x0000_i1025" src="cid:[image001-:-jpg-:-01CB00A8-:-DF6F9A50]"><o:p></o:p></span></font></p> | |
GiuseppeC 31-May-2010 [3226] | I admit I am a bit confused... |
Gabriele 1-Jun-2010 [3227] | Amacleod, the image is attached, the container is multipart/related instead of multipart/mixed. The email client will not show the individual components of a multipart/related message, instead, it shows the main part (the HTML) which then refers to the other parts (in case of HTML, using cid: links). |
amacleod 1-Jun-2010 [3228] | is there a way for rebol to attach multipert/related? |
Oldes 1-Jun-2010 [3229x3] | You can check this really old script http://box.lebeda.ws/~hmm/rebol/mail-page_latest.r But I'm not sure if it works. I never used it in real situation. |
Just quicklu checking and it does not look like good example. It's probably some not working version. Found several bugs just by observing. | |
I've reuploaded the file so at least this test works: write/binary %test.msg page-mailer/form-msg page-mailer/make-html-mail/text {ahoj <img src="path-to-your-image.jpg">} {plain version} Which produces MSG file which you can examine to see, how it should looks like. For example like this one: http://box.lebeda.ws/~hmm/rebol/test.msg | |
Claude 1-Jun-2010 [3232x5] | hi here you are un function to send mail with multi attachments |
REBOL[] send: func [ "Send a message to an address (or block of addresses)" ;Note - will also be used with REBOL protocol later. address [email! block!] "An address or block of addresses" message "Text of message. First line is subject." /only "Send only one message to multiple addresses" /header "Supply your own custom header" header-obj [object!] "The header to use" /attach "Attach file, files, or [.. [filename data]]" files [file! block!] "The files to attach to the message" /subject "Set the subject of the message" subj "The subject line" /show "Show all recipients in the TO field" /local smtp-port boundary make-boundary tmp from ][ make-boundary: does [] if file? files [files: reduce [files]] ; make it a block if email? address [address: reduce [address]] ; make it a block message: either string? message [copy message] [mold message] if not header [ ; Clone system default header header-obj: make system/standard/email [ subject: any [subj copy/part message any [find message newline 50]] ] ] if subject [header-obj/subject: subj] either none? header-obj/from [ if none? header-obj/from: from: system/user/email [net-error "Email header not set: no from address"] if all [string? system/user/name not empty? system/user/name][ header-obj/from: rejoin [system/user/name " <" from ">"] ] ][ from: header-obj/from ] if none? header-obj/to [ header-obj/to: tmp: make string! 20 if show [ foreach email address [repend tmp [email ", "]] clear back back tail tmp ] ] if none? header-obj/date [header-obj/date: to-idate now] if attach [ boundary: rejoin ["--__REBOL--" system/product "--" system/version "--" checksum form now/precise "__"] header-obj/MIME-Version: "1.0" header-obj/content-type: join "multipart/mixed; boundary=" [{"} skip boundary 2 {"}] message: build-attach-body message files boundary ] ;-- Send as an SMTP batch or individually addressed: smtp-port: open [scheme: 'esmtp] either only [ ; Only one message to multiple addrs address: copy address ; remove non-email values remove-each value address [not email? :value] message: head insert insert tail net-utils/export header-obj newline message insert smtp-port reduce [from address message] ] [ foreach addr address [ if email? addr [ if not show [insert clear header-obj/to addr] tmp: head insert insert tail net-utils/export header-obj newline message insert smtp-port reduce [from reduce [addr] tmp] ] ] ] close smtp-port ] resend: func [ "Relay a message" to from message /local smtp-port ][ smtp-port: open [scheme: 'esmtp] insert smtp-port reduce [from reduce [to] message] close smtp-port ] build-attach-body: function [ {Return an email body with attached files.} body [string!] {The message body} files [block!] {List of files to send [%file1.r [%file2.r "data"]]} boundary [string!] {The boundary divider} ][ make-mime-header break-lines file val ][ make-mime-header: func [file] [ net-utils/export context [ Content-Type: join {application/octet-stream; name="} [file {"}] Content-Transfer-Encoding: "base64" Content-Disposition: join {attachment; filename="} [file {"^/}] ] ] break-lines: func [mesg data /at num] [ num: any [num 72] while [not tail? data] [ append mesg join copy/part data num #"^/" data: skip data num ] mesg ] if not empty? files [ insert body reduce [boundary "^/Content-type: text/html^/^/"] append body "^/^/" if not parse files [ some [ (file: none) [ set file file! (val: read/binary file) | into [ set file file! set val skip ;anything allowed to end ] ] ( if file [ repend body [ boundary "^/" make-mime-header any [find/last/tail file #"/" file] ] val: either any-string? val [val] [mold :val] break-lines body enbase val ] ) ] ] [net-error "Cannot parse file list."] append body join boundary "--^/" ] body ] | |
i find it on http://www.rebol.org/ | |
do %./send.r header: make system/standard/email [ Subject: rejoin ["example REBOL "] Organization: "" Content-Type: "multipart/html" ] msg: rejoin [ {<img src = "test.jpg" /> </html>} ] send/header/attach [[cr-:-fideurambank-:-lu]] msg header [%test.jpg] | |
with this you can send mail with images in html | |
amacleod 1-Jun-2010 [3237] | Nice Claude! I'll check it out. Thanks. |
GiuseppeC 1-Jun-2010 [3238] | Thanks Claude, I'll try to use this too. |
Davide 1-Jun-2010 [3239] | To display the image inline the header "Content-ID" is mandatory. So add something like: Content-ID: rejoin ["<" file ">"] And use that id to reference the image in html, prefixed with string "cid:" <img src="cid:test.jpg" /> |
PatrickP61 23-Sep-2010 [3240] | I want to capture only the function names in a block and write it to a file. The WHAT function does this by printing a list of function names and then a short description. I tried this: data: to-block what ** Script error: to-block does not allow unset! for its value argument How can I just capture the Function names in a block using WHAT? |
Graham 23-Sep-2010 [3241] | have a look at the source of 'what and modify it? |
PatrickP61 23-Sep-2010 [3242] | that is a possibility of course, but I thought there would be a faster way of just capturing the printed output into a blcok |
Gregg 23-Sep-2010 [3243] | Unfortunately some functions, like WHAT, weren't designed with that in mind. |
Chris 23-Sep-2010 [3244] | You can use 'echo to capture the result in a temporary file, then delete the file after: echo %tmp.txt what echo none parse read %tmp.txt [...] delete %tmp.txt Shame you can't echo to a string or binary... |
PatrickP61 23-Sep-2010 [3245] | Chris, That is a good idea, for the quick and dirty, but I am having an issue with WHAT WHAT has what is supposed to be an optional field for module name that follows it. But if I do this: echo %tmp.txt what echo none This is processed as if it was this: echo %tmp.txt what echo <--- echo becomes the passed parameter into WHAT none How do I get around that other than specifying a dummy field? Try this: echo %tmp.txt what halt <--- halt will NOT be executed since it is pulled into the WHAT function!! echo none |
BrianH 23-Sep-2010 [3246x2] | It's only optional from the command line, not within a script. |
In a script, try what (). | |
PatrickP61 23-Sep-2010 [3248] | Will do |
BrianH 23-Sep-2010 [3249] | or (what) |
PatrickP61 23-Sep-2010 [3250x2] | That works just fine! Thanks |
What is the easiest way to capture the first literal in a string? LIST: {?? Debug print a word, path, or blo...} I tried FIRST TO-BLOCK LIST but got this: >> first to-block list ** Syntax error: invalid "word" -- "word," ** Where: to to-block ** Near: (line 1) ?? Debug print a word, pat... It works when I have a valid word (not ?? or other) | |
Steeve 23-Sep-2010 [3252] | first load/next list |
BrianH 23-Sep-2010 [3253x2] | >> a: {?? Debug print a word, path, or blo...} == {?? Debug print a word, path, or blo...} >> parse a [return to " "] == "??" |
That's R3 though. | |
PatrickP61 23-Sep-2010 [3255x2] | Yeah, I'm in R3 |
They both work! Thanks | |
BrianH 23-Sep-2010 [3257] | >> to-word parse a [return to " "] == ?? It will be faster than LOAD/next, trust me. Might be slower than TRANSCODE/next though. |
PatrickP61 23-Sep-2010 [3258] | Parse is very fast I guess?? |
BrianH 23-Sep-2010 [3259x2] | Yes, but TRANSCODE is faster. However, TRANSCODE only works on UTF8 binary, so when you add the binary conversion the PARSE method ends up being marginally faster. |
>> dp [first transcode/next to-binary a] == make object! [ timer: 0:00:00.000013 evals: 15 eval-natives: 6 eval-functions: 2 series-made: 4 series-freed: 1 series-expanded: 1 series-bytes: 570 series-recycled: 0 made-blocks: 2 made-objects: 0 recycles: 0 ] >> dp [to-word parse a [return to " "]] == make object! [ timer: 0:00:00.000012 evals: 17 eval-natives: 5 eval-functions: 2 series-made: 2 series-freed: 0 series-expanded: 0 series-bytes: 435 series-recycled: 0 made-blocks: 1 made-objects: 0 recycles: 0 ] >> b: to-binary a == #{ 3F3F20202020202020202020202020202020202020204465627567207072696E 74206120776F72642C20706174682C206F7220626C6F2E2E2E } >> dp [first transcode/next b] == make object! [ timer: 0:00:00.00001 evals: 11 eval-natives: 5 eval-functions: 1 series-made: 3 series-freed: 1 series-expanded: 1 series-bytes: 512 series-recycled: 0 made-blocks: 2 made-objects: 0 recycles: 0 ] | |
PatrickP61 23-Sep-2010 [3261] | Will ECHO write a file in UTF-8 and so allow me to use TRANSCODE? |
older newer | first last |