http://smmeyer.com/scribble/?p=48
Have just recently finished putting together a bulk mailing application inside Excel to email preformatted html newsletters with embedded images. I learned a lot in the process and was able to solve a problem that has irritated me for years.
Previous research led me to the Micro$oft’s support website to this solution but it only attaches one of however many files you may have selected. I am now using a visual basic script file to replace the default MAPIMail link. It can send attachments via the explorer context menu in html format, with my default signature AND multiple attachments. It works for me with XP and Outlook 2007 so I hope it will for other versions of Outlook.
Create a new text document in Notepad, paste the code from below and save the file somewhere safe. Rename the file to “Mail Recipient.vbs”. Next create a shortcut and rename that to “Mail Recipient”. Customize the shortcut’s icon to the one found in C:/Windows/System32/Sendmail.dll and move your new shortcut to your “Send to” folder e.g. “C:\Documents and Settings\Stephen\SendTo\Mail Recipient.lnk”. Rather don’t delete the original MAPIMail link, just change it’s attributes to hidden (you may want it back again later).
Option Explicit
Dim objArgs, OutApp, oNameSpace, oInbox, oEmailItem, olMailItem
Dim a, oAttachments, subjectStr, olFormatHTML
olMailItem = 0
olFormatHTML = 2
Set objArgs = WScript.Arguments 'gets paths of selected files
Set OutApp = CreateObject("Outlook.Application") 'opens Outlook
Set oEmailItem = OutApp.CreateItem(olMailItem) ' opens new email
For a = 0 to objArgs.Count - 1
Set oAttachments = oEmailItem.Attachments.Add(objArgs(a))
subjectStr = subjectStr & Right(objArgs(a),Len(objArgs(a))-(InStrRev(objArgs(a),"\"))) & ", " 'recreates the default Subject e.g. Emailing: file1.doc, file2.xls
Next
If subjectStr = "" then subjectStr = "No Subject "
oEmailItem.Subject = "Emailing: " & Left(subjectStr, (Len(subjectStr)-2))
oEmailItem.BodyFormat = olFormatHTML
oEmailItem.Display
15 Comments
Excellent work!
It is a shame that we have to resort to a custom script to get something as simple as this sorted out!
Can you please elaborate. I dont understand what name have to put in the short cut icon?? I have create a short cut for the mail receipent. What should I do next?
Mmmm. I’m not too certain I understand what you’re asking but…
It’s not important what name you use for the shortcut – a shortcut can have any name you want so long as the path next to Target links to the VB Script file. I used the name “Mail Recipient” because I wanted the Send To menu to look the same as the default.
I wanted to use the same icon as the default Mail Recipient shortcut (an open envelope) so, inside the shortcut properties if you click Change Icon, then you must click Browse and go to your Windows/System32 folder and look for the sendmail.dll file.
Hope that helps
I tried this with Office 2003 on Windows XP. It works and that’s what counts. Great job.
Thank you, you had no idea how much this drove me crazy. And now it actually WORKS as it always should have.
Awesome thanks…why MS would think this is hard, wrong or not needed is beyond reason.
Thanks- Works great!
TOO COOL
It really works ! Thanks for sharing us !
I tried with office 2003 and office xp and works .
Thanks for that. There’s not many times when a solution works first time and so easily like that.
Are you a PC, is Windows 7 your creation? haha… ta
That’s Great!
I created a custom icon (the old one with an ‘S’ on it) and named it “Mail Recipient (signed)”.
I’m thinking to write a batch script that will copy the script, icon and shortcut to the correct folders of the current user – almost like an installation file.
Using Outlook 2003…
This works great; however, I cannot seem to make it work with Adobe Acrobat Reader 9. If I click “attach to email” from within the reader, it still opens/creates an email without a signature. I can insert the signature, but need the signature to be automatically added. I’ve restarted both Outlook and Adobe Reader with the same results. Any ideas?
Thanks,
Sam
I can’t say for certain, but my best guess would be that Reader uses it’s own built in programming to do the same task, and that Adobe were equally as lazy as Microsoft when they implemented it.
Stumbled on this by shear luck. How awesome. Been wanting to do this for ages. Does the script allow for the “to:” box to be filled out automatically with an email address? (I have to send a file everyday to the same person)
Worked very well for me. Stephen, you ROCK
One Trackback
[...] had searched for a fix to this problem and I stumbled upon Stephen’s Scribble Pad describing how to replace the default MAPIMail link with a visual basic script file. Additionally [...]