Previous Topic

Next Topic

Book Contents

Book Index

Home Page

Sending E-Mail from a Simple Mail Client

The basic procedure for sending mail with a client that does not support COM (e.g., Microsoft Outlook, Eudora) is as follows:

Sending e-mail with a client that does not support COM is a more risky and unreliable venture, but it can be done. The sample code below shows one possible implementation for Eudora:

Dim WshShell, StartTime
' Create a WSH Shell object.
Set WshShell = _
CreateObject("WScript.Shell")
' Launch e-mail URL.
WshShell.Run _
"mailto:someone@somewhere.com" + _
"?Subject=Test%20Message" + _
"&Body=Hi%20There!"
' Get current time
StartTime = Now()
' Wait for 20 seconds for mail app to start
Do While StartTime > Now() - 20/CDbl(3600*24)
Loop
' Activate Eudora's window.
WshShell.AppActivate "Eudora Pro"
' Send the Ctrl-e sequence to send mail.
WshShell.SendKeys "^e"
' Wait for 15 seconds to finish sending mail.
StartTime = Now()
Do While StartTime > Now() - 15/CDbl(3600*24)
Loop
' Activate Eudora window again.
WshShell.AppActivate "Eudora Pro"
' Send a Ctrl-q to quit the program.
WshShell.SendKeys "^q"

Similar techniques can be used for other e-mail clients. Notice that the "mailto" URL request must be formatted as a URL: no spaces are allowed and all spaces have been replaced with "%20".

See Also

How to Send E-Mail from a Macro

Sending E-Mail with a COM Compliant Client

Reading E-Mail from a COM Compliant Client

Sending E-Mail with Microsoft CDO