Email Attachment: text files
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Email Attachment: text files
Hi,
I need to add the option in a Windows project to send an email and add 2-3 text files as attachments. I can use revMail in a button to generate the email, but cannot figure out how to automatically add the 2-3 text files (these are plain text files) found in the app's directory as email attachments.
From researching and reading online, it doesn't appear that this is easily solved.
Has anyone solved adding email attachments in a Windows app (would appreciate seeing any script for this)? Alternately, has anyone seen a plug-in that can be added to accomplish this?
Kind Regards,
I need to add the option in a Windows project to send an email and add 2-3 text files as attachments. I can use revMail in a button to generate the email, but cannot figure out how to automatically add the 2-3 text files (these are plain text files) found in the app's directory as email attachments.
From researching and reading online, it doesn't appear that this is easily solved.
Has anyone solved adding email attachments in a Windows app (would appreciate seeing any script for this)? Alternately, has anyone seen a plug-in that can be added to accomplish this?
Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
Hi Coach,
unfortunately "RevMail" does not support mail attachments.
But here you will find a library that lets you do this:
http://troz.net/Rev/libraries.php
Best
Klaus
unfortunately "RevMail" does not support mail attachments.
But here you will find a library that lets you do this:
http://troz.net/Rev/libraries.php
Best
Klaus
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
I'm not sure exactly what function RevMail is capable of, but if it allows you raw text handling, then you should be able to make attachments yourself. You would need to base64 encode the files for attachment and then include the resulting text output from the base64 encoding into the raw email. Of course, that means you'll also need to input the proper email header information and markers at the beginning of each attachment. You'll also want to read up on RFC821 and probably a few other RFCs, which I can't remember their numbers. RFC821 covers SMTP but I don't remember if it also covers the structure of the email itself. It's been so long since I've done any such work, so I could be off a bit.
Unless between RevMail and the Lib Klaus pointed out does what you need, then all the above I mention is just babble and simply disregard it.
Unless between RevMail and the Lib Klaus pointed out does what you need, then all the above I mention is just babble and simply disregard it.

'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi Garrett,
Thanks for your suggestions. I think a little complex for me as a beginner with just a few weeks of learning RunRev.
The text files are space delimited text, so in order to read them on the other end of their being emailed, they need to retain their format. The easiest way, if possible, would be to encrypt them for privacy and send them as email attachments.
The library is interesting, but it requires the user to enter their smtp server address, maybe authentication (if used). While many users will be capable, some of the users for the project may not easily be able to figure this out. (I wish on a Windows machine with an email program like Outlook installed, there was an easy way to get their smtp server address and enter it for them, but I suspect this is not possible.)
HTML email would be another option if it could add the text file attachments and be easy for the user to quickly configure. (I looked for Andre Garcia's HTML sample on RevOnline, but didn't find it yet.)
In my eLearning projects, I've found that the easier and more automated for the user, when possible, the better.
An interesting challenge.
Kind Regards,
Thanks for your suggestions. I think a little complex for me as a beginner with just a few weeks of learning RunRev.
The text files are space delimited text, so in order to read them on the other end of their being emailed, they need to retain their format. The easiest way, if possible, would be to encrypt them for privacy and send them as email attachments.
The library is interesting, but it requires the user to enter their smtp server address, maybe authentication (if used). While many users will be capable, some of the users for the project may not easily be able to figure this out. (I wish on a Windows machine with an email program like Outlook installed, there was an easy way to get their smtp server address and enter it for them, but I suspect this is not possible.)
HTML email would be another option if it could add the text file attachments and be easy for the user to quickly configure. (I looked for Andre Garcia's HTML sample on RevOnline, but didn't find it yet.)
In my eLearning projects, I've found that the easier and more automated for the user, when possible, the better.
An interesting challenge.
Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
I gave the wrong RFC anyway, that covered SMTP only. RFC5322 http://tools.ietf.org/html/rfc5322 covers the structure of an email, but yes, it's a long verbose document and likely not for the faint of heart either.
Building a good solid and full featured email sending client is not very simple unless the programming language you use has it all built in. I never looked into Rev's email functions myself.
Back in the late 90's I built my own SMTP server. The language I used back then had little to no support for such things. I had to code it all right down to the raw tcp/ip communications myself. It took a lot of code, headaches and time. After that I never again ventured on to a project that was related to email. Hell, I built an encrypted Instant Message system that was easier than making an SMTP server. You'd think that would be harder, but it wasn't.
If Rev does not offer everything you need directly, you might consider looking for some command line tools to use along with Rev itself.
Sorry if I added confusion here and hope that I didn't deter you from your goal. Just keep on going with it until you see it through. You might hit some hard hurdles, but don't let that stop you.
Building a good solid and full featured email sending client is not very simple unless the programming language you use has it all built in. I never looked into Rev's email functions myself.
Back in the late 90's I built my own SMTP server. The language I used back then had little to no support for such things. I had to code it all right down to the raw tcp/ip communications myself. It took a lot of code, headaches and time. After that I never again ventured on to a project that was related to email. Hell, I built an encrypted Instant Message system that was easier than making an SMTP server. You'd think that would be harder, but it wasn't.
If Rev does not offer everything you need directly, you might consider looking for some command line tools to use along with Rev itself.
Sorry if I added confusion here and hope that I didn't deter you from your goal. Just keep on going with it until you see it through. You might hit some hard hurdles, but don't let that stop you.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
BTW, regarding the users to input their smtp accounts. If that's not an option, you have two choices then:
A) Create a built in SMTP server which doesn't require the users to input such info except maybe their own name and email address. (see my comment above regarding making an SMTP server)
B) Setup a general purpose email account on your own email server for the users of your program to send the emails through. This would require you to hard code the SMTP information so they don't need to worry about it. But like above, you'd need them to at least input their name and email address.
Of course, you could use B along with RevMail, but you'd still be left with the problem of setting your attachments.
A) Create a built in SMTP server which doesn't require the users to input such info except maybe their own name and email address. (see my comment above regarding making an SMTP server)
B) Setup a general purpose email account on your own email server for the users of your program to send the emails through. This would require you to hard code the SMTP information so they don't need to worry about it. But like above, you'd need them to at least input their name and email address.
Of course, you could use B along with RevMail, but you'd still be left with the problem of setting your attachments.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi Garrett,
One work around, using a library, could be to add a button with an "ask" script, specifying that the user enter their email address minus their name and "@". Then hard-coding the smtp field's contents with "smtp." and scripting to add their input "after" that content will in some-many cases produce their smtp address. But, far from a perfect solution.
Command line utilities may be another way to go...
(The server route is probably way too complex for me, plus I have my site using an ISP's shared Windows hosting which I suspect would not give access to this, even if I could figure it out.)
Kind Regards
One work around, using a library, could be to add a button with an "ask" script, specifying that the user enter their email address minus their name and "@". Then hard-coding the smtp field's contents with "smtp." and scripting to add their input "after" that content will in some-many cases produce their smtp address. But, far from a perfect solution.
Command line utilities may be another way to go...
(The server route is probably way too complex for me, plus I have my site using an ISP's shared Windows hosting which I suspect would not give access to this, even if I could figure it out.)
Kind Regards
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi,
Another option, mentioned by Klaus, is to use an SMTP mailer library like SMTPlibrary.rev at http://troz.net/Rev/libraries.php.
What I can't find in online reading or accompanying materials is how to include an external library like this in a RunRev project.
Would this involve placing the library's functions in a substack, calling these using scripts in controls added to another substack in the project? I think I am confusing a library with a plug-in, so I am not sure how to use a library.
I would much appreciate any suggestions, leads, examples of how to use/import external libraries for a project.
Kind Regards,
Another option, mentioned by Klaus, is to use an SMTP mailer library like SMTPlibrary.rev at http://troz.net/Rev/libraries.php.
What I can't find in online reading or accompanying materials is how to include an external library like this in a RunRev project.
Would this involve placing the library's functions in a substack, calling these using scripts in controls added to another substack in the project? I think I am confusing a library with a plug-in, so I am not sure how to use a library.
I would much appreciate any suggestions, leads, examples of how to use/import external libraries for a project.
Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
There are several ways to use a library. In this case I would suggest one of the simplest is to open both the main application stack and the "library" stack in the IDE at the same time. In the "Basic Settings" pane of the stack inspector for the library stack, change the mainstack to refer not to itself, but to the main application stack.
Then on opening the mainstack, in say the preOpenStack handler, add the line
That will make all the library code available to all the cards and substacks of your project.
There are other ways of including code as libraries, such as inserting frontscripts or backscripts, but this way is a conveniently simple method of including everything in your project in a portable way.
Then on opening the mainstack, in say the preOpenStack handler, add the line
Code: Select all
start using stack "<yourLibraryStackNameHere>"
There are other ways of including code as libraries, such as inserting frontscripts or backscripts, but this way is a conveniently simple method of including everything in your project in a portable way.
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi SparkOut,
Thanks. OK, this works.
As I go forward, trying to learn, it will probably be helpful to figure out some of the other ways to script and include library functions.
Again, thanks.
Kind Regards,
Thanks. OK, this works.
As I go forward, trying to learn, it will probably be helpful to figure out some of the other ways to script and include library functions.
Again, thanks.
Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi,
In trying to configure the functions for SMTP email, I am not sure how to add 2 or more files as attachments to the email (adding 1 file is not a problem).
In the SMTP email library, the relevant function takes the contents of the attachment field (fld "Attach") and puts it into the email, parsing it for SMTP handling.
If I script
then the email sends the xyz file as an attachment. But if I use
or
it does not send both files as email attachments.
A work a round is to use the property inspector for the field and hard code the 2 files into "Contents" (not wrapped, defaulted to the right edge) but the only way this works to add both files is if the second file is added in the next line below the first. (Is there a way to write a script to add the files in lines one below the other?)
xyz.txt
abc.txt
Any help would be appreciated.
Kind Regards,[/quote]
In trying to configure the functions for SMTP email, I am not sure how to add 2 or more files as attachments to the email (adding 1 file is not a problem).
In the SMTP email library, the relevant function takes the contents of the attachment field (fld "Attach") and puts it into the email, parsing it for SMTP handling.
If I script
Code: Select all
put "xyz.txt" into fld "Attach"
Code: Select all
put "xyz.txt" & "abc.txt" into fld "Attach"
Code: Select all
put ("xyz.txt" & "abc.txt") into fld "Attach"
A work a round is to use the property inspector for the field and hard code the 2 files into "Contents" (not wrapped, defaulted to the right edge) but the only way this works to add both files is if the second file is added in the next line below the first. (Is there a way to write a script to add the files in lines one below the other?)
xyz.txt
abc.txt
Any help would be appreciated.
Kind Regards,[/quote]
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
Hi Coach,
as far as I remember the library handles every LINE of that field as one file.
CR is the magic word
(RETURN will also work, but CR requires less typing!)
...
put "file1.txt" into fld "Attach"
put CR & "file2.txt" AFTER fld "Attach"
...
This one:
...
put "xyz.txt" & "abc.txt" into fld "Attach"
...
Will put "xyz.txtabc.txt" into fld "Attach" (as you MIGHT have seen after looking at the field!) and this is no valid filename so nothing gets attached!
Best
Klaus
as far as I remember the library handles every LINE of that field as one file.
CR is the magic word

(RETURN will also work, but CR requires less typing!)
...
put "file1.txt" into fld "Attach"
put CR & "file2.txt" AFTER fld "Attach"
...
This one:
...
put "xyz.txt" & "abc.txt" into fld "Attach"
...
Will put "xyz.txtabc.txt" into fld "Attach" (as you MIGHT have seen after looking at the field!) and this is no valid filename so nothing gets attached!
Best
Klaus
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
-
- Posts: 87
- Joined: Thu Jul 17, 2008 8:42 pm
Hi,
I can script a button so that the user can enter a password for encrypting a text file, using askPassword.
Once the user enters a password, the process goes forward. If the password is empty, they see a message saying essentially to start over by clicking the button again and entering a password (not very efficient).
Is there a way more efficiently start over by automatically "clicking" the button for them, so it starts over, but only starts over one time.
I have tried sending a mouseup to the button, but this causes an endless loop: they cannot cancel when they leave the password empty, without recycling again and again to the same button. Is there a way to send the mouseup to the button only once (gives them one more chance to set the password, not endless cycling)?
I can't figure out how to script this and would appreciate any help.
Kind Regards,
I can script a button so that the user can enter a password for encrypting a text file, using askPassword.
Once the user enters a password, the process goes forward. If the password is empty, they see a message saying essentially to start over by clicking the button again and entering a password (not very efficient).
Is there a way more efficiently start over by automatically "clicking" the button for them, so it starts over, but only starts over one time.
I have tried sending a mouseup to the button, but this causes an endless loop: they cannot cancel when they leave the password empty, without recycling again and again to the same button. Is there a way to send the mouseup to the button only once (gives them one more chance to set the password, not endless cycling)?
I can't figure out how to script this and would appreciate any help.
Kind Regards,
saratogacoach
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770
LiveCode 4.6.0, Windows 7 Home Premium 64 bit, Core i7 2.80, 8G RAM, ATI Radeon HD5770