Posted By

Scooter on 04/27/14


Tagged


Versions (?)

Send to mail recipient using Outlook


 / Published in: Visual Basic
 

URL: http://www.howtogeek.com/howto/windows-vista/customize-the-windows-vista-send-to-menu/

Copy-paste into a .VBS file and create a shortcut in the SendTo folder

  1. Option Explicit
  2. Dim objArgs, OutApp, oNameSpace, oInbox, oEmailItem, olMailItem
  3. Dim a, oAttachments, subjectStr, olFormatHTML
  4. olMailItem = 0
  5. olFormatHTML = 2
  6. Set objArgs = WScript.Arguments 'gets paths of selected files
  7. Set OutApp = CreateObject("Outlook.Application") 'opens Outlook
  8. Set oEmailItem = OutApp.CreateItem(olMailItem) 'opens new email
  9. For a = 0 to objArgs.Count - 1
  10. Set oAttachments = oEmailItem.Attachments.Add(objArgs(a))
  11. subjectStr = subjectStr & Right(objArgs(a),Len(objArgs(a))-(InStrRev(objArgs(a),"\"))) & ", " 'recreates the default Subject e.g. Emailing: file1.doc, file2.xls
  12. Next
  13. If subjectStr = "" then subjectStr = "No Subject "
  14. oEmailItem.Subject = "Emailing: " & Left(subjectStr, (Len(subjectStr)-2))
  15. oEmailItem.BodyFormat = olFormatHTML
  16. oEmailItem.Display

Report this snippet  

You need to login to post a comment.