Windows Explorer “Send To” in HTML with Signature and Multiple Attachments

By Stephen  

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

  1. Kalahari_kudu
    Posted 6 October 2008 at 8:43 am | Permalink

    Excellent work!

    It is a shame that we have to resort to a custom script to get something as simple as this sorted out!

  2. ced
    Posted 18 May 2009 at 9:33 am | Permalink

    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?

  3. Stephen
    Posted 18 May 2009 at 12:35 pm | Permalink

    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 ;-)

  4. Joe
    Posted 12 August 2009 at 9:10 pm | Permalink

    I tried this with Office 2003 on Windows XP. It works and that’s what counts. Great job.

  5. Corey Reynolds
    Posted 12 September 2009 at 6:30 pm | Permalink

    Thank you, you had no idea how much this drove me crazy. And now it actually WORKS as it always should have.

  6. Scott
    Posted 14 September 2009 at 7:33 pm | Permalink

    Awesome thanks…why MS would think this is hard, wrong or not needed is beyond reason.

  7. Felix
    Posted 7 December 2009 at 11:02 pm | Permalink

    Thanks- Works great!

  8. zorro
    Posted 28 January 2010 at 3:06 pm | Permalink

    TOO COOL

  9. acronimus
    Posted 12 February 2010 at 11:00 am | Permalink

    It really works ! Thanks for sharing us !
    I tried with office 2003 and office xp and works .

  10. Bursting Energy
    Posted 22 February 2010 at 1:40 pm | Permalink

    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

  11. Posted 12 May 2010 at 12:23 pm | Permalink

    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.

  12. Sam
    Posted 13 May 2010 at 1:54 am | Permalink

    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

  13. Stephen
    Posted 13 May 2010 at 4:04 pm | Permalink

    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.

  14. Adam
    Posted 22 May 2010 at 1:48 pm | Permalink

    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)

  15. Francis Garcia
    Posted 29 June 2010 at 8:21 pm | Permalink

    Worked very well for me. Stephen, you ROCK

One Trackback

  1. [...] 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 [...]

Post a Comment

Your email is never shared.