by Jack Wheeler
| When I first discovered how to use mailto: in Windows I was very excited, but then Peter Wayne mentioned the words "command lines" and my interest was heightened and focused. Here is what I learned about Email. |
In a previous article on email I showed how to launch an email program from Alpha Five. Until recently I had never been the least bit interested in dealing with emails and their associated protocols. I could never begin to compare myself to those of you who know the difference between a protocol and an ISP. I just figured that I would wait for those brains at Alpha Software to come up with their own email interface and all the associated goodies for us. BUT
Did you know that Windows has variables that all mail server programs use as their basis? Did you know that there are command lines and switches that you can use to launch and modify most email programs?
Here are the variables used in a typical Email program, in this case, Internet Explorer for Windows:

Figure 1. Email variables. (Editor's note: BCC means "blind carbon copy" and is used to send a copy of a message to someone without notifying the other recipients. Sneaky, isn't it?)
These variables are:
Code must start out with the Mailto: variable
Use the (?) between the first two variables
Use the (&) between all others
Character count cannot exceed 457 - system will crash if you exceed this
number!
Works for Netscape and Outlook
Example Is [All in one line]
mailto:jwl1@jps.net, law10@jps.net, ford20@earthlink.net?CC=peterwayne@inex.com&BCC=belinda@aa.net&subject=Re: Proposal you wanted&priority=highest&Body=hello there, hope you have a good day an lots of fun
This is how it looks:
Figure 2. Message generated in Internet Explorer by the above example.
This kind of code works well if you need to send a small message to lots of people. On a form you can create your own email phone book and send your message to a number of filtered addresses. Or if you simply want to include an attachment to lots of people this works well. I think you can send out around 270 emails at a time this way - not bad! Warning: If you happen to have Microsoft Word open it will crash using this kind of code. Winword.exe is somehow affiliated with Windows and a universal email form. In any event this is a powerful method for starting your own email address book within your current tables.
Now for the switches:
For Microsoft outlook you can look to the web page at http://support.microsoft.com/support/kb/articles/Q197//7/82.ASP?LNG=ENG&SA=ALLKB
To start Outlook and address an email you would use this command line:
"C:\program files\Microsoft office\office\outlook.exe" /c.ipm.note/ m <email address>
To start outlook and attach an attachment you would use this line:
"C:\program files\Microsoft office\office\outlook.exe" /a "c:\my documents\invoice.doc"
The problems with these command lines are that they are too restrictive: you can only enter one address at a time and only one attachment per email. You cannot include a body text or a subject line. Rather cumbersome and limiting! However, you can use Alpha Five's sys_send_keys() to overcome these limits.
Here is the best code I could come up with (all one line)
"C:\program files\Microsoft office\office\outlook.exe" /c.ipm.note/ m jwl1"jps.net a/ "c:\my documents\invoice.doc"
In Microsofts defense, they have left Outlook 97 and Outlook2000 open ended, in that you have the ability to completely design and code your own forms and variables. They have many books to help with this. It may be worth the time and energy to research Outlook since many companies are now using this program for inter-office mail and the calendar that is included in the product.
Netscape Navigator is another story. This company seems so bent on beating Microsoft's Explorer that they give the user the ability to extensively modify Navigator. I even found a wonderful FREE download that enables the user to custom design their own Navigator setup program. (You can code exclusively for Netscape messenger and include the setup program with your program; you will find this on Netscapes developer site.)
Netscape has some wonderful switches found at
http://developer.netscape.com/docs/manuals/deploymt/options.htm
Now I am not the sharpest tool in the shed, so you will have to bear with me on my inability to understand some of these switches. If you figure them out email Dr Wayne and he will add them to the article.
Here are the rules for syntax, etc.:
I tried every combination to read more than one attachment but to no avail: I could not find a way to include the email address or the subject as well as multiple attachments. However, I found a way to include a RTF memo field into the body by means of creating a text file and including that into it. This gave me an easy way of emailing my customers little notes and letters as I commonly do daily. What a time saver, especially since I could simply save each message when I exited Alpha Five and send them all when I log onto the internet. Here is what I did:
Since RTF fields allow text attributes and formatting I have started utilizing them 100% of the time. I do not use any regular memo fields. It takes a lot more work since Xbasic does not allow direct manipulation of RTF fields through any coding I know. I already have a generic letterform that allows me to type a creative letter and prints it on a letterhead. All I did was add TWO buttons for email and I was off!
Figure 3. My email form.
You can read my article on rich text letters to see how I use the sys_send_keys() function to prepare my letter. Once my letter is complete I change the color of the fonts for the second button and I press it to send the email. Here is the code on button one:
dim t as p
dim f as p
dim client as c
dim email as c
dim subject as c
dim body as c
dim message as c
dim txt as b
dim text as c
dim attach as c
f=parentform.this
if f:email.text = "" then
f:email.text = ui_get_text("EMAIL","What is the Email
address?")
end if
if Email.text = "" then
ui_msg_box("Failed","You failed to supply an address")
end
end if
parent.commit()
f:notes.activate()
sys_send_keys("{Alt-E}A")
sys_send_keys("{Alt-E}C")
f:button4.font.color="GREEN"
Script 1. OnPush script for button1.
Here is the code on the second button (called on the form button4)
dim t as p
dim f as p
dim client as c
dim email as c
dim subject as c
dim file_names[250] as c
dim body as c
dim message as c
dim txt as b
dim text as c
dim attach as c
dim file1 as c
dim file2 as c
dim file3 as c
f=parentform.this
f:button4.font.color="buttontext"
old_directory = dir_get()
dir_put("c:\my documents")
files = filefind.first("*.*")
i = 1
WHILE .not. files.eof()
file_names[i] = files.name()
files.next()
i = i+1
END WHILE
dir_put(old_directory)
sort_array("file_names")
file1= ui_get_list_array("Choose an Attachment",3,"file_names")
email=f:email.text
subject = "Re: Message from Jack Wheeler"
text = :clipboard.get_data()
filename ="c:\memos.txt"
if file.exists(filename) then
file.remove(filename)
end if
fil = file.create(filename, FILE_RW_EXCLUSIVE)
fil.close()
fil = file.open(filename, FILE_RW_shared)
size = file.bytes_get()
fil.seek(size)
fil.write_line("")
fil.write_line(text)
fil.flush()
fil.close()
cmd="C:\progra~1\netscape\program\Netscape.exe"+\
"-compose "+alltrim(filename)+" "+chr(34)+"-c:\mydocuments"+\
chr(92)+file1+chr(34)
sys_shell(cmd,1)
sleep(5)
:clipboard.set_data(email)
sys_send_keys("{ctrl-v}")
sys_send_keys("{tab}")
:clipboard.set_data(subject)
sys_send_keys("{ctrl-v}")
END
Script 2. The OnPush code for Button4.
Here is what the form looks like filled in after the second button is pressed:
As you can see there is a lot you can do with emails within alpha five now. Since emails are a big part of our lives now you should include them in everything you do from now on.
Here are the problems I came across with these procedures
I hope you can benefit from these explorations into Email. If you figure out ways to improve upon these methods, please let us know!
2/16/00
Don't forget, we need your feedback to make this site better!