Macros and Programming


CardboxForumsMacros and Programming > "pick a name for email"

pick a name for email

Current user: [none]
Register / Log In · Help

Posted By Post

Charles Welling

10-Oct-2007 15:13

Here's a small macro that some of you may find useful. We have several databases that contain data that is sent to somebody by e-mail. I've made macros for all users to do this, so that they automatically use the right format and do not send the entire database instead of a single record.
Most people want to pick a name from a list and hit OK instead of typing the address.
The following macro takes care of that. First, it presents the user with an inputbox to type in the address. If no address is entered, the macro shows the content of a folder. This folder (in this case a subfolder of "F:\Cardbox3" called "Email") contains text files without the ".txt" extension. Each filename is a name, such as "John" or "Mary" or whatever. So, what the users sees is a list of names. When such a file is clicked, the macro reads the contents of that file, which is a single line that constitutes the actual e-mail address.
E.g. the file "John" may contain the line "john.johnson@hiscompany.com".

Please note that:
You don't need the inputbox. If you ALWAYS want to pick a name, remove the inputbox line as well as the IF-statement.

You may also make files that have the name of an entire group of people. Such a file could contain more than a single address. Use the SPLIT command to send an e-mail to everyone in that file.

Here's the macro:

addressee=InputBox("E-mail to whom?" & vbCrLf & "Or click OK immediately to pick a name.", "Enter the e-mail address.")

if addressee="" then
name=GetOpenFilename("","F:\cardbox3\Email","Pick a name.")
set fso=CreateObject("Scripting.FileSystemObject")
Set name=fso.OpenTextFile(name)
set fso=nothing
end if


Quick Reply

Please log in or register before trying to post a reply.

© 2010 Cardbox Software Limited   Home