Create Yahoo! Mail Macros

Create Yahoo! Mail Macros

With a combination of email drafts, direct URL bookmarks, and bookmarklets, you can send complex emails with one click.

In the world of office software, a macro is a little bit of code that combines several steps of a process into a single click. Macros take advantage of a computer's ability to automate tasks and can significantly reduce any repetitive task that needs to be done. Taking this thinking to the world of Yahoo! Mail, you can create your own Yahoo! Mail macros to help you send messages.

The normal process of sending a message involves going to Yahoo! Mail, clicking the Compose button, selecting a recipient, typing a subject and message, and clicking the Send button. These steps aren't very labor-intensive, but if you find yourself sending the same types of email again and again, there are a few ways you can speed things up.


Imagine you send a weekly email with some statistics to a group of coworkers. The introduction, explanation, and ending of the email stay the same from week to week, with only a bit of text in the middle changing each time. The simplest way to automate this type of message is with the built-in Drafts folder at Yahoo! Mail. Draft emails are like templates that can be used and reused as many times as you need.

To create a draft, browse to the standard email form at Yahoo! Mail ( by clicking Compose Mail on the navigation menu or pressing Shift-Ctrl-P on the keyboard. Give the email a descriptive subject line, such as "weekly stats message" so you'll remember what the message is for without reading the text of the message. Create the email as if you were sending it out, but when you're finished, click the "Save as a Draft" button instead of clicking Send.

Now, whenever you want to use the email you just composed as a template, click on the Drafts folder from your list of folders and find this message in your list. Click on the message subject to bring the email up for editing. Make any changes you need to the email, add any recipients, and click Send. The message will still be available in your Drafts folder, and you can use the message just like this at any time. If you ever want to remove a draft email from your Drafts folder, manually delete it by checking the box next to the subject and clicking the Delete button.

Yahoo! Mail Bookmarks

Another way to automate common tasks is by creating your own Yahoo! Mail URLs. With some information about how Yahoo! Mail URLs are constructed, you can create a direct link to the Yahoo! Mail form with the fields prefilled for you. For example, if you find yourself sending out the same email over and over again, you could create a direct link to your Yahoo! Mail that includes the full message and subject, saving you some copying and pasting.

To get started, click the Mail tab and then click the Compose button. Note the base URLeverything up to the It should look something like this:

This base URL will vary based on the localized version of Yahoo! you're using and the way Yahoo! is balancing its servers. With the base URL in hand, add the following to specify the mail form and include your Yahoo! ID:

	/ym/Compose?insert Yahoo! IDnull

So, putting these pieces together will give you blank new mail form, like so:

	Insert base URL/ym/Compose?insert Yahoo! IDnull

To see the form change, add a variable/value pair to the end, using an ampersand (&), variable, equals sign (=), and value. For example, &[email protected] automatically adds the address [email protected] to the form:

	Insert base URL/ym/Compose?insert Yahoo! ID null &[email protected] 

Here are the variables you can use in the URL:


The email address of the recipient


An email address of a copied recipient


An email address of a blind-copied recipient


The subject of the email


The text of the message

Using a few of these variables together can give you a fairly complex message that's ready to go without any further action required beyond clicking the Send button. Here's an example: Yahoo! IDnull&to=
[email protected]&subject=hello&body=Hi%20Bob%2C%20this%20is%20my%20weekly%20

Note that the message text is URL-encoded, which means some characters, such as spaces, are converted to their URL code equivalent (%20 is the URL code equivalent for a space). Look carefully between those %20 s and you'll see the text of the message. This encoding is required because some characters (such as spaces) aren't allowed in URLs. Plugging this monster URL into your address bar will bring up a page like the one shown in Figure, with the fields already filled in.

Bookmark your newly created URL and give it a snappy name, such as "mail to bob!," and you'll have a shortcut to frequently sent mail.

Yahoo! Mail Bookmarklet

Now that you know how to bookmark prefilled mail forms, you can take this a step further to create a Yahoo! Mail bookmarklet. A bookmarklet is a bit of JavaScript that lives inside of a browser bookmark that is executed when you click it. Since bookmarklets can interact with the page you're currently viewing in the browser, your Yahoo! Mail bookmarklet can get information like the page title, current URL, and any text you might have highlighted.

A prefilled Yahoo! Mail form

The code.

This code creates a Send Link bookmarklet that sends information via Yahoo! Mail about the current web page you're viewing. As with other bookmarklets in this book, first a nicely formatted version of the code is shown, with the usable bookmarklet code to follow:

	// Dissected JavaScript bookmarklet for Send Link
	// Set d to the document object as a shortcut
	var d = document;

	// Set t to the currently selected text, if available
	var t = d.selection?d.selection.createRange().text:d.getSelection();

	// Build the body of the email that includes the current
	// document title, URL, and any selected text
	var b = d.title + '\n\n';
	b += d.location.href + '\n\n';
	b += '"' + t + '"\n\n';

	// Build the URL that will add a bookmark to Yahoo! Bookmarks
	var url = 'insert base URL  /ym/Compose? insert Yahoo! ID null&';

	// include the tile of the current page as the subject
	url += 'subject ='+escape(d.title)+'&';

	// include the title of the current page
	url += 'body ='+escape(b)+'&';

	// also send a copy of the email to yourself
	url += 'cc=insert your email address';

	// open a new window to bring up the mail form,

As you can see, this bookmarklet builds the appropriate Yahoo! Mail URL, including a message subject and body in the URL. Both are escaped for URLs with the escape() function. The body includes the title of the current site, its URL, and any text that is selected on the page.

And here's the code formatted appropriately for a bookmarklet:

\n';url='insert base URL /ym/Compose?insert Yahoo! ID null& subject ='+
escape(d.title)+'&body ='+escape(b)+'&[email protected]';void(window

It's not nearly as easy to read, but it's much morSe compact. Line breaks and comments have been removed from the code, and the JavaScript has been compacted wherever possible.

Running the hack.

Install the bookmarklet by creating a bookmark in your browser. Right-click the bookmark and choose Properties to edit the bookmark. In the Location field, paste the bookmarklet code and rename the bookmark Send Link!.

Imagine you'd like to send a friend a reference to the book pictured in Figure, along with the highlighted text describing the book.

After you click the Send Link! bookmarklet, a new window opens with title, URL, and the highlighted text prefilled at Yahoo! Mail, as shown in Figure.

From here, it's just a matter of filling in the To: field and clicking the Send button!

Understanding a bit more about how Yahoo! Mail works can help you streamline any repetitive email tasks or create new features similar to the Send Link! bookmarklet.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows